Parcourir la source

Add php-7 gmagick and Update uninstall.sh

lj2007331 il y a 9 ans
Parent
commit
1a3127a3c2
7 fichiers modifiés avec 340 ajouts et 161 suppressions
  1. 1 1
      apps.conf
  2. 2 2
      config/pure-ftpd.conf
  3. 9 3
      include/GraphicsMagick.sh
  4. 3 3
      include/ImageMagick.sh
  5. 1 0
      include/redis.sh
  6. 41 96
      install.sh
  7. 283 56
      uninstall.sh

+ 1 - 1
apps.conf

@@ -1,7 +1,7 @@
 # newest software version
 # Web
 nginx_version=1.9.9
-tengine_version=2.1.2
+tengine_version=2.1.1
 
 tomcat_7_version=7.0.67
 tomcat_8_version=8.0.30

+ 2 - 2
config/pure-ftpd.conf

@@ -37,7 +37,7 @@ BrokenClientsCompatibility  no
 
 # Maximum number of simultaneous users
 
-MaxClientsNumber            50
+MaxClientsNumber            500
 
 
 
@@ -49,7 +49,7 @@ Daemonize                   yes
 
 # Maximum number of sim clients with the same IP address
 
-MaxClientsPerIP             5
+MaxClientsPerIP             50
 
 
 

+ 9 - 3
include/GraphicsMagick.sh

@@ -24,9 +24,15 @@ cd ..
 Install_php-gmagick() {
 cd $oneinstack_dir/src
 if [ -e "$php_install_dir/bin/phpize" ];then
-    src_url=http://pecl.php.net/get/gmagick-$gmagick_version.tgz && Download_src
-    tar xzf gmagick-$gmagick_version.tgz 
-    cd gmagick-$gmagick_version
+    if [ "`$php_install_dir/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}'`" == '7' ];then
+        src_url=https://pecl.php.net/get/gmagick-2.0.1RC1.tgz && Download_src
+        tar xzf gmagick-2.0.1RC1.tgz 
+        cd gmagick-2.0.1RC1 
+    else
+        src_url=http://pecl.php.net/get/gmagick-$gmagick_version.tgz && Download_src
+        tar xzf gmagick-$gmagick_version.tgz 
+        cd gmagick-$gmagick_version
+    fi
     make clean
     export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
     $php_install_dir/bin/phpize

+ 3 - 3
include/ImageMagick.sh

@@ -25,9 +25,9 @@ Install_php-imagick() {
 cd $oneinstack_dir/src
 if [ -e "$php_install_dir/bin/phpize" ];then
     if [ "`$php_install_dir/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}'`" == '7' ];then
-        src_url=https://pecl.php.net/get/imagick-3.4.0RC3.tgz && Download_src
-        tar xzf imagick-3.4.0RC3.tgz
-        cd imagick-3.4.0RC3
+        src_url=https://pecl.php.net/get/imagick-3.4.0RC4.tgz && Download_src
+        tar xzf imagick-3.4.0RC4.tgz
+        cd imagick-3.4.0RC4
     else
         src_url=http://pecl.php.net/get/imagick-$imagick_version.tgz && Download_src
         tar xzf imagick-$imagick_version.tgz

+ 1 - 0
include/redis.sh

@@ -30,6 +30,7 @@ if [ -f "src/redis-server" ];then
     sed -i "s@logfile.*@logfile $redis_install_dir/var/redis.log@" $redis_install_dir/etc/redis.conf
     sed -i "s@^dir.*@dir $redis_install_dir/var@" $redis_install_dir/etc/redis.conf
     sed -i 's@daemonize no@daemonize yes@' $redis_install_dir/etc/redis.conf
+    sed -i "s@^# bind 127.0.0.1@bind 127.0.0.1@" $redis_install_dir/etc/redis.conf
     redis_maxmemory=`expr $Mem / 8`000000
     [ -z "`grep ^maxmemory $redis_install_dir/etc/redis.conf`" ] && sed -i "s@maxmemory <bytes>@maxmemory <bytes>\nmaxmemory `expr $Mem / 8`000000@" $redis_install_dir/etc/redis.conf
     echo "${CSUCCESS}Redis-server install successfully! ${CEND}"

+ 41 - 96
install.sh

@@ -43,9 +43,7 @@ mkdir -p $wwwroot_dir/default $wwwlogs_dir
 # Use default SSH port 22. If you use another SSH port on your server
 if [ -e "/etc/ssh/sshd_config" ];then
     [ -z "`grep ^Port /etc/ssh/sshd_config`" ] && ssh_port=22 || ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}'`
-    while :
-    do
-        echo
+    while :; do echo
         read -p "Please input SSH port(Default: $ssh_port): " SSH_PORT 
         [ -z "$SSH_PORT" ] && SSH_PORT=$ssh_port
         if [ $SSH_PORT -eq 22 >/dev/null 2>&1 -o $SSH_PORT -gt 1024 >/dev/null 2>&1 -a $SSH_PORT -lt 65535 >/dev/null 2>&1 ];then
@@ -63,18 +61,14 @@ if [ -e "/etc/ssh/sshd_config" ];then
 fi
 
 # check Web server
-while :
-do
-    echo
+while :; do echo
     read -p "Do you want to install Web server? [y/n]: " Web_yn
     if [[ ! $Web_yn =~ ^[y,n]$ ]];then
         echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
     else
         if [ "$Web_yn" == 'y' ];then
             # Nginx/Tegine
-            while :
-            do
-                echo
+            while :; do echo
                 echo 'Please select Nginx server:'
                 echo -e "\t${CMSG}1${CEND}. Install Nginx"
                 echo -e "\t${CMSG}2${CEND}. Install Tengine"
@@ -90,9 +84,7 @@ do
                 fi
             done
             # Apache
-            while :
-            do
-                echo
+            while :; do echo
                 echo 'Please select Apache server:'
                 echo -e "\t${CMSG}1${CEND}. Install Apache-2.4"
                 echo -e "\t${CMSG}2${CEND}. Install Apache-2.2"
@@ -107,9 +99,7 @@ do
                 fi
             done
             # Tomcat
-            while :
-            do
-                echo
+            while :; do echo
                 echo 'Please select tomcat server:'
                 echo -e "\t${CMSG}1${CEND}. Install Tomcat-8"
                 echo -e "\t${CMSG}2${CEND}. Install Tomcat-7"
@@ -121,9 +111,7 @@ do
                 else
                     [ "$Tomcat_version" != '3' -a -e "$tomcat_install_dir/conf/server.xml" ] && { echo "${CWARNING}Tomcat already installed! ${CEND}" ; Tomcat_version=Other; }  
                     if [ "$Tomcat_version" == '1' ];then
-                        while :
-                        do
-                            echo
+                        while :; do echo
                             echo 'Please select JDK version:'
                             echo -e "\t${CMSG}1${CEND}. Install JDK-1.8"
                             echo -e "\t${CMSG}2${CEND}. Install JDK-1.7"
@@ -137,9 +125,7 @@ do
                         done
                     fi
                     if [ "$Tomcat_version" == '2' ];then
-                        while :
-                        do
-                            echo
+                        while :; do echo
                             echo 'Please select JDK version:'
                             echo -e "\t${CMSG}1${CEND}. Install JDK-1.8"
                             echo -e "\t${CMSG}2${CEND}. Install JDK-1.7"
@@ -162,18 +148,14 @@ do
 done
 
 # choice database
-while :
-do
-    echo
+while :; do echo
     read -p "Do you want to install Database? [y/n]: " DB_yn
     if [[ ! $DB_yn =~ ^[y,n]$ ]];then
         echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
     else
         if [ "$DB_yn" == 'y' ];then
             [ -d "$db_install_dir/support-files" ] && { echo "${CWARNING}Database already installed! ${CEND}"; DB_yn=Other; break; }
-            while :
-            do
-                echo
+            while :; do echo
                 echo 'Please select a version of the Database:'
                 echo -e "\t${CMSG}1${CEND}. Install MySQL-5.7"
                 echo -e "\t${CMSG}2${CEND}. Install MySQL-5.6"
@@ -188,8 +170,7 @@ do
                 if [[ ! $DB_version =~ ^[1-8]$ ]];then
                     echo "${CWARNING}input error! Please only input number 1,2,3,4,5,6,7,8${CEND}"
                 else
-                    while :
-                    do
+                    while :; do
                         read -p "Please input the root password of database: " dbrootpwd
                         [ -n "`echo $dbrootpwd | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and & ${CEND}"; continue; }
                         (( ${#dbrootpwd} >= 5 )) && sed -i "s+^dbrootpwd.*+dbrootpwd='$dbrootpwd'+" ./options.conf && break || echo "${CWARNING}database root password least 5 characters! ${CEND}"
@@ -203,18 +184,14 @@ do
 done
 
 # check PHP
-while :
-do
-    echo
+while :; do echo
     read -p "Do you want to install PHP? [y/n]: " PHP_yn
     if [[ ! $PHP_yn =~ ^[y,n]$ ]];then
         echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
     else
         if [ "$PHP_yn" == 'y' ];then
             [ -e "$php_install_dir/bin/phpize" ] && { echo "${CWARNING}PHP already installed! ${CEND}"; PHP_yn=Other; break; }
-            while :
-            do
-                echo
+            while :; do echo
                 echo 'Please select a version of the PHP:'
                 echo -e "\t${CMSG}1${CEND}. Install php-5.3"
                 echo -e "\t${CMSG}2${CEND}. Install php-5.4"
@@ -226,17 +203,14 @@ do
                 if [[ ! $PHP_version =~ ^[1-5]$ ]];then
                     echo "${CWARNING}input error! Please only input number 1,2,3,4,5${CEND}"
                 else
-                    while :
-                    do
-                        echo
+                    while :; do echo
                         read -p "Do you want to install opcode cache of the PHP? [y/n]: " PHP_cache_yn 
                         if [[ ! $PHP_cache_yn =~ ^[y,n]$ ]];then
-                        	echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+                            echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
                         else
                             if [ "$PHP_cache_yn" == 'y' ];then	
                                 if [ $PHP_version == 1 ];then
-                                    while :
-                                    do
+                                    while :; do
                                         echo 'Please select a opcode cache of the PHP:'
                                         echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
                                         echo -e "\t${CMSG}2${CEND}. Install XCache"
@@ -252,8 +226,7 @@ do
                                     done
                                 fi
                                 if [ $PHP_version == 2 ];then
-                                    while :
-                                    do
+                                    while :; do
                                         echo 'Please select a opcode cache of the PHP:'
                                         echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
                                         echo -e "\t${CMSG}2${CEND}. Install XCache"
@@ -269,8 +242,7 @@ do
                                     done
                                 fi
                                 if [ $PHP_version == 3 ];then
-                                    while :
-                                    do
+                                    while :; do
                                         echo 'Please select a opcode cache of the PHP:'
                                         echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
                                         echo -e "\t${CMSG}2${CEND}. Install XCache"
@@ -285,8 +257,7 @@ do
                                     done
                                 fi
                                 if [ $PHP_version == 4 ];then
-                                    while :
-                                    do
+                                    while :; do
                                         echo 'Please select a opcode cache of the PHP:'
                                         echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
                                         echo -e "\t${CMSG}2${CEND}. Install XCache"
@@ -300,8 +271,7 @@ do
                                     done
                                 fi
                                 if [ $PHP_version == 5 ];then
-                                    while :
-                                    do
+                                    while :; do
                                         echo 'Please select a opcode cache of the PHP:'
                                         echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
                                         read -p "Please input a number:(Default 1 press Enter) " PHP_cache
@@ -318,16 +288,13 @@ do
                         fi
                     done
                     if [ "$PHP_cache" == '2' ];then
-                        while :
-                        do
+                        while :; do
                             read -p "Please input xcache admin password: " xcache_admin_pass
                             (( ${#xcache_admin_pass} >= 5 )) && { xcache_admin_md5_pass=`echo -n "$xcache_admin_pass" | md5sum | awk '{print $1}'` ; break ; } || echo "${CFAILURE}xcache admin password least 5 characters! ${CEND}"
                         done
                     fi
                     if [ "$PHP_version" != '5' -a "$PHP_cache" != '1' ];then
-                        while :
-                        do
-                            echo
+                        while :; do echo
                             read -p "Do you want to install ZendGuardLoader? [y/n]: " ZendGuardLoader_yn
                             if [[ ! $ZendGuardLoader_yn =~ ^[y,n]$ ]];then
                                 echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
@@ -338,9 +305,7 @@ do
                     fi
         
                     if [ "$PHP_version" != '5' ];then
-                        while :
-                        do
-                            echo
+                        while :; do echo
                             read -p "Do you want to install ionCube? [y/n]: " ionCube_yn
                             if [[ ! $ionCube_yn =~ ^[y,n]$ ]];then
                                 echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
@@ -351,9 +316,7 @@ do
                     fi
         
                     # ImageMagick or GraphicsMagick
-                    while :
-                    do
-                        echo
+                    while :; do echo
                         read -p "Do you want to install ImageMagick or GraphicsMagick? [y/n]: " Magick_yn
                         if [[ ! $Magick_yn =~ ^[y,n]$ ]];then
                             echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
@@ -362,9 +325,8 @@ do
                         fi
                     done
 
-                    if [ "$Magick_yn" == 'y' ] && [ "$PHP_version" != '5' ];then
-                        while :
-                        do
+                    if [ "$Magick_yn" == 'y' ];then
+                        while :; do
                             echo 'Please select ImageMagick or GraphicsMagick:'
                             echo -e "\t${CMSG}1${CEND}. Install ImageMagick"
                             echo -e "\t${CMSG}2${CEND}. Install GraphicsMagick"
@@ -376,8 +338,6 @@ do
                                 break
                             fi
                         done
-                    elif [ "$Magick_yn" == 'y' ] && [ "$PHP_version" == '5' ];then
-                        Magick=1
                     fi
                     break
                 fi
@@ -388,9 +348,7 @@ do
 done
 
 # check Pureftpd
-while :
-do
-    echo
+while :; do echo
     read -p "Do you want to install Pure-FTPd? [y/n]: " FTP_yn
     if [[ ! $FTP_yn =~ ^[y,n]$ ]];then
         echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
@@ -402,9 +360,7 @@ done
 
 # check phpMyAdmin
 if [[ $PHP_version =~ ^[1-5]$ ]] || [ -e "$php_install_dir/bin/phpize" ];then
-    while :
-    do
-        echo
+    while :; do echo
         read -p "Do you want to install phpMyAdmin? [y/n]: " phpMyAdmin_yn
         if [[ ! $phpMyAdmin_yn =~ ^[y,n]$ ]];then
             echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
@@ -416,9 +372,7 @@ if [[ $PHP_version =~ ^[1-5]$ ]] || [ -e "$php_install_dir/bin/phpize" ];then
 fi
 
 # check redis
-while :
-do
-    echo
+while :; do echo
     read -p "Do you want to install redis? [y/n]: " redis_yn
     if [[ ! $redis_yn =~ ^[y,n]$ ]];then
         echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
@@ -428,9 +382,7 @@ do
 done
 
 # check memcached
-while :
-do
-    echo
+while :; do echo
     read -p "Do you want to install memcached? [y/n]: " memcached_yn
     if [[ ! $memcached_yn =~ ^[y,n]$ ]];then
         echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
@@ -441,19 +393,16 @@ done
 
 # check jemalloc or tcmalloc 
 if [ "$Nginx_version" == '1' -o "$Nginx_version" == '2' -o "$DB_yn" == 'y' ];then
-    while :
-    do
-        echo
+    while :; do echo
         read -p "Do you want to use jemalloc or tcmalloc optimize Database and Web server? [y/n]: " je_tc_malloc_yn
         if [[ ! $je_tc_malloc_yn =~ ^[y,n]$ ]];then
-        	echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+            echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
         else
             if [ "$je_tc_malloc_yn" == 'y' ];then
                 echo 'Please select jemalloc or tcmalloc:'
                 echo -e "\t${CMSG}1${CEND}. jemalloc"
                 echo -e "\t${CMSG}2${CEND}. tcmalloc"
-                while :
-                do
+                while :; do
                     read -p "Please input a number:(Default 1 press Enter) " je_tc_malloc
                     [ -z "$je_tc_malloc" ] && je_tc_malloc=1
                     if [[ ! $je_tc_malloc =~ ^[1-2]$ ]];then
@@ -468,9 +417,7 @@ if [ "$Nginx_version" == '1' -o "$Nginx_version" == '2' -o "$DB_yn" == 'y' ];the
     done
 fi
 
-while :
-do
-    echo
+while :; do echo
     read -p "Do you want to install HHVM? [y/n]: " HHVM_yn
     if [[ ! $HHVM_yn =~ ^[y,n]$ ]];then
         echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
@@ -710,15 +657,13 @@ echo "####################Congratulations########################"
 [ "$redis_yn" == 'y' ] && echo -e "\n`printf "%-32s" "redis install dir:"`${CMSG}$redis_install_dir${CEND}"
 [ "$memcached_yn" == 'y' ] && echo -e "\n`printf "%-32s" "memcached install dir:"`${CMSG}$memcached_install_dir${CEND}"
 [ "$Web_yn" == 'y' ] && echo -e "\n`printf "%-32s" "index url:"`${CMSG}http://$IPADDR/${CEND}"
-while :
-do
-        echo
-        echo "${CMSG}Please restart the server and see if the services start up fine.${CEND}"
-        read -p "Do you want to restart OS ? [y/n]: " restart_yn
-        if [[ ! $restart_yn =~ ^[y,n]$ ]];then
-            echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
-        else
-            break
-        fi
+while :; do echo
+    echo "${CMSG}Please restart the server and see if the services start up fine.${CEND}"
+    read -p "Do you want to restart OS ? [y/n]: " restart_yn
+    if [[ ! $restart_yn =~ ^[y,n]$ ]];then
+        echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+    else
+        break
+    fi
 done
 [ "$restart_yn" == 'y' ] && reboot

+ 283 - 56
uninstall.sh

@@ -2,11 +2,11 @@
 # Author:  yeho <lj2007331 AT gmail.com>
 # BLOG:  https://blog.linuxeye.com
 #
-# Version: 1.0-Alpha Jun 15,2015 lj2007331 AT gmail.com
 # Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
 #
 # Project home page:
 #       http://oneinstack.com
+#       https://github.com/lj2007331/oneinstack
 
 export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 clear
@@ -26,74 +26,301 @@ printf "
 # Check if user is root
 [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; } 
 
-Uninstall()
-{
-[ -e "$db_install_dir" ] && service mysqld stop && rm -rf /etc/init.d/mysqld /etc/my.cnf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf
-[ -e "$apache_install_dir" ] && service httpd stop && rm -rf /etc/init.d/httpd /etc/logrotate.d/apache
-[ -e "$tomcat_install_dir" ] && service tomcat stop && rm -rf /etc/init.d/tomcat
-[ -e "/usr/java" ] && rm -rf /usr/java
-[ -e "$php_install_dir/bin/phpize" ] && service php-fpm stop && rm -rf /etc/init.d/php-fpm
-[ -e "$nginx_install_dir" ] && service nginx stop && rm -rf /etc/init.d/nginx /etc/logrotate.d/nginx
-[ -e "$tengine_install_dir" ] && service nginx stop && rm -rf /etc/init.d/nginx /etc/logrotate.d/nginx
-[ -e "$pureftpd_install_dir" ] && service pureftpd stop && rm -rf /etc/init.d/pureftpd
-[ -e "$redis_install_dir" ] && service redis-server stop && rm -rf /etc/init.d/redis-server /usr/local/bin/redis-*
-[ -e "$memcached_install_dir" ] && service memcached stop && rm -rf /etc/init.d/memcached /usr/bin/memcached
-[ -e "/usr/local/imagemagick" ] && rm -rf /usr/local/imagemagick 
-[ -e "/usr/local/graphicsmagick" ] && rm -rf /usr/local/graphicsmagick 
-[ -e "/etc/init.d/supervisord" ] && service supervisord stop && { rm -rf /etc/supervisord.conf /etc/init.d/supervisord; } 
-[ -e "/usr/bin/hhvm" ] && { rpm -e hhvm ; rm -rf /etc/hhvm /var/log/hhvm /usr/bin/hhvm; }
-id -u $run_user >/dev/null 2>&1 ; [ $? -eq 0 ] && userdel $run_user
-id -u mysql >/dev/null 2>&1 ; [ $? -eq 0 ] && userdel mysql 
 
-[ -e "$wwwroot_dir" ] && /bin/mv ${wwwroot_dir}{,$(date +%Y%m%d%H)}
-[ -e "$db_data_dir" ] && /bin/mv ${db_data_dir}{,$(date +%Y%m%d%H)}
-for D in `cat ./options.conf | grep dir= | grep -v oneinstack | grep -v backup_dir | awk -F'=' '{print $2}' | sort | uniq`
-do
-    [ -e "$D" ] && rm -rf $D
+Usage(){
+printf "
+Usage: $0 [  ${CMSG}all${CEND} | ${CMSG}web${CEND} | ${CMSG}db${CEND} | ${CMSG}php${CEND} | ${CMSG}hhvm${CEND} | ${CMSG}pureftpd${CEND} | ${CMSG}redis${CEND} | ${CMSG}memcached${CEND} ]
+${CMSG}all${CEND}            --->Uninstall All 
+${CMSG}web${CEND}            --->Uninstall Nginx/Tengine/Apache/Tomcat
+${CMSG}db${CEND}             --->Uninstall MySQL/MariaDB/Percona
+${CMSG}php${CEND}            --->Uninstall PHP
+${CMSG}hhvm${CEND}           --->Uninstall HHVM 
+${CMSG}pureftpd${CEND}       --->Uninstall PureFtpd 
+${CMSG}redis${CEND}          --->Uninstall Redis
+${CMSG}memcached${CEND}      --->Uninstall Memcached 
+
+"
+}
+
+Uninstall_status() {
+while :; do echo
+    read -p "Do you want to uninstall? [y/n]: " uninstall_yn
+    echo
+    if [[ ! $uninstall_yn =~ ^[y,n]$ ]];then
+        echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+    else
+        break
+    fi
 done
+}
 
-sed -i 's@^oneinstack_dir=.*@oneinstack_dir=@' ./options.conf
-sed -i 's@^dbrootpwd=.*@dbrootpwd=@' ./options.conf
+Print_Warn() {
+echo
+echo "${CWARNING}You will uninstall OneinStack, Please backup your configure files and DB data! ${CEND}"
+}
+
+Print_web() {
+[ -d "$nginx_install_dir" ] && echo "$nginx_install_dir" 
+[ -d "$tengine_install_dir" ] && echo "$tengine_install_dir"
+[ -e "/etc/init.d/nginx" ] && echo '/etc/init.d/nginx'
+[ -e "/etc/logrotate.d/nginx" ] && echo '/etc/logrotate.d/nginx'
+
+[ -d "$apache_install_dir" ] && echo "$apache_install_dir"
+[ -e "/etc/init.d/httpd" ] && echo "/etc/init.d/httpd"
+[ -e "/etc/logrotate.d/apache" ] && echo "/etc/logrotate.d/apache"
+
+[ -d "$tomcat_install_dir" ] && echo "$tomcat_install_dir"
+[ -e "/etc/init.d/tomcat" ] && echo "/etc/init.d/tomcat"
+[ -e "/etc/logrotate.d/tomcat" ] && echo "/etc/logrotate.d/tomcat"
+[ -d "/usr/java" ] && echo '/usr/java'
+}
+
+Uninstall_Web() {
+[ -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; }
+[ -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; }
+[ -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; }
+[ -d "$tomcat_install_dir" ] && { killall java > /dev/null 2>&1; rm -rf $tomcat_install_dir /etc/init.d/tomcat; }
+[ -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; }
+[ -e "$wwwroot_dir" ] && /bin/mv ${wwwroot_dir}{,$(date +%Y%m%d%H)}
 sed -i 's@^website_name=.*@website_name=@' ./options.conf
 sed -i 's@^local_bankup_yn=.*@local_bankup_yn=y@' ./options.conf
 sed -i 's@^remote_bankup_yn=.*@remote_bankup_yn=n@' ./options.conf
-sed -i "s@^export.*$db_install_dir.*@@g" /etc/profile && . /etc/profile
-echo "${CMSG}Uninstall completed${CEND}"
+echo "${CMSG}Web uninstall completed${CEND}"
 }
 
-echo 
-echo "${CWARNING}You will uninstall OneinStack, Please backup your configure files and DB data! ${CEND}"
-echo 
-echo "${CWARNING}The following directory or files will be remove: ${CEND}"
-for D in `cat ./options.conf | grep dir= | grep -v oneinstack | grep -v backup_dir | awk -F'=' '{print $2}' | sort | uniq` 
-do
-    [ -e "$D" ] && echo $D
-done
-[ -e "/etc/init.d/nginx" ] && echo '/etc/init.d/nginx'
-[ -e "/etc/logrotate.d/nginx" ] && echo '/etc/logrotate.d/nginx'
-[ -e "$apache_install_dir" ] && echo -e "/etc/init.d/httpd\n/etc/logrotate.d/apache"
-[ -e "$tomcat_install_dir" ] && echo '/etc/init.d/tomcat'
-[ -e "/usr/java" ] && echo '/usr/java' 
-[ -e "$db_install_dir" ] && echo -e "/etc/init.d/mysqld\n/etc/my.cnf"
-[ -e "$php_install_dir/bin/phpize" ] && echo '/etc/init.d/php-fpm'
-[ -e "$pureftpd_install_dir" ] && echo '/etc/init.d/pureftpd'
-[ -e "$memcached_install_dir" ] && echo -e "/etc/init.d/memcached\n/usr/bin/memcached"
-[ -e "$redis_install_dir" ] && echo '/etc/init.d/redis-server' 
-[ -e "/usr/local/imagemagick" ] && echo '/usr/local/imagemagick' 
-[ -e "/usr/local/graphicsmagick" ] && echo '/usr/local/graphicsmagick' 
-echo 
-echo "Press Ctrl+c to cancel or Press any key to continue..."
-char=`get_char`
+Print_DB() {
+[ -e "$db_install_dir" ] && echo "$db_install_dir" || { echo;echo "${CWARNING}The database is not installed${CEND}";echo;exit; } 
+[ -e "/etc/init.d/mysqld" ] && echo "/etc/init.d/mysqld"
+[ -e "/etc/my.cnf" ] && echo "/etc/my.cnf"
+}
 
+Uninstall_DB() {
+[ -e "$db_install_dir" ] && { service mysqld stop > /dev/null 2>&1; rm -rf $db_install_dir /etc/init.d/mysqld /etc/my.cnf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf; }
+id -u mysql >/dev/null 2>&1 ; [ $? -eq 0 ] && userdel mysql
+[ -e "$db_data_dir" ] && /bin/mv ${db_data_dir}{,$(date +%Y%m%d%H)}
+sed -i 's@^dbrootpwd=.*@dbrootpwd=@' ./options.conf
+sed -i "s@$db_install_dir/bin:@@" /etc/profile
+echo "${CMSG}DB uninstall completed${CEND}"
+}
+
+Print_PHP() {
+[ -e "$php_install_dir" ] && echo "$php_install_dir" || { echo;echo "${CWARNING}The PHP is not installed${CEND}";echo;exit; } 
+[ -e "/etc/init.d/php-fpm" ] && echo "/etc/init.d/php-fpm"
+[ -e "/usr/local/imagemagick" ] && echo "/usr/local/imagemagick"
+[ -e "/usr/local/graphicsmagick" ] && echo '/usr/local/graphicsmagick'
+}
+
+Uninstall_PHP() {
+[ -e "$php_install_dir/bin/phpize" -a -e "$php_install_dir/etc/php-fpm.conf" ] && { service php-fpm stop > /dev/null 2>&1; rm -rf $php_install_dir /etc/init.d/php-fpm; }
+[ -e "$php_install_dir/bin/phpize" -a ! -e "$php_install_dir/etc/php-fpm.conf" ] && rm -rf $php_install_dir
+[ -e "/usr/local/imagemagick" ] && rm -rf /usr/local/imagemagick 
+[ -e "/usr/local/graphicsmagick" ] && rm -rf /usr/local/graphicsmagick 
+sed -i "s@$php_install_dir/bin:@@" /etc/profile
+echo "${CMSG}PHP uninstall completed${CEND}"
+}
+
+Print_HHVM() {
+[ -e "/usr/bin/hhvm" ] && echo "/usr/bin/hhvm" || { echo;echo "${CWARNING}The HHVM is not installed${CEND}";echo;exit; } 
+[ -e "/etc/hhvm" ] && echo "/etc/hhvm"
+[ -e "/var/log/hhvm" ] && echo "/var/log/hhvm"
+[ -e "/etc/supervisord.conf" ] && echo "/etc/supervisord.conf"
+[ -e "/etc/init.d/supervisord" ] && echo "/etc/init.d/supervisord"
+}
+
+Uninstall_HHVM() {
+[ -e "/etc/init.d/supervisord" ] && { service supervisord stop > /dev/null 2>&1; rm -rf /etc/supervisord.conf /etc/init.d/supervisord; }
+[ -e "/usr/bin/hhvm" ] && { rpm -e hhvm; rm -rf /etc/hhvm /var/log/hhvm /usr/bin/hhvm; }
+echo "${CMSG}HHVM uninstall completed${CEND}"
+}
+
+Print_PureFtpd() {
+[ -e "$pureftpd_install_dir" ] && echo "$pureftpd_install_dir" || { echo;echo "${CWARNING}The PureFtpd is not installed${CEND}";echo;exit; } 
+[ -e "/etc/init.d/pureftpd" ] && echo "/etc/init.d/pureftpd" 
+}
+
+Uninstall_PureFtpd() {
+[ -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}"
+}
+
+Print_Redis() {
+[ -e "$redis_install_dir" ] && echo "$redis_install_dir" || { echo;echo "${CWARNING}The Redis is not installed${CEND}";echo;exit; } 
+[ -e "/etc/init.d/redis-server" ] && echo "/etc/init.d/redis-server"
+}
+
+Uninstall_Redis() {
+[ -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}"
+}
+
+Print_Memcached() {
+[ -e "$memcached_install_dir" ] && echo "$memcached_install_dir" || { echo;echo "${CWARNING}The Memcached is not installed${CEND}";echo;exit; } 
+[ -e "/etc/init.d/memcached" ] && echo "/etc/init.d/memcached"
+[ -e "/usr/bin/memcached" ] && echo "/usr/bin/memcached"
+}
+
+Uninstall_Memcached() {
+[ -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}"
+}
+
+Menu(){
 while :
 do
+    printf "
+What Are You Doing?
+\t${CMSG}0${CEND}. Uninstall All 
+\t${CMSG}1${CEND}. Uninstall Nginx/Tengine/Apache/Tomcat 
+\t${CMSG}2${CEND}. Uninstall MySQL/MariaDB/Percona 
+\t${CMSG}3${CEND}. Uninstall PHP 
+\t${CMSG}4${CEND}. Uninstall HHVM 
+\t${CMSG}5${CEND}. Uninstall PureFtpd 
+\t${CMSG}6${CEND}. Uninstall Redis 
+\t${CMSG}7${CEND}. Uninstall Memcached 
+\t${CMSG}q${CEND}. Exit
+"
     echo
-    read -p "Do you want to uninstall OneinStack? [y/n]: " uninstall_yn
-    if [[ ! $uninstall_yn =~ ^[y,n]$ ]];then
-        echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+    read -p "Please input the correct option: " Number
+    if [[ ! $Number =~ ^[0-7,q]$ ]];then
+        echo "${CWARNING}input error! Please only input 0,1,2,3,4,5,6,7 and q${CEND}"
     else
-        break
+        case "$Number" in
+        0)
+            Print_Warn
+            Print_web
+            Print_DB
+            Print_PHP
+            Print_HHVM
+            Print_PureFtpd
+            Print_Redis
+            Print_Memcached
+
+            Uninstall_status
+            if [ "$uninstall_yn" == 'y' ];then
+                Uninstall_Web
+                Uninstall_DB
+                Uninstall_PHP
+                Uninstall_HHVM
+                Uninstall_PureFtpd
+                Uninstall_Redis
+                Uninstall_Memcached
+            else
+                exit
+            fi
+            ;;
+        1)
+            Print_Warn
+            Print_web
+            Uninstall_status
+            [ "$uninstall_yn" == 'y' ] && Uninstall_Web || exit
+            ;;
+        2)
+            Print_Warn
+            Print_DB
+            Uninstall_status
+            [ "$uninstall_yn" == 'y' ] && Uninstall_DB || exit
+            ;;
+        3)
+            Print_PHP
+            Uninstall_status
+            [ "$uninstall_yn" == 'y' ] && Uninstall_PHP || exit
+            ;;
+        4)
+            Print_HHVM
+            Uninstall_status
+            [ "$uninstall_yn" == 'y' ] && Uninstall_HHVM || exit
+            ;;
+        5)
+            Print_PureFtpd
+            Uninstall_status
+            [ "$uninstall_yn" == 'y' ] && Uninstall_PureFtpd || exit
+            ;;
+        6)
+            Print_Redis
+            Uninstall_status
+            [ "$uninstall_yn" == 'y' ] && Uninstall_Redis || exit
+            ;;
+        7)
+            Print_Memcached
+            Uninstall_status
+            [ "$uninstall_yn" == 'y' ] && Uninstall_Memcached || exit
+            ;;
+        q)
+            exit
+            ;;
+        esac
     fi
 done
+}
+
+if [ $# == 0 ];then
+    Menu
+elif [ $# == 1 ];then
+    case $1 in
+    all)
+        Print_Warn
+        Print_web
+        Print_DB
+        Print_PHP
+        Print_HHVM
+        Print_PureFtpd
+        Print_Redis
+        Print_Memcached
 
-[ "$uninstall_yn" == 'y' ] && Uninstall
+        Uninstall_status
+        if [ "$uninstall_yn" == 'y' ];then
+            Uninstall_Web
+            Uninstall_DB
+            Uninstall_PHP
+            Uninstall_HHVM
+            Uninstall_PureFtpd
+            Uninstall_Redis
+            Uninstall_Memcached
+        else
+            exit
+        fi
+        ;;
+    web)
+        Print_Warn
+        Print_web
+        Uninstall_status
+        [ "$uninstall_yn" == 'y' ] && Uninstall_Web || exit
+        ;;
+    db)
+        Print_Warn
+        Print_DB
+        Uninstall_status
+        [ "$uninstall_yn" == 'y' ] && Uninstall_DB || exit
+        ;;
+    php)
+        Print_PHP
+        Uninstall_status
+        [ "$uninstall_yn" == 'y' ] && Uninstall_PHP || exit
+        ;;
+    hhvm)
+        Print_HHVM
+        Uninstall_status
+        [ "$uninstall_yn" == 'y' ] && Uninstall_HHVM || exit 
+        ;;
+    pureftpd)
+        Print_PureFtpd
+        Uninstall_status
+        [ "$uninstall_yn" == 'y' ] && Uninstall_PureFtpd || exit 
+        ;;
+    redis)
+        Print_Redis
+        Uninstall_status
+        [ "$uninstall_yn" == 'y' ] && Uninstall_Redis || exit 
+        ;;
+    memcached)
+        Print_Memcached
+        Uninstall_status
+        [ "$uninstall_yn" == 'y' ] && Uninstall_Memcached || exit 
+        ;;
+    *)
+        Usage
+        ;;
+    esac
+else
+    Usage
+fi