uninstall.sh 24 KB

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