uninstall.sh 25 KB

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