uninstall.sh 29 KB

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