uninstall.sh 24 KB

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