uninstall.sh 29 KB

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