uninstall.sh 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/oneinstack/oneinstack
  10. export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
  11. clear
  12. printf "
  13. #######################################################################
  14. # OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+ #
  15. # Uninstall OneinStack #
  16. # For more information please visit https://oneinstack.com #
  17. #######################################################################
  18. "
  19. # Check if user is root
  20. [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
  21. oneinstack_dir=$(dirname "`readlink -f $0`")
  22. pushd ${oneinstack_dir} > /dev/null
  23. . ./options.conf
  24. . ./include/color.sh
  25. . ./include/get_char.sh
  26. . ./include/check_dir.sh
  27. Show_Help() {
  28. echo
  29. echo "Usage: $0 command ...[parameters]....
  30. --help, -h Show this help message, More: https://oneinstack.com
  31. --quiet, -q quiet operation
  32. --all Uninstall All
  33. --web Uninstall Nginx/Tengine/OpenResty/Apache/Tomcat
  34. --mysql Uninstall MySQL/MariaDB/Percona/AliSQL
  35. --postgresql Uninstall PostgreSQL
  36. --mongodb Uninstall MongoDB
  37. --php Uninstall PHP (PATH: ${php_install_dir})
  38. --mphp_ver [53~73] Uninstall another PHP version (PATH: ${php_install_dir}\${mphp_ver})
  39. --allphp Uninstall all PHP
  40. --phpcache Uninstall PHP opcode cache
  41. --php_extensions [ext name] Uninstall PHP extensions, include zendguardloader,ioncube,
  42. sourceguardian,imagick,gmagick,fileinfo,imap,ldap,phalcon,
  43. yaf,redis,memcached,memcache,mongodb,swoole,xdebug
  44. --hhvm Uninstall HHVM
  45. --pureftpd Uninstall PureFtpd
  46. --redis Uninstall Redis-server
  47. --memcached Uninstall Memcached-server
  48. --phpmyadmin Uninstall phpMyAdmin
  49. --python Uninstall Python (PATH: ${python_install_dir})
  50. "
  51. }
  52. ARG_NUM=$#
  53. TEMP=`getopt -o hvVq --long help,version,quiet,all,web,mysql,postgresql,mongodb,php,mphp_ver:,allphp,phpcache,php_extensions:,hhvm,pureftpd,redis,memcached,phpmyadmin,python -- "$@" 2>/dev/null`
  54. [ $? != 0 ] && echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1
  55. eval set -- "${TEMP}"
  56. while :; do
  57. [ -z "$1" ] && break;
  58. case "$1" in
  59. -h|--help)
  60. Show_Help; exit 0
  61. ;;
  62. -q|--quiet)
  63. quiet_flag=y
  64. uninstall_flag=y
  65. shift 1
  66. ;;
  67. --all)
  68. all_flag=y
  69. web_flag=y
  70. mysql_flag=y
  71. postgresql_flag=y
  72. mongodb_flag=y
  73. allphp_flag=y
  74. hhvm_flag=y
  75. pureftpd_flag=y
  76. redis_flag=y
  77. memcached_flag=y
  78. phpmyadmin_flag=y
  79. python_flag=y
  80. shift 1
  81. ;;
  82. --web)
  83. web_flag=y; shift 1
  84. ;;
  85. --mysql)
  86. mysql_flag=y; shift 1
  87. ;;
  88. --postgresql)
  89. postgresql_flag=y; shift 1
  90. ;;
  91. --mongodb)
  92. mongodb_flag=y; shift 1
  93. ;;
  94. --php)
  95. php_flag=y; shift 1
  96. ;;
  97. --mphp_ver)
  98. mphp_ver=$2; mphp_flag=y; shift 2
  99. [[ ! "${mphp_ver}" =~ ^5[3-6]$|^7[0-3]$ ]] && { echo "${CWARNING}mphp_ver input error! Please only input number 53~73${CEND}"; exit 1; }
  100. ;;
  101. --allphp)
  102. allphp_flag=y; shift 1
  103. ;;
  104. --phpcache)
  105. phpcache_flag=y; shift 1
  106. ;;
  107. --php_extensions)
  108. php_extensions=$2; shift 2
  109. [ -n "`echo ${php_extensions} | grep -w zendguardloader`" ] && pecl_zendguardloader=1
  110. [ -n "`echo ${php_extensions} | grep -w ioncube`" ] && pecl_ioncube=1
  111. [ -n "`echo ${php_extensions} | grep -w sourceguardian`" ] && pecl_sourceguardian=1
  112. [ -n "`echo ${php_extensions} | grep -w imagick`" ] && pecl_imagick=1
  113. [ -n "`echo ${php_extensions} | grep -w gmagick`" ] && pecl_gmagick=1
  114. [ -n "`echo ${php_extensions} | grep -w fileinfo`" ] && pecl_fileinfo=1
  115. [ -n "`echo ${php_extensions} | grep -w imap`" ] && pecl_imap=1
  116. [ -n "`echo ${php_extensions} | grep -w ldap`" ] && pecl_ldap=1
  117. [ -n "`echo ${php_extensions} | grep -w phalcon`" ] && pecl_phalcon=1
  118. [ -n "`echo ${php_extensions} | grep -w yaf`" ] && pecl_yaf=1
  119. [ -n "`echo ${php_extensions} | grep -w redis`" ] && pecl_redis=1
  120. [ -n "`echo ${php_extensions} | grep -w memcached`" ] && pecl_memcached=1
  121. [ -n "`echo ${php_extensions} | grep -w memcache`" ] && pecl_memcache=1
  122. [ -n "`echo ${php_extensions} | grep -w mongodb`" ] && pecl_mongodb=1
  123. [ -n "`echo ${php_extensions} | grep -w swoole`" ] && pecl_swoole=1
  124. [ -n "`echo ${php_extensions} | grep -w xdebug`" ] && pecl_xdebug=1
  125. ;;
  126. --hhvm)
  127. hhvm_flag=y; shift 1
  128. ;;
  129. --pureftpd)
  130. pureftpd_flag=y; shift 1
  131. ;;
  132. --redis)
  133. redis_flag=y; shift 1
  134. ;;
  135. --memcached)
  136. memcached_flag=y; shift 1
  137. ;;
  138. --phpmyadmin)
  139. phpmyadmin_flag=y; shift 1
  140. ;;
  141. --python)
  142. python_flag=y; shift 1
  143. ;;
  144. --)
  145. shift
  146. ;;
  147. *)
  148. echo "${CWARNING}ERROR: unknown argument! ${CEND}" && Show_Help && exit 1
  149. ;;
  150. esac
  151. done
  152. Uninstall_status() {
  153. if [ "${quiet_flag}" != 'y' ]; then
  154. while :; do echo
  155. read -e -p "Do you want to uninstall? [y/n]: " uninstall_flag
  156. if [[ ! ${uninstall_flag} =~ ^[y,n]$ ]]; then
  157. echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
  158. else
  159. break
  160. fi
  161. done
  162. fi
  163. }
  164. Print_Warn() {
  165. echo
  166. echo "${CWARNING}You will uninstall OneinStack, Please backup your configure files and DB data! ${CEND}"
  167. }
  168. Print_web() {
  169. [ -d "${nginx_install_dir}" ] && echo ${nginx_install_dir}
  170. [ -d "${tengine_install_dir}" ] && echo ${tengine_install_dir}
  171. [ -d "${openresty_install_dir}" ] && echo ${openresty_install_dir}
  172. [ -e "/etc/init.d/nginx" ] && echo /etc/init.d/nginx
  173. [ -e "/lib/systemd/system/nginx.service" ] && echo /lib/systemd/system/nginx.service
  174. [ -e "/etc/logrotate.d/nginx" ] && echo /etc/logrotate.d/nginx
  175. [ -d "${apache_install_dir}" ] && echo ${apache_install_dir}
  176. [ -e "/lib/systemd/system/httpd.service" ] && echo /lib/systemd/system/httpd.service
  177. [ -e "/etc/init.d/httpd" ] && echo /etc/init.d/httpd
  178. [ -e "/etc/logrotate.d/apache" ] && echo /etc/logrotate.d/apache
  179. [ -d "${tomcat_install_dir}" ] && echo ${tomcat_install_dir}
  180. [ -e "/etc/init.d/tomcat" ] && echo /etc/init.d/tomcat
  181. [ -e "/etc/logrotate.d/tomcat" ] && echo /etc/logrotate.d/tomcat
  182. [ -d "/usr/java" ] && echo /usr/java
  183. [ -d "/usr/local/apr" ] && echo /usr/local/apr
  184. }
  185. Uninstall_Web() {
  186. [ -d "${nginx_install_dir}" ] && { killall nginx > /dev/null 2>&1; rm -rf ${nginx_install_dir} /etc/init.d/nginx /etc/logrotate.d/nginx; sed -i "s@${nginx_install_dir}/sbin:@@" /etc/profile; echo "${CMSG}Nginx uninstall completed! ${CEND}"; }
  187. [ -d "${tengine_install_dir}" ] && { killall nginx > /dev/null 2>&1; rm -rf ${tengine_install_dir} /etc/init.d/nginx /etc/logrotate.d/nginx; sed -i "s@${tengine_install_dir}/sbin:@@" /etc/profile; echo "${CMSG}Tengine uninstall completed! ${CEND}"; }
  188. [ -d "${openresty_install_dir}" ] && { killall nginx > /dev/null 2>&1; rm -rf ${openresty_install_dir} /etc/init.d/nginx /etc/logrotate.d/nginx; sed -i "s@${openresty_install_dir}/nginx/sbin:@@" /etc/profile; echo "${CMSG}OpenResty uninstall completed! ${CEND}"; }
  189. [ -e "/lib/systemd/system/nginx.service" ] && { systemctl disable nginx > /dev/null 2>&1; rm -f /lib/systemd/system/nginx.service; }
  190. [ -d "${apache_install_dir}" ] && { service httpd stop > /dev/null 2>&1; rm -rf ${apache_install_dir} /etc/init.d/httpd /etc/logrotate.d/apache; sed -i "s@${apache_install_dir}/bin:@@" /etc/profile; echo "${CMSG}Apache uninstall completed! ${CEND}"; }
  191. [ -e "/lib/systemd/system/httpd.service" ] && { systemctl disable httpd > /dev/null 2>&1; rm -f /lib/systemd/system/httpd.service; }
  192. [ -d "${tomcat_install_dir}" ] && { killall java > /dev/null 2>&1; chmod +x /etc/logrotate.d/tomcat; rm -rf ${tomcat_install_dir} /etc/init.d/tomcat /etc/logrotate.d/tomcat /usr/local/apr; echo "${CMSG}Tomcat uninstall completed! ${CEND}"; }
  193. [ -d "/usr/java" ] && { rm -rf /usr/java; sed -i '/export JAVA_HOME=/d' /etc/profile; sed -i '/export CLASSPATH=/d' /etc/profile; sed -i 's@\$JAVA_HOME/bin:@@' /etc/profile; }
  194. [ -e "${wwwroot_dir}" ] && /bin/mv ${wwwroot_dir}{,$(date +%Y%m%d%H)}
  195. sed -i 's@^website_name=.*@website_name=@' ./options.conf
  196. sed -i 's@^backup_content=.*@backup_content=@' ./options.conf
  197. }
  198. Print_MySQL() {
  199. [ -e "${db_install_dir}" ] && echo ${db_install_dir}
  200. [ -e "/etc/init.d/mysqld" ] && echo /etc/init.d/mysqld
  201. [ -e "/etc/my.cnf" ] && echo /etc/my.cnf
  202. }
  203. Print_PostgreSQL() {
  204. [ -e "${pgsql_install_dir}" ] && echo ${pgsql_install_dir}
  205. [ -e "/etc/init.d/postgresql" ] && echo /etc/init.d/postgresql
  206. [ -e "/lib/systemd/system/postgresql.service" ] && echo /lib/systemd/system/postgresql.service
  207. }
  208. Print_MongoDB() {
  209. [ -e "${mongo_install_dir}" ] && echo ${mongo_install_dir}
  210. [ -e "/etc/init.d/mongod" ] && echo /etc/init.d/mongod
  211. [ -e "/lib/systemd/system/mongod.service" ] && echo /lib/systemd/system/mongod.service
  212. [ -e "/etc/mongod.conf" ] && echo /etc/mongod.conf
  213. }
  214. Uninstall_MySQL() {
  215. # uninstall mysql,mariadb,percona,alisql
  216. if [ -d "${db_install_dir}/support-files" ]; then
  217. service mysqld stop > /dev/null 2>&1
  218. rm -rf ${db_install_dir} /etc/init.d/mysqld /etc/my.cnf* /etc/ld.so.conf.d/*{mysql,mariadb,percona,alisql}*.conf
  219. id -u mysql >/dev/null 2>&1 ; [ $? -eq 0 ] && userdel mysql
  220. [ -e "${db_data_dir}" ] && /bin/mv ${db_data_dir}{,$(date +%Y%m%d%H)}
  221. sed -i 's@^dbrootpwd=.*@dbrootpwd=@' ./options.conf
  222. sed -i "s@${db_install_dir}/bin:@@" /etc/profile
  223. echo "${CMSG}MySQL uninstall completed! ${CEND}"
  224. fi
  225. }
  226. Uninstall_PostgreSQL() {
  227. # uninstall postgresql
  228. if [ -e "${pgsql_install_dir}/bin/psql" ]; then
  229. service postgresql stop > /dev/null 2>&1
  230. rm -rf ${pgsql_install_dir} /etc/init.d/postgresql
  231. [ -e "/lib/systemd/system/postgresql.service" ] && { systemctl disable postgresql > /dev/null 2>&1; rm -f /lib/systemd/system/postgresql.service; }
  232. [ -e "${php_install_dir}/etc/php.d/07-pgsql.ini" ] && rm -f ${php_install_dir}/etc/php.d/07-pgsql.ini
  233. id -u postgres >/dev/null 2>&1 ; [ $? -eq 0 ] && userdel postgres
  234. [ -e "${pgsql_data_dir}" ] && /bin/mv ${pgsql_data_dir}{,$(date +%Y%m%d%H)}
  235. sed -i 's@^dbpostgrespwd=.*@dbpostgrespwd=@' ./options.conf
  236. sed -i "s@${pgsql_install_dir}/bin:@@" /etc/profile
  237. echo "${CMSG}PostgreSQL uninstall completed! ${CEND}"
  238. fi
  239. }
  240. Uninstall_MongoDB() {
  241. # uninstall mongodb
  242. if [ -e "${mongo_install_dir}/bin/mongo" ]; then
  243. service mongod stop > /dev/null 2>&1
  244. rm -rf ${mongo_install_dir} /etc/mongod.conf /etc/init.d/mongod /tmp/mongo*.sock
  245. [ -e "/lib/systemd/system/mongod.service" ] && { systemctl disable mongod > /dev/null 2>&1; rm -f /lib/systemd/system/mongod.service; }
  246. [ -e "${php_install_dir}/etc/php.d/07-mongo.ini" ] && rm -f ${php_install_dir}/etc/php.d/07-mongo.ini
  247. [ -e "${php_install_dir}/etc/php.d/07-mongodb.ini" ] && rm -f ${php_install_dir}/etc/php.d/07-mongodb.ini
  248. id -u mongod > /dev/null 2>&1 ; [ $? -eq 0 ] && userdel mongod
  249. [ -e "${mongo_data_dir}" ] && /bin/mv ${mongo_data_dir}{,$(date +%Y%m%d%H)}
  250. sed -i 's@^dbmongopwd=.*@dbmongopwd=@' ./options.conf
  251. sed -i "s@${mongo_install_dir}/bin:@@" /etc/profile
  252. echo "${CMSG}MongoDB uninstall completed! ${CEND}"
  253. fi
  254. }
  255. Print_PHP() {
  256. [ -e "${php_install_dir}" ] && echo ${php_install_dir}
  257. [ -e "/etc/init.d/php-fpm" ] && echo /etc/init.d/php-fpm
  258. [ -e "/lib/systemd/system/php-fpm.service" ] && echo /lib/systemd/system/php-fpm.service
  259. }
  260. Print_MPHP() {
  261. [ -e "${php_install_dir}${mphp_ver}" ] && echo ${php_install_dir}${mphp_ver}
  262. [ -e "/etc/init.d/php${mphp_ver}-fpm" ] && echo /etc/init.d/php${mphp_ver}-fpm
  263. [ -e "/lib/systemd/system/php${mphp_ver}-fpm.service" ] && echo /lib/systemd/system/php${mphp_ver}-fpm.service
  264. }
  265. Print_ALLPHP() {
  266. [ -e "${php_install_dir}" ] && echo ${php_install_dir}
  267. [ -e "/etc/init.d/php-fpm" ] && echo /etc/init.d/php-fpm
  268. [ -e "/lib/systemd/system/php-fpm.service" ] && echo /lib/systemd/system/php-fpm.service
  269. for php_ver in 53 54 55 56 70 71 72 73; do
  270. [ -e "${php_install_dir}${php_ver}" ] && echo ${php_install_dir}${php_ver}
  271. [ -e "/etc/init.d/php${php_ver}-fpm" ] && echo /etc/init.d/php${php_ver}-fpm
  272. [ -e "/lib/systemd/system/php${php_ver}-fpm.service" ] && echo /lib/systemd/system/php${php_ver}-fpm.service
  273. done
  274. [ -e "${imagick_install_dir}" ] && echo ${imagick_install_dir}
  275. [ -e "${gmagick_install_dir}" ] && echo ${gmagick_install_dir}
  276. [ -e "${curl_install_dir}" ] && echo ${curl_install_dir}
  277. }
  278. Uninstall_PHP() {
  279. [ -e "/etc/init.d/php-fpm" ] && { service php-fpm stop > /dev/null 2>&1; rm -f /etc/init.d/php-fpm; }
  280. [ -e "/lib/systemd/system/php-fpm.service" ] && { systemctl stop php-fpm > /dev/null 2>&1; systemctl disable php-fpm > /dev/null 2>&1; rm -f /lib/systemd/system/php-fpm.service; }
  281. [ -e "${apache_install_dir}/conf/httpd.conf" ] && [ -n "`grep libphp ${apache_install_dir}/conf/httpd.conf`" ] && sed -i '/libphp/d' ${apache_install_dir}/conf/httpd.conf
  282. [ -e "${php_install_dir}" ] && { rm -rf ${php_install_dir}; echo "${CMSG}PHP uninstall completed! ${CEND}"; }
  283. sed -i "s@${php_install_dir}/bin:@@" /etc/profile
  284. }
  285. Uninstall_MPHP() {
  286. [ -e "/etc/init.d/php${mphp_ver}-fpm" ] && { service php${mphp_ver}-fpm stop > /dev/null 2>&1; rm -f /etc/init.d/php${mphp_ver}-fpm; }
  287. [ -e "/lib/systemd/system/php${mphp_ver}-fpm.service" ] && { systemctl stop php${mphp_ver}-fpm > /dev/null 2>&1; systemctl disable php${mphp_ver}-fpm > /dev/null 2>&1; rm -f /lib/systemd/system/php${mphp_ver}-fpm.service; }
  288. [ -e "${php_install_dir}${mphp_ver}" ] && { rm -rf ${php_install_dir}${mphp_ver}; echo "${CMSG}PHP${mphp_ver} uninstall completed! ${CEND}"; }
  289. }
  290. Uninstall_ALLPHP() {
  291. [ -e "/etc/init.d/php-fpm" ] && { service php-fpm stop > /dev/null 2>&1; rm -f /etc/init.d/php-fpm; }
  292. [ -e "/lib/systemd/system/php-fpm.service" ] && { systemctl stop php-fpm > /dev/null 2>&1; systemctl disable php-fpm > /dev/null 2>&1; rm -f /lib/systemd/system/php-fpm.service; }
  293. [ -e "${apache_install_dir}/conf/httpd.conf" ] && [ -n "`grep libphp ${apache_install_dir}/conf/httpd.conf`" ] && sed -i '/libphp/d' ${apache_install_dir}/conf/httpd.conf
  294. [ -e "${php_install_dir}" ] && { rm -rf ${php_install_dir}; echo "${CMSG}PHP uninstall completed! ${CEND}"; }
  295. sed -i "s@${php_install_dir}/bin:@@" /etc/profile
  296. for php_ver in 53 54 55 56 70 71 72 73; do
  297. [ -e "/etc/init.d/php${php_ver}-fpm" ] && { service php${php_ver}-fpm stop > /dev/null 2>&1; rm -f /etc/init.d/php${php_ver}-fpm; }
  298. [ -e "/lib/systemd/system/php${php_ver}-fpm.service" ] && { systemctl stop php${php_ver}-fpm > /dev/null 2>&1; systemctl disable php${php_ver}-fpm > /dev/null 2>&1; rm -f /lib/systemd/system/php${php_ver}-fpm.service; }
  299. [ -e "${php_install_dir}${php_ver}" ] && { rm -rf ${php_install_dir}${php_ver}; echo "${CMSG}PHP${php_ver} uninstall completed! ${CEND}"; }
  300. done
  301. [ -e "${imagick_install_dir}" ] && rm -rf ${imagick_install_dir}
  302. [ -e "${gmagick_install_dir}" ] && rm -rf ${gmagick_install_dir}
  303. [ -e "${curl_install_dir}" ] && rm -rf ${curl_install_dir}
  304. }
  305. Uninstall_PHPcache() {
  306. . include/zendopcache.sh
  307. . include/xcache.sh
  308. . include/apcu.sh
  309. . include/eaccelerator.sh
  310. Uninstall_ZendOPcache
  311. Uninstall_XCache
  312. Uninstall_APCU
  313. Uninstall_eAccelerator
  314. # reload php
  315. [ -e "${php_install_dir}/sbin/php-fpm" ] && service php-fpm reload
  316. [ -e "${php_install_dir}${mphp_ver}/sbin/php-fpm" ] && service php${mphp_ver}-fpm reload
  317. [ -e "${apache_install_dir}/bin/apachectl" ] && ${apache_install_dir}/bin/apachectl -k graceful
  318. }
  319. Uninstall_PHPext() {
  320. # ZendGuardLoader
  321. if [ "${pecl_zendguardloader}" == '1' ]; then
  322. . include/ZendGuardLoader.sh
  323. Uninstall_ZendGuardLoader
  324. fi
  325. # ioncube
  326. if [ "${pecl_ioncube}" == '1' ]; then
  327. . include/ioncube.sh
  328. Uninstall_ionCube
  329. fi
  330. # SourceGuardian
  331. if [ "${pecl_sourceguardian}" == '1' ]; then
  332. . include/sourceguardian.sh
  333. Uninstall_SourceGuardian
  334. fi
  335. # imagick
  336. if [ "${pecl_imagick}" == '1' ]; then
  337. . include/ImageMagick.sh
  338. Uninstall_ImageMagick
  339. Uninstall_pecl_imagick
  340. fi
  341. # gmagick
  342. if [ "${pecl_gmagick}" == '1' ]; then
  343. . include/GraphicsMagick.sh
  344. Uninstall_GraphicsMagick
  345. Uninstall_pecl_gmagick
  346. fi
  347. # fileinfo
  348. if [ "${pecl_fileinfo}" == '1' ]; then
  349. . include/pecl_fileinfo.sh
  350. Uninstall_pecl_fileinfo
  351. fi
  352. # imap
  353. if [ "${pecl_imap}" == '1' ]; then
  354. . include/pecl_imap.sh
  355. Uninstall_pecl_imap
  356. fi
  357. # ldap
  358. if [ "${pecl_ldap}" == '1' ]; then
  359. . include/pecl_ldap.sh
  360. Uninstall_pecl_ldap
  361. fi
  362. # phalcon
  363. if [ "${pecl_phalcon}" == '1' ]; then
  364. . include/pecl_phalcon.sh
  365. Uninstall_pecl_phalcon
  366. fi
  367. # yaf
  368. if [ "${pecl_yaf}" == '1' ]; then
  369. . include/pecl_yaf.sh
  370. Uninstall_pecl_yaf 2>&1 | tee -a ${oneinstack_dir}/install.log
  371. fi
  372. # pecl_memcached
  373. if [ "${pecl_memcached}" == '1' ]; then
  374. . include/memcached.sh
  375. Uninstall_pecl_memcached
  376. fi
  377. # pecl_memcache
  378. if [ "${pecl_memcache}" == '1' ]; then
  379. . include/memcached.sh
  380. Uninstall_pecl_memcache
  381. fi
  382. # pecl_redis
  383. if [ "${pecl_redis}" == '1' ]; then
  384. . include/redis.sh
  385. Uninstall_pecl_redis
  386. fi
  387. # pecl_mongodb
  388. if [ "${pecl_mongodb}" == '1' ]; then
  389. . include/pecl_mongodb.sh
  390. Uninstall_pecl_mongodb
  391. fi
  392. # swoole
  393. if [ "${pecl_swoole}" == '1' ]; then
  394. . include/pecl_swoole.sh
  395. Uninstall_pecl_swoole
  396. fi
  397. # xdebug
  398. if [ "${pecl_xdebug}" == '1' ]; then
  399. . include/pecl_xdebug.sh
  400. Uninstall_pecl_xdebug
  401. fi
  402. # reload php
  403. [ -e "${php_install_dir}/sbin/php-fpm" ] && service php-fpm reload
  404. [ -e "${php_install_dir}${mphp_ver}/sbin/php-fpm" ] && service php${mphp_ver}-fpm reload
  405. [ -e "${apache_install_dir}/bin/apachectl" ] && ${apache_install_dir}/bin/apachectl -k graceful
  406. }
  407. Menu_PHPext() {
  408. while :; do
  409. echo 'Please select uninstall PHP extensions:'
  410. echo -e "\t${CMSG} 0${CEND}. Do not uninstall"
  411. echo -e "\t${CMSG} 1${CEND}. Uninstall zendguardloader(PHP<=5.6)"
  412. echo -e "\t${CMSG} 2${CEND}. Uninstall ioncube"
  413. echo -e "\t${CMSG} 3${CEND}. Uninstall sourceguardian(PHP<=7.2)"
  414. echo -e "\t${CMSG} 4${CEND}. Uninstall imagick"
  415. echo -e "\t${CMSG} 5${CEND}. Uninstall gmagick"
  416. echo -e "\t${CMSG} 6${CEND}. Uninstall fileinfo"
  417. echo -e "\t${CMSG} 7${CEND}. Uninstall imap"
  418. echo -e "\t${CMSG} 8${CEND}. Uninstall ldap"
  419. echo -e "\t${CMSG} 9${CEND}. Uninstall phalcon(PHP>=5.5)"
  420. echo -e "\t${CMSG}10${CEND}. Uninstall redis"
  421. echo -e "\t${CMSG}11${CEND}. Uninstall memcached"
  422. echo -e "\t${CMSG}12${CEND}. Uninstall memcache"
  423. echo -e "\t${CMSG}13${CEND}. Uninstall mongodb"
  424. echo -e "\t${CMSG}14${CEND}. Uninstall swoole"
  425. echo -e "\t${CMSG}15${CEND}. Uninstall xdebug(PHP>=5.5)"
  426. read -e -p "Please input a number:(Default 0 press Enter) " phpext_option
  427. phpext_option=${phpext_option:-0}
  428. [ "${phpext_option}" == '0' ] && break
  429. array_phpext=(${phpext_option})
  430. array_all=(1 2 3 4 5 6 7 8 9 10 11 12 13 14 15)
  431. for v in ${array_phpext[@]}
  432. do
  433. [ -z "`echo ${array_all[@]} | grep -w ${v}`" ] && phpext_flag=1
  434. done
  435. if [ "${phpext_flag}" == '1' ]; then
  436. unset phpext_flag
  437. echo; echo "${CWARNING}input error! Please only input number 1 2 3 14 and so on${CEND}"; echo
  438. continue
  439. else
  440. [ -n "`echo ${array_phpext[@]} | grep -w 1`" ] && pecl_zendguardloader=1
  441. [ -n "`echo ${array_phpext[@]} | grep -w 2`" ] && pecl_ioncube=1
  442. [ -n "`echo ${array_phpext[@]} | grep -w 3`" ] && pecl_sourceguardian=1
  443. [ -n "`echo ${array_phpext[@]} | grep -w 4`" ] && pecl_imagick=1
  444. [ -n "`echo ${array_phpext[@]} | grep -w 5`" ] && pecl_gmagick=1
  445. [ -n "`echo ${array_phpext[@]} | grep -w 6`" ] && pecl_fileinfo=1
  446. [ -n "`echo ${array_phpext[@]} | grep -w 7`" ] && pecl_imap=1
  447. [ -n "`echo ${array_phpext[@]} | grep -w 8`" ] && pecl_ldap=1
  448. [ -n "`echo ${array_phpext[@]} | grep -w 9`" ] && pecl_phalcon=1
  449. [ -n "`echo ${array_phpext[@]} | grep -w 10`" ] && pecl_redis=1
  450. [ -n "`echo ${array_phpext[@]} | grep -w 11`" ] && pecl_memcached=1
  451. [ -n "`echo ${array_phpext[@]} | grep -w 12`" ] && pecl_memcache=1
  452. [ -n "`echo ${array_phpext[@]} | grep -w 13`" ] && pecl_mongodb=1
  453. [ -n "`echo ${array_phpext[@]} | grep -w 14`" ] && pecl_swoole=1
  454. [ -n "`echo ${array_phpext[@]} | grep -w 15`" ] && pecl_xdebug=1
  455. break
  456. fi
  457. done
  458. }
  459. Print_HHVM() {
  460. [ -e "/usr/bin/hhvm" ] && echo /usr/bin/hhvm
  461. [ -e "/etc/hhvm" ] && echo /etc/hhvm
  462. [ -e "/var/log/hhvm" ] && echo /var/log/hhvm
  463. [ -e "/lib/systemd/system/hhvm.service" ] && echo /lib/systemd/system/hhvm.service
  464. [ -e "/etc/supervisord.conf" ] && echo /etc/supervisord.conf
  465. [ -e "/etc/init.d/supervisord" ] && echo /etc/init.d/supervisord
  466. }
  467. Uninstall_HHVM() {
  468. [ -e "/lib/systemd/system/hhvm.service" ] && { systemctl disable hhvm > /dev/null 2>&1; rm -f /lib/systemd/system/hhvm.service; }
  469. [ -e "/etc/init.d/supervisord" ] && { service supervisord stop > /dev/null 2>&1; rm -f /etc/supervisord.conf /etc/init.d/supervisord; }
  470. [ -e "/usr/bin/hhvm" ] && { rpm -e hhvm; rm -rf /etc/hhvm /var/log/hhvm /usr/bin/hhvm; echo "${CMSG}HHVM uninstall completed! ${CEND}"; }
  471. }
  472. Print_PureFtpd() {
  473. [ -e "${pureftpd_install_dir}" ] && echo ${pureftpd_install_dir}
  474. [ -e "/etc/init.d/pureftpd" ] && echo /etc/init.d/pureftpd
  475. [ -e "/lib/systemd/system/pureftpd.service" ] && echo /lib/systemd/system/pureftpd.service
  476. }
  477. Uninstall_PureFtpd() {
  478. [ -e "${pureftpd_install_dir}" ] && { service pureftpd stop > /dev/null 2>&1; rm -rf ${pureftpd_install_dir} /etc/init.d/pureftpd; echo "${CMSG}Pureftpd uninstall completed! ${CEND}"; }
  479. [ -e "/lib/systemd/system/pureftpd.service" ] && { systemctl disable pureftpd > /dev/null 2>&1; rm -f /lib/systemd/system/pureftpd.service; }
  480. }
  481. Print_Redis_server() {
  482. [ -e "${redis_install_dir}" ] && echo ${redis_install_dir}
  483. [ -e "/etc/init.d/redis-server" ] && echo /etc/init.d/redis-server
  484. [ -e "/lib/systemd/system/redis-server.service" ] && echo /lib/systemd/system/redis-server.service
  485. }
  486. Uninstall_Redis_server() {
  487. [ -e "${redis_install_dir}" ] && { service redis-server stop > /dev/null 2>&1; rm -rf ${redis_install_dir} /etc/init.d/redis-server /usr/local/bin/redis-*; echo "${CMSG}Redis uninstall completed! ${CEND}"; }
  488. [ -e "/lib/systemd/system/redis-server.service" ] && { systemctl disable redis-server > /dev/null 2>&1; rm -f /lib/systemd/system/redis-server.service; }
  489. }
  490. Print_Memcached_server() {
  491. [ -e "${memcached_install_dir}" ] && echo ${memcached_install_dir}
  492. [ -e "/etc/init.d/memcached" ] && echo /etc/init.d/memcached
  493. [ -e "/usr/bin/memcached" ] && echo /usr/bin/memcached
  494. }
  495. Uninstall_Memcached_server() {
  496. [ -e "${memcached_install_dir}" ] && { service memcached stop > /dev/null 2>&1; rm -rf ${memcached_install_dir} /etc/init.d/memcached /usr/bin/memcached; echo "${CMSG}Memcached uninstall completed! ${CEND}"; }
  497. }
  498. Print_phpMyAdmin() {
  499. [ -d "${wwwroot_dir}/default/phpMyAdmin" ] && echo ${wwwroot_dir}/default/phpMyAdmin
  500. }
  501. Uninstall_phpMyAdmin() {
  502. [ -d "${wwwroot_dir}/default/phpMyAdmin" ] && rm -rf ${wwwroot_dir}/default/phpMyAdmin
  503. }
  504. Print_openssl() {
  505. [ -d "${openssl_install_dir}" ] && echo ${openssl_install_dir}
  506. }
  507. Uninstall_openssl() {
  508. [ -d "${openssl_install_dir}" ] && rm -rf ${openssl_install_dir}
  509. }
  510. Print_Python() {
  511. [ -d "${python_install_dir}" ] && echo ${python_install_dir}
  512. }
  513. Menu() {
  514. while :; do
  515. printf "
  516. What Are You Doing?
  517. \t${CMSG} 0${CEND}. Uninstall All
  518. \t${CMSG} 1${CEND}. Uninstall Nginx/Tengine/OpenResty/Apache/Tomcat
  519. \t${CMSG} 2${CEND}. Uninstall MySQL/MariaDB/Percona/AliSQL
  520. \t${CMSG} 3${CEND}. Uninstall PostgreSQL
  521. \t${CMSG} 4${CEND}. Uninstall MongoDB
  522. \t${CMSG} 5${CEND}. Uninstall all PHP
  523. \t${CMSG} 6${CEND}. Uninstall PHP opcode cache
  524. \t${CMSG} 7${CEND}. Uninstall PHP extensions
  525. \t${CMSG} 8${CEND}. Uninstall HHVM
  526. \t${CMSG} 9${CEND}. Uninstall PureFtpd
  527. \t${CMSG}10${CEND}. Uninstall Redis
  528. \t${CMSG}11${CEND}. Uninstall Memcached
  529. \t${CMSG}12${CEND}. Uninstall phpMyAdmin
  530. \t${CMSG}13${CEND}. Uninstall Python (PATH: ${python_install_dir})
  531. \t${CMSG} q${CEND}. Exit
  532. "
  533. echo
  534. read -e -p "Please input the correct option: " Number
  535. if [[ ! "${Number}" =~ ^[0-9,q]$|^1[0-3]$ ]]; then
  536. echo "${CWARNING}input error! Please only input 0~13 and q${CEND}"
  537. else
  538. case "$Number" in
  539. 0)
  540. Print_Warn
  541. Print_web
  542. Print_MySQL
  543. Print_PostgreSQL
  544. Print_MongoDB
  545. Print_ALLPHP
  546. Print_HHVM
  547. Print_PureFtpd
  548. Print_Redis_server
  549. Print_Memcached_server
  550. Print_openssl
  551. Print_phpMyAdmin
  552. Print_Python
  553. Uninstall_status
  554. if [ "${uninstall_flag}" == 'y' ]; then
  555. Uninstall_Web
  556. Uninstall_MySQL
  557. Uninstall_PostgreSQL
  558. Uninstall_MongoDB
  559. Uninstall_ALLPHP
  560. Uninstall_HHVM
  561. Uninstall_PureFtpd
  562. Uninstall_Redis_server
  563. Uninstall_Memcached_server
  564. Uninstall_openssl
  565. Uninstall_phpMyAdmin
  566. . include/python.sh; Uninstall_Python
  567. else
  568. exit
  569. fi
  570. ;;
  571. 1)
  572. Print_Warn
  573. Print_web
  574. Uninstall_status
  575. [ "${uninstall_flag}" == 'y' ] && Uninstall_Web || exit
  576. ;;
  577. 2)
  578. Print_Warn
  579. Print_MySQL
  580. Uninstall_status
  581. [ "${uninstall_flag}" == 'y' ] && Uninstall_MySQL || exit
  582. ;;
  583. 3)
  584. Print_Warn
  585. Print_PostgreSQL
  586. Uninstall_status
  587. [ "${uninstall_flag}" == 'y' ] && Uninstall_PostgreSQL || exit
  588. ;;
  589. 4)
  590. Print_Warn
  591. Print_MongoDB
  592. Uninstall_status
  593. [ "${uninstall_flag}" == 'y' ] && Uninstall_MongoDB || exit
  594. ;;
  595. 5)
  596. Print_ALLPHP
  597. Uninstall_status
  598. [ "${uninstall_flag}" == 'y' ] && Uninstall_ALLPHP || exit
  599. ;;
  600. 6)
  601. Uninstall_status
  602. [ "${uninstall_flag}" == 'y' ] && Uninstall_PHPcache || exit
  603. ;;
  604. 7)
  605. Menu_PHPext
  606. [ "${phpext_option}" != '0' ] && Uninstall_status
  607. [ "${uninstall_flag}" == 'y' ] && Uninstall_PHPext || exit
  608. ;;
  609. 8)
  610. Print_HHVM
  611. Uninstall_status
  612. [ "${uninstall_flag}" == 'y' ] && Uninstall_HHVM || exit
  613. ;;
  614. 9)
  615. Print_PureFtpd
  616. Uninstall_status
  617. [ "${uninstall_flag}" == 'y' ] && Uninstall_PureFtpd || exit
  618. ;;
  619. 10)
  620. Print_Redis_server
  621. Uninstall_status
  622. [ "${uninstall_flag}" == 'y' ] && Uninstall_Redis_server || exit
  623. ;;
  624. 11)
  625. Print_Memcached_server
  626. Uninstall_status
  627. [ "${uninstall_flag}" == 'y' ] && Uninstall_Memcached_server || exit
  628. ;;
  629. 12)
  630. Print_phpMyAdmin
  631. Uninstall_status
  632. [ "${uninstall_flag}" == 'y' ] && Uninstall_phpMyAdmin || exit
  633. ;;
  634. 13)
  635. Print_Python
  636. Uninstall_status
  637. [ "${uninstall_flag}" == 'y' ] && { . include/python.sh; Uninstall_Python; } || exit
  638. ;;
  639. q)
  640. exit
  641. ;;
  642. esac
  643. fi
  644. done
  645. }
  646. if [ ${ARG_NUM} == 0 ]; then
  647. Menu
  648. else
  649. [ "${web_flag}" == 'y' ] && Print_web
  650. [ "${mysql_flag}" == 'y' ] && Print_MySQL
  651. [ "${postgresql_flag}" == 'y' ] && Print_PostgreSQL
  652. [ "${mongodb_flag}" == 'y' ] && Print_MongoDB
  653. if [ "${allphp_flag}" == 'y' ]; then
  654. Print_ALLPHP
  655. else
  656. [ "${php_flag}" == 'y' ] && Print_PHP
  657. [ "${mphp_flag}" == 'y' ] && [ "${phpcache_flag}" != 'y' ] && [ -z "${php_extensions}" ] && Print_MPHP
  658. fi
  659. [ "${hhvm_flag}" == 'y' ] && Print_HHVM
  660. [ "${pureftpd_flag}" == 'y' ] && Print_PureFtpd
  661. [ "${redis_flag}" == 'y' ] && Print_Redis_server
  662. [ "${memcached_flag}" == 'y' ] && Print_Memcached_server
  663. [ "${phpmyadmin_flag}" == 'y' ] && Print_phpMyAdmin
  664. [ "${python_flag}" == 'y' ] && Print_Python
  665. [ "${all_flag}" == 'y' ] && Print_openssl
  666. Uninstall_status
  667. if [ "${uninstall_flag}" == 'y' ]; then
  668. [ "${web_flag}" == 'y' ] && Uninstall_Web
  669. [ "${mysql_flag}" == 'y' ] && Uninstall_MySQL
  670. [ "${postgresql_flag}" == 'y' ] && Uninstall_PostgreSQL
  671. [ "${mongodb_flag}" == 'y' ] && Uninstall_MongoDB
  672. if [ "${allphp_flag}" == 'y' ]; then
  673. Uninstall_ALLPHP
  674. else
  675. [ "${php_flag}" == 'y' ] && Uninstall_PHP
  676. [ "${php_flag}" == 'y' ] && [ "${phpcache_flag}" == 'y' ] && Uninstall_PHPcache
  677. [ -n "${php_extensions}" ] && Uninstall_PHPext
  678. [ "${mphp_flag}" == 'y' ] && [ "${phpcache_flag}" != 'y' ] && [ -z "${php_extensions}" ] && Uninstall_MPHP
  679. [ "${mphp_flag}" == 'y' ] && [ "${phpcache_flag}" == 'y' ] && { php_install_dir=${php_install_dir}${mphp_ver}; Uninstall_PHPcache; }
  680. [ "${mphp_flag}" == 'y' ] && [ -n "${php_extensions}" ] && { php_install_dir=${php_install_dir}${mphp_ver}; Uninstall_PHPext; }
  681. fi
  682. [ "${hhvm_flag}" == 'y' ] && Uninstall_HHVM
  683. [ "${pureftpd_flag}" == 'y' ] && Uninstall_PureFtpd
  684. [ "${redis_flag}" == 'y' ] && Uninstall_Redis_server
  685. [ "${memcached_flag}" == 'y' ] && Uninstall_Memcached_server
  686. [ "${phpmyadmin_flag}" == 'y' ] && Uninstall_phpMyAdmin
  687. [ "${python_flag}" == 'y' ] && { . include/python.sh; Uninstall_Python; }
  688. [ "${all_flag}" == 'y' ] && Uninstall_openssl
  689. fi
  690. fi