uninstall.sh 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  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. showhelp() {
  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}" && showhelp && exit 1
  52. eval set -- "${TEMP}"
  53. while :; do
  54. [ -z "$1" ] && break;
  55. case "$1" in
  56. -h|--help)
  57. showhelp; exit 0
  58. ;;
  59. -q|--quiet)
  60. quiet_yn=y
  61. uninstall_yn=y
  62. shift 1
  63. ;;
  64. --all)
  65. all_yn=y
  66. web_yn=y
  67. mysql_yn=y
  68. postgresql_yn=y
  69. mongodb_yn=y
  70. php_yn=y
  71. hhvm_yn=y
  72. pureftpd_yn=y
  73. redis_yn=y
  74. memcached_yn=y
  75. phpmyadmin_yn=y
  76. shift 1
  77. ;;
  78. --web)
  79. web_yn=y; shift 1
  80. ;;
  81. --mysql)
  82. mysql_yn=y; shift 1
  83. ;;
  84. --postgresql)
  85. postgresql_yn=y; shift 1
  86. ;;
  87. --mongodb)
  88. mongodb_yn=y; shift 1
  89. ;;
  90. --php)
  91. php_yn=y; shift 1
  92. ;;
  93. --phpcache)
  94. phpcache_yn=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_yn=y; shift 1
  115. ;;
  116. --pureftpd)
  117. pureftpd_yn=y; shift 1
  118. ;;
  119. --redis)
  120. redis_yn=y; shift 1
  121. ;;
  122. --memcached)
  123. memcached_yn=y; shift 1
  124. ;;
  125. --phpmyadmin)
  126. phpmyadmin_yn=y; shift 1
  127. ;;
  128. --)
  129. shift
  130. ;;
  131. *)
  132. echo "${CWARNING}ERROR: unknown argument! ${CEND}" && showhelp && exit 1
  133. ;;
  134. esac
  135. done
  136. Uninstall_status() {
  137. if [ "${quiet_yn}" != 'y' ]; then
  138. while :; do echo
  139. read -e -p "Do you want to uninstall? [y/n]: " uninstall_yn
  140. if [[ ! ${uninstall_yn} =~ ^[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@^local_bankup_yn=.*@local_bankup_yn=y@' ./options.conf
  181. sed -i 's@^remote_bankup_yn=.*@remote_bankup_yn=n@' ./options.conf
  182. }
  183. Print_MySQL() {
  184. [ -e "${db_install_dir}" ] && echo "${db_install_dir}"
  185. [ -e "/etc/init.d/mysqld" ] && echo "/etc/init.d/mysqld"
  186. [ -e "/etc/my.cnf" ] && echo "/etc/my.cnf"
  187. }
  188. Print_PostgreSQL() {
  189. [ -e "${pgsql_install_dir}" ] && echo "${pgsql_install_dir}"
  190. [ -e "/etc/init.d/postgresql" ] && echo "/etc/init.d/postgresql"
  191. [ -e "/lib/systemd/system/postgresql.service" ] && echo "/lib/systemd/system/postgresql.service"
  192. }
  193. Print_MongoDB() {
  194. [ -e "${mongo_install_dir}" ] && echo "${mongo_install_dir}"
  195. [ -e "/etc/init.d/mongod" ] && echo "/etc/init.d/mongod"
  196. [ -e "/lib/systemd/system/mongod.service" ] && echo "/lib/systemd/system/mongod.service"
  197. [ -e "/etc/mongod.conf" ] && echo "/etc/mongod.conf"
  198. }
  199. Uninstall_MySQL() {
  200. # uninstall mysql,mariadb,percona,alisql
  201. if [ -d "${db_install_dir}/support-files" ]; then
  202. service mysqld stop > /dev/null 2>&1
  203. rm -rf ${db_install_dir} /etc/init.d/mysqld /etc/my.cnf* /etc/ld.so.conf.d/*{mysql,mariadb,percona,alisql}*.conf
  204. id -u mysql >/dev/null 2>&1 ; [ $? -eq 0 ] && userdel mysql
  205. [ -e "${db_data_dir}" ] && /bin/mv ${db_data_dir}{,$(date +%Y%m%d%H)}
  206. sed -i 's@^dbrootpwd=.*@dbrootpwd=@' ./options.conf
  207. sed -i "s@${db_install_dir}/bin:@@" /etc/profile
  208. echo "${CMSG}MySQL uninstall completed! ${CEND}"
  209. fi
  210. }
  211. Uninstall_PostgreSQL() {
  212. # uninstall postgresql
  213. if [ -e "${pgsql_install_dir}/bin/psql" ]; then
  214. service postgresql stop > /dev/null 2>&1
  215. rm -rf ${pgsql_install_dir} /etc/init.d/postgresql
  216. [ -e "/lib/systemd/system/postgresql.service" ] && { systemctl disable postgresql > /dev/null 2>&1; rm -f /lib/systemd/system/postgresql.service; }
  217. [ -e "${php_install_dir}/etc/php.d/07-pgsql.ini" ] && rm -f ${php_install_dir}/etc/php.d/07-pgsql.ini
  218. id -u postgres >/dev/null 2>&1 ; [ $? -eq 0 ] && userdel postgres
  219. [ -e "${pgsql_data_dir}" ] && /bin/mv ${pgsql_data_dir}{,$(date +%Y%m%d%H)}
  220. sed -i 's@^dbpostgrespwd=.*@dbpostgrespwd=@' ./options.conf
  221. sed -i "s@${pgsql_install_dir}/bin:@@" /etc/profile
  222. echo "${CMSG}PostgreSQL uninstall completed! ${CEND}"
  223. fi
  224. }
  225. Uninstall_MongoDB() {
  226. # uninstall mongodb
  227. if [ -e "${mongo_install_dir}/bin/mongo" ]; then
  228. service mongod stop > /dev/null 2>&1
  229. rm -rf ${mongo_install_dir} /etc/mongod.conf /etc/init.d/mongod /tmp/mongo*.sock
  230. [ -e "/lib/systemd/system/mongod.service" ] && { systemctl disable mongod > /dev/null 2>&1; rm -f /lib/systemd/system/mongod.service; }
  231. [ -e "${php_install_dir}/etc/php.d/07-mongo.ini" ] && rm -f ${php_install_dir}/etc/php.d/07-mongo.ini
  232. [ -e "${php_install_dir}/etc/php.d/07-mongodb.ini" ] && rm -f ${php_install_dir}/etc/php.d/07-mongodb.ini
  233. id -u mongod > /dev/null 2>&1 ; [ $? -eq 0 ] && userdel mongod
  234. [ -e "${mongo_data_dir}" ] && /bin/mv ${mongo_data_dir}{,$(date +%Y%m%d%H)}
  235. sed -i 's@^dbmongopwd=.*@dbmongopwd=@' ./options.conf
  236. sed -i "s@${mongo_install_dir}/bin:@@" /etc/profile
  237. echo "${CMSG}MongoDB uninstall completed! ${CEND}"
  238. fi
  239. }
  240. Print_PHP() {
  241. [ -e "${php_install_dir}" ] && echo "${php_install_dir}"
  242. [ -e "/etc/init.d/php-fpm" ] && echo "/etc/init.d/php-fpm"
  243. [ -e "/lib/systemd/system/php-fpm.service" ] && echo '/lib/systemd/system/php-fpm.service'
  244. [ -e "${imagick_install_dir}" ] && echo "${imagick_install_dir}"
  245. [ -e "${gmagick_install_dir}" ] && echo "${gmagick_install_dir}"
  246. [ -e "${curl_install_dir}" ] && echo "${curl_install_dir}"
  247. }
  248. Uninstall_PHP() {
  249. [ -e "/etc/init.d/php-fpm" ] && { service php-fpm stop > /dev/null 2>&1; rm -f /etc/init.d/php-fpm; }
  250. [ -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; }
  251. [ -e "${php_install_dir}" ] && { rm -rf ${php_install_dir}; echo "${CMSG}PHP uninstall completed! ${CEND}"; }
  252. [ -e "${imagick_install_dir}" ] && rm -rf ${imagick_install_dir}
  253. [ -e "${gmagick_install_dir}" ] && rm -rf ${gmagick_install_dir}
  254. [ -e "${curl_install_dir}" ] && rm -rf "${curl_install_dir}"
  255. sed -i "s@${php_install_dir}/bin:@@" /etc/profile
  256. }
  257. Uninstall_PHPcache() {
  258. . include/zendopcache.sh
  259. . include/xcache.sh
  260. . include/apcu.sh
  261. . include/eaccelerator.sh
  262. Uninstall_ZendOPcache
  263. Uninstall_XCache
  264. Uninstall_APCU
  265. Uninstall_eAccelerator
  266. # reload php
  267. [ -e "${php_install_dir}/sbin/php-fpm" ] && service php-fpm reload
  268. [ -e "${apache_install_dir}/bin/apachectl" ] && ${apache_install_dir}/bin/apachectl -k graceful
  269. }
  270. Uninstall_PHPext() {
  271. # ZendGuardLoader
  272. if [ "${pecl_zendguardloader}" == '1' ]; then
  273. . include/ZendGuardLoader.sh
  274. Uninstall_ZendGuardLoader
  275. fi
  276. # ioncube
  277. if [ "${pecl_ioncube}" == '1' ]; then
  278. . include/ioncube.sh
  279. Uninstall_ionCube
  280. fi
  281. # SourceGuardian
  282. if [ "${pecl_sourceguardian}" == '1' ]; then
  283. . include/sourceguardian.sh
  284. Uninstall_SourceGuardian
  285. fi
  286. # imagick
  287. if [ "${pecl_imagick}" == '1' ]; then
  288. . include/ImageMagick.sh
  289. Uninstall_ImageMagick
  290. Uninstall_pecl-imagick
  291. fi
  292. # gmagick
  293. if [ "${pecl_gmagick}" == '1' ]; then
  294. . include/GraphicsMagick.sh
  295. Uninstall_GraphicsMagick
  296. Uninstall_pecl-gmagick
  297. fi
  298. # fileinfo
  299. if [ "${pecl_fileinfo}" == '1' ]; then
  300. . include/pecl_fileinfo.sh
  301. Uninstall_pecl-fileinfo
  302. fi
  303. # imap
  304. if [ "${pecl_imap}" == '1' ]; then
  305. . include/pecl_imap.sh
  306. Uninstall_pecl-imap
  307. fi
  308. # phalcon
  309. if [ "${pecl_phalcon}" == '1' ]; then
  310. . include/pecl_phalcon.sh
  311. Uninstall_pecl-phalcon
  312. fi
  313. # pecl_memcached
  314. if [ "${pecl_memcached}" == '1' ]; then
  315. . include/memcached.sh
  316. Uninstall_pecl-memcached
  317. fi
  318. # pecl_memcache
  319. if [ "${pecl_memcache}" == '1' ]; then
  320. . include/memcached.sh
  321. Uninstall_pecl-memcache
  322. fi
  323. # pecl_redis
  324. if [ "${pecl_redis}" == '1' ]; then
  325. . include/redis.sh
  326. Uninstall_pecl-redis
  327. fi
  328. # pecl_mongodb
  329. if [ "${pecl_mongodb}" == '1' ]; then
  330. . include/pecl_mongodb.sh
  331. Uninstall_pecl-mongodb
  332. fi
  333. # swoole
  334. if [ "${pecl_swoole}" == '1' ]; then
  335. . include/pecl_swoole.sh
  336. Uninstall_pecl-swoole
  337. fi
  338. # xdebug
  339. if [ "${pecl_xdebug}" == '1' ]; then
  340. . include/pecl_xdebug.sh
  341. Uninstall_pecl-xdebug
  342. fi
  343. # reload php
  344. [ -e "${php_install_dir}/sbin/php-fpm" ] && service php-fpm reload
  345. [ -e "${apache_install_dir}/bin/apachectl" ] && ${apache_install_dir}/bin/apachectl -k graceful
  346. }
  347. Menu_PHPext() {
  348. while :; do
  349. echo 'Please select uninstall PHP extensions:'
  350. echo -e "\t${CMSG} 0${CEND}. Do not uninstall"
  351. echo -e "\t${CMSG} 1${CEND}. Uninstall zendguardloader(PHP<=5.6)"
  352. echo -e "\t${CMSG} 2${CEND}. Uninstall ioncube"
  353. echo -e "\t${CMSG} 3${CEND}. Uninstall sourceguardian(PHP<=7.2)"
  354. echo -e "\t${CMSG} 4${CEND}. Uninstall imagick"
  355. echo -e "\t${CMSG} 5${CEND}. Uninstall gmagick"
  356. echo -e "\t${CMSG} 6${CEND}. Uninstall fileinfo"
  357. echo -e "\t${CMSG} 7${CEND}. Uninstall imap"
  358. echo -e "\t${CMSG} 8${CEND}. Uninstall phalcon(PHP>=5.5)"
  359. echo -e "\t${CMSG} 9${CEND}. Uninstall redis"
  360. echo -e "\t${CMSG}10${CEND}. Uninstall memcached"
  361. echo -e "\t${CMSG}11${CEND}. Uninstall memcache(PHP<=7.2)"
  362. echo -e "\t${CMSG}12${CEND}. Uninstall mongodb"
  363. echo -e "\t${CMSG}13${CEND}. Uninstall swoole"
  364. echo -e "\t${CMSG}14${CEND}. Uninstall xdebug(PHP>=5.5)"
  365. read -e -p "Please input a number:(Default 0 press Enter) " phpext_option
  366. phpext_option=${phpext_option:-0}
  367. [ "${phpext_option}" == '0' ] && break
  368. array_phpext=(${phpext_option})
  369. array_all=(1 2 3 4 5 6 7 8 9 10 11 12 13 14)
  370. for v in ${array_phpext[@]}
  371. do
  372. [ -z "`echo ${array_all[@]} | grep -w ${v}`" ] && phpext_flag=1
  373. done
  374. if [ "${phpext_flag}" == '1' ]; then
  375. unset phpext_flag
  376. echo; echo "${CWARNING}input error! Please only input number 1 2 3 14 and so on${CEND}"; echo
  377. continue
  378. else
  379. [ -n "`echo ${array_phpext[@]} | grep -w 1`" ] && pecl_zendguardloader=1
  380. [ -n "`echo ${array_phpext[@]} | grep -w 2`" ] && pecl_ioncube=1
  381. [ -n "`echo ${array_phpext[@]} | grep -w 3`" ] && pecl_sourceguardian=1
  382. [ -n "`echo ${array_phpext[@]} | grep -w 4`" ] && pecl_imagick=1
  383. [ -n "`echo ${array_phpext[@]} | grep -w 5`" ] && pecl_gmagick=1
  384. [ -n "`echo ${array_phpext[@]} | grep -w 6`" ] && pecl_fileinfo=1
  385. [ -n "`echo ${array_phpext[@]} | grep -w 7`" ] && pecl_imap=1
  386. [ -n "`echo ${array_phpext[@]} | grep -w 8`" ] && pecl_phalcon=1
  387. [ -n "`echo ${array_phpext[@]} | grep -w 9`" ] && pecl_redis=1
  388. [ -n "`echo ${array_phpext[@]} | grep -w 10`" ] && pecl_memcached=1
  389. [ -n "`echo ${array_phpext[@]} | grep -w 11`" ] && pecl_memcache=1
  390. [ -n "`echo ${array_phpext[@]} | grep -w 12`" ] && pecl_mongodb=1
  391. [ -n "`echo ${array_phpext[@]} | grep -w 13`" ] && pecl_swoole=1
  392. [ -n "`echo ${array_phpext[@]} | grep -w 14`" ] && pecl_xdebug=1
  393. break
  394. fi
  395. done
  396. }
  397. Print_HHVM() {
  398. [ -e "/usr/bin/hhvm" ] && echo "/usr/bin/hhvm"
  399. [ -e "/etc/hhvm" ] && echo "/etc/hhvm"
  400. [ -e "/var/log/hhvm" ] && echo "/var/log/hhvm"
  401. [ -e "/lib/systemd/system/hhvm.service" ] && echo "/lib/systemd/system/hhvm.service"
  402. [ -e "/etc/supervisord.conf" ] && echo "/etc/supervisord.conf"
  403. [ -e "/etc/init.d/supervisord" ] && echo "/etc/init.d/supervisord"
  404. }
  405. Uninstall_HHVM() {
  406. [ -e "/lib/systemd/system/hhvm.service" ] && { systemctl disable hhvm > /dev/null 2>&1; rm -f /lib/systemd/system/hhvm.service; }
  407. [ -e "/etc/init.d/supervisord" ] && { service supervisord stop > /dev/null 2>&1; rm -f /etc/supervisord.conf /etc/init.d/supervisord; }
  408. [ -e "/usr/bin/hhvm" ] && { rpm -e hhvm; rm -rf /etc/hhvm /var/log/hhvm /usr/bin/hhvm; echo "${CMSG}HHVM uninstall completed! ${CEND}"; }
  409. }
  410. Print_PureFtpd() {
  411. [ -e "${pureftpd_install_dir}" ] && echo "${pureftpd_install_dir}"
  412. [ -e "/etc/init.d/pureftpd" ] && echo "/etc/init.d/pureftpd"
  413. [ -e "/lib/systemd/system/pureftpd.service" ] && echo "/lib/systemd/system/pureftpd.service"
  414. }
  415. Uninstall_PureFtpd() {
  416. [ -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}"; }
  417. [ -e "/lib/systemd/system/pureftpd.service" ] && { systemctl disable pureftpd > /dev/null 2>&1; rm -f /lib/systemd/system/pureftpd.service; }
  418. }
  419. Print_Redis-server() {
  420. [ -e "${redis_install_dir}" ] && echo "${redis_install_dir}"
  421. [ -e "/etc/init.d/redis-server" ] && echo "/etc/init.d/redis-server"
  422. [ -e "/lib/systemd/system/redis-server.service" ] && echo '/lib/systemd/system/redis-server.service'
  423. }
  424. Uninstall_Redis-server() {
  425. [ -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}"; }
  426. [ -e "/lib/systemd/system/redis-server.service" ] && { systemctl disable redis-server > /dev/null 2>&1; rm -f /lib/systemd/system/redis-server.service; }
  427. }
  428. Print_Memcached-server() {
  429. [ -e "${memcached_install_dir}" ] && echo "${memcached_install_dir}"
  430. [ -e "/etc/init.d/memcached" ] && echo "/etc/init.d/memcached"
  431. [ -e "/usr/bin/memcached" ] && echo "/usr/bin/memcached"
  432. }
  433. Uninstall_Memcached-server() {
  434. [ -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}"; }
  435. }
  436. Print_phpMyAdmin() {
  437. [ -d "${wwwroot_dir}/default/phpMyAdmin" ] && echo "${wwwroot_dir}/default/phpMyAdmin"
  438. }
  439. Uninstall_phpMyAdmin() {
  440. [ -d "${wwwroot_dir}/default/phpMyAdmin" ] && rm -rf ${wwwroot_dir}/default/phpMyAdmin
  441. }
  442. Print_openssl() {
  443. [ -d "${openssl_install_dir}" ] && echo "${openssl_install_dir}"
  444. }
  445. Uninstall_openssl() {
  446. [ -d "${openssl_install_dir}" ] && rm -rf ${openssl_install_dir}
  447. }
  448. Menu() {
  449. while :; do
  450. printf "
  451. What Are You Doing?
  452. \t${CMSG} 0${CEND}. Uninstall All
  453. \t${CMSG} 1${CEND}. Uninstall Nginx/Tengine/OpenResty/Apache/Tomcat
  454. \t${CMSG} 2${CEND}. Uninstall MySQL/MariaDB/Percona/AliSQL
  455. \t${CMSG} 3${CEND}. Uninstall PostgreSQL
  456. \t${CMSG} 4${CEND}. Uninstall MongoDB
  457. \t${CMSG} 5${CEND}. Uninstall PHP
  458. \t${CMSG} 6${CEND}. Uninstall PHP opcode cache
  459. \t${CMSG} 7${CEND}. Uninstall PHP extensions
  460. \t${CMSG} 8${CEND}. Uninstall HHVM
  461. \t${CMSG} 9${CEND}. Uninstall PureFtpd
  462. \t${CMSG}10${CEND}. Uninstall Redis
  463. \t${CMSG}11${CEND}. Uninstall Memcached
  464. \t${CMSG}12${CEND}. Uninstall phpMyAdmin
  465. \t${CMSG} q${CEND}. Exit
  466. "
  467. echo
  468. read -e -p "Please input the correct option: " Number
  469. if [[ ! "${Number}" =~ ^[0-9,q]$|^1[0-2]$ ]]; then
  470. echo "${CWARNING}input error! Please only input 0~12 and q${CEND}"
  471. else
  472. case "$Number" in
  473. 0)
  474. Print_Warn
  475. Print_web
  476. Print_MySQL
  477. Print_PostgreSQL
  478. Print_MongoDB
  479. Print_PHP
  480. Print_HHVM
  481. Print_PureFtpd
  482. Print_Redis-server
  483. Print_Memcached-server
  484. Print_openssl
  485. Print_phpMyAdmin
  486. Uninstall_status
  487. if [ "${uninstall_yn}" == 'y' ]; then
  488. Uninstall_Web
  489. Uninstall_MySQL
  490. Uninstall_PostgreSQL
  491. Uninstall_MongoDB
  492. Uninstall_PHP
  493. Uninstall_HHVM
  494. Uninstall_PureFtpd
  495. Uninstall_Redis-server
  496. Uninstall_Memcached-server
  497. Uninstall_openssl
  498. Uninstall_phpMyAdmin
  499. else
  500. exit
  501. fi
  502. ;;
  503. 1)
  504. Print_Warn
  505. Print_web
  506. Uninstall_status
  507. [ "${uninstall_yn}" == 'y' ] && Uninstall_Web || exit
  508. ;;
  509. 2)
  510. Print_Warn
  511. Print_MySQL
  512. Uninstall_status
  513. [ "${uninstall_yn}" == 'y' ] && Uninstall_MySQL || exit
  514. ;;
  515. 3)
  516. Print_Warn
  517. Print_PostgreSQL
  518. Uninstall_status
  519. [ "${uninstall_yn}" == 'y' ] && Uninstall_PostgreSQL || exit
  520. ;;
  521. 4)
  522. Print_Warn
  523. Print_MongoDB
  524. Uninstall_status
  525. [ "${uninstall_yn}" == 'y' ] && Uninstall_MongoDB || exit
  526. ;;
  527. 5)
  528. Print_PHP
  529. Uninstall_status
  530. [ "${uninstall_yn}" == 'y' ] && Uninstall_PHP || exit
  531. ;;
  532. 6)
  533. Uninstall_status
  534. [ "${uninstall_yn}" == 'y' ] && Uninstall_PHPcache || exit
  535. ;;
  536. 7)
  537. Menu_PHPext
  538. [ "${phpext_option}" != '0' ] && Uninstall_status
  539. [ "${uninstall_yn}" == 'y' ] && Uninstall_PHPext || exit
  540. ;;
  541. 8)
  542. Print_HHVM
  543. Uninstall_status
  544. [ "${uninstall_yn}" == 'y' ] && Uninstall_HHVM || exit
  545. ;;
  546. 9)
  547. Print_PureFtpd
  548. Uninstall_status
  549. [ "${uninstall_yn}" == 'y' ] && Uninstall_PureFtpd || exit
  550. ;;
  551. 10)
  552. Print_Redis-server
  553. Uninstall_status
  554. [ "${uninstall_yn}" == 'y' ] && Uninstall_Redis-server || exit
  555. ;;
  556. 11)
  557. Print_Memcached-server
  558. Uninstall_status
  559. [ "${uninstall_yn}" == 'y' ] && Uninstall_Memcached-server || exit
  560. ;;
  561. 12)
  562. Print_phpMyAdmin
  563. Uninstall_status
  564. [ "${uninstall_yn}" == 'y' ] && Uninstall_phpMyAdmin || exit
  565. ;;
  566. q)
  567. exit
  568. ;;
  569. esac
  570. fi
  571. done
  572. }
  573. if [ ${ARG_NUM} == 0 ]; then
  574. Menu
  575. else
  576. [ "${web_yn}" == 'y' ] && Print_web
  577. [ "${mysql_yn}" == 'y' ] && Print_MySQL
  578. [ "${postgresql_yn}" == 'y' ] && Print_PostgreSQL
  579. [ "${mongodb_yn}" == 'y' ] && Print_MongoDB
  580. [ "${php_yn}" == 'y' ] && Print_PHP
  581. [ "${hhvm_yn}" == 'y' ] && Print_HHVM
  582. [ "${pureftpd_yn}" == 'y' ] && Print_PureFtpd
  583. [ "${redis_yn}" == 'y' ] && Print_Redis-server
  584. [ "${memcached_yn}" == 'y' ] && Print_Memcached-server
  585. [ "${phpmyadmin_yn}" == 'y' ] && Print_phpMyAdmin
  586. [ "${all_yn}" == 'y' ] && Print_openssl
  587. Uninstall_status
  588. if [ "${uninstall_yn}" == 'y' ]; then
  589. [ "${web_yn}" == 'y' ] && Uninstall_Web
  590. [ "${mysql_yn}" == 'y' ] && Uninstall_MySQL
  591. [ "${postgresql_yn}" == 'y' ] && Uninstall_PostgreSQL
  592. [ "${mongodb_yn}" == 'y' ] && Uninstall_MongoDB
  593. [ "${phpcache_yn}" == 'y' ] && Uninstall_PHPcache
  594. Uninstall_PHPext
  595. [ "${php_yn}" == 'y' ] && Uninstall_PHP
  596. [ "${hhvm_yn}" == 'y' ] && Uninstall_HHVM
  597. [ "${pureftpd_yn}" == 'y' ] && Uninstall_PureFtpd
  598. [ "${redis_yn}" == 'y' ] && Uninstall_Redis-server
  599. [ "${memcached_yn}" == 'y' ] && Uninstall_Memcached-server
  600. [ "${phpmyadmin_yn}" == 'y' ] && Uninstall_phpMyAdmin
  601. [ "${all_yn}" == 'y' ] && Uninstall_openssl
  602. fi
  603. fi