uninstall.sh 29 KB

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