uninstall.sh 29 KB

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