Browse Source

Format all script (Tab width:2 spaces)

lj2007331 8 years ago
parent
commit
e9ea701cfd
72 changed files with 5002 additions and 5064 deletions
  1. 281 291
      addons.sh
  2. 44 44
      backup.sh
  3. 92 92
      backup_setup.sh
  4. 1 1
      config/index_cn.html
  5. 30 35
      include/GraphicsMagick.sh
  6. 30 35
      include/ImageMagick.sh
  7. 60 62
      include/ZendGuardLoader.sh
  8. 46 48
      include/apache-2.2.sh
  9. 58 61
      include/apache-2.4.sh
  10. 22 23
      include/apcu.sh
  11. 5 8
      include/boost.sh
  12. 620 622
      include/check_download.sh
  13. 50 50
      include/check_os.sh
  14. 9 9
      include/check_port.py
  15. 5 5
      include/color.sh
  16. 32 26
      include/demo.sh
  17. 5 5
      include/download.sh
  18. 19 21
      include/eaccelerator-0.9.sh
  19. 20 21
      include/eaccelerator-1.0-dev.sh
  20. 17 17
      include/get_ipaddr.py
  21. 10 10
      include/get_ipaddr_state.py
  22. 16 16
      include/get_public_ipaddr.py
  23. 32 34
      include/hhvm_CentOS.sh
  24. 55 55
      include/init_CentOS.sh
  25. 8 8
      include/init_Debian.sh
  26. 24 24
      include/init_Ubuntu.sh
  27. 43 43
      include/ioncube.sh
  28. 16 11
      include/jdk-1.6.sh
  29. 14 14
      include/jdk-1.7.sh
  30. 15 15
      include/jdk-1.8.sh
  31. 12 12
      include/jemalloc.sh
  32. 12 12
      include/mariadb-10.0.sh
  33. 12 12
      include/mariadb-10.1.sh
  34. 13 13
      include/mariadb-5.5.sh
  35. 83 92
      include/memcached.sh
  36. 34 37
      include/memory.sh
  37. 12 12
      include/mysql-5.5.sh
  38. 12 12
      include/mysql-5.6.sh
  39. 12 12
      include/mysql-5.7.sh
  40. 54 55
      include/nginx.sh
  41. 52 53
      include/openresty.sh
  42. 13 13
      include/percona-5.5.sh
  43. 12 12
      include/percona-5.6.sh
  44. 12 12
      include/percona-5.7.sh
  45. 156 156
      include/php-5.3.sh
  46. 137 137
      include/php-5.4.sh
  47. 137 138
      include/php-5.5.sh
  48. 138 138
      include/php-5.6.sh
  49. 140 140
      include/php-7.0.sh
  50. 10 10
      include/phpmyadmin.sh
  51. 31 28
      include/pureftpd.sh
  52. 65 72
      include/redis.sh
  53. 10 12
      include/tcmalloc.sh
  54. 57 58
      include/tengine.sh
  55. 53 53
      include/tomcat-6.sh
  56. 52 52
      include/tomcat-7.sh
  57. 52 52
      include/tomcat-8.sh
  58. 155 155
      include/upgrade_db.sh
  59. 21 21
      include/upgrade_php.sh
  60. 26 26
      include/upgrade_phpmyadmin.sh
  61. 30 30
      include/upgrade_redis.sh
  62. 110 107
      include/upgrade_web.sh
  63. 20 22
      include/xcache.sh
  64. 16 18
      include/zendopcache.sh
  65. 525 526
      install.sh
  66. 102 102
      pureftpd_vhost.sh
  67. 11 11
      reset_db_root_password.sh
  68. 145 146
      shadowsocks.sh
  69. 216 216
      uninstall.sh
  70. 53 62
      upgrade.sh
  71. 5 5
      versions.txt
  72. 505 506
      vhost.sh

+ 281 - 291
addons.sh

@@ -50,44 +50,43 @@ sed -i "s@^oneinstack_dir.*@oneinstack_dir=`pwd`@" ./options.conf
 [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
 [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
 
 
 # Check PHP
 # Check PHP
-if [ -e "$php_install_dir/bin/phpize" ];then
-    PHP_detail_version=`$php_install_dir/bin/php -r 'echo PHP_VERSION;'`
-    phpExtensionDir=`$php_install_dir/bin/php-config --extension-dir`
-    PHP_main_version=${PHP_detail_version%.*}
-    PHP_yn=y
-    [ "$PHP_main_version" == '5.3' ] && PHP_version=1
-    [ "$PHP_main_version" == '5.4' ] && PHP_version=2
-    [ "$PHP_main_version" == '5.5' ] && PHP_version=3
-    [ "$PHP_main_version" == '5.6' ] && PHP_version=4
-    [ "$PHP_main_version" == '7.0' ] && PHP_version=5
+if [ -e "$php_install_dir/bin/phpize" ]; then
+  PHP_detail_version=`$php_install_dir/bin/php -r 'echo PHP_VERSION;'`
+  phpExtensionDir=`$php_install_dir/bin/php-config --extension-dir`
+  PHP_main_version=${PHP_detail_version%.*}
+  [ "$PHP_main_version" == '5.3' ] && PHP_version=1
+  [ "$PHP_main_version" == '5.4' ] && PHP_version=2
+  [ "$PHP_main_version" == '5.5' ] && PHP_version=3
+  [ "$PHP_main_version" == '5.6' ] && PHP_version=4
+  [ "$PHP_main_version" == '7.0' ] && PHP_version=5
 fi
 fi
 
 
 # Check PHP Extensions
 # Check PHP Extensions
 Check_PHP_Extension() {
 Check_PHP_Extension() {
-[ -e "$php_install_dir/etc/php.d/ext-${PHP_extension}.ini" ] && { echo "${CWARNING}PHP $PHP_extension module already installed! ${CEND}"; exit 1; }
+  [ -e "$php_install_dir/etc/php.d/ext-${PHP_extension}.ini" ] && { echo "${CWARNING}PHP $PHP_extension module already installed! ${CEND}"; exit 1; }
 }
 }
 
 
 # restart PHP
 # restart PHP
 Restart_PHP() {
 Restart_PHP() {
-[ -e "$apache_install_dir/conf/httpd.conf" ] && /etc/init.d/httpd restart || /etc/init.d/php-fpm restart
+  [ -e "$apache_install_dir/conf/httpd.conf" ] && /etc/init.d/httpd restart || /etc/init.d/php-fpm restart
 }
 }
 
 
 # Check succ
 # Check succ
 Check_succ() {
 Check_succ() {
-[ -f "${phpExtensionDir}/${PHP_extension}.so" ] && { Restart_PHP; echo;echo "${CSUCCESS}PHP $PHP_extension module installed successfully! ${CEND}"; }
+  [ -f "${phpExtensionDir}/${PHP_extension}.so" ] && { Restart_PHP; echo;echo "${CSUCCESS}PHP $PHP_extension module installed successfully! ${CEND}"; }
 }
 }
 
 
 # Uninstall succ
 # Uninstall succ
 Uninstall_succ() {
 Uninstall_succ() {
-[ -e "$php_install_dir/etc/php.d/ext-${PHP_extension}.ini" ] && { rm -rf $php_install_dir/etc/php.d/ext-${PHP_extension}.ini; Restart_PHP; echo; echo "${CMSG}PHP $PHP_extension module uninstall completed${CEND}"; } || { echo; echo "${CWARNING}$PHP_extension module does not exist! ${CEND}"; }
+  [ -e "$php_install_dir/etc/php.d/ext-${PHP_extension}.ini" ] && { rm -rf $php_install_dir/etc/php.d/ext-${PHP_extension}.ini; Restart_PHP; echo; echo "${CMSG}PHP $PHP_extension module uninstall completed${CEND}"; } || { echo; echo "${CWARNING}$PHP_extension module does not exist! ${CEND}"; }
 }
 }
 
 
 # PHP 5.5,5,6,7.0 install opcache
 # PHP 5.5,5,6,7.0 install opcache
 Install_opcache() {
 Install_opcache() {
-$php_install_dir/bin/phpize
-./configure --with-php-config=$php_install_dir/bin/php-config
-make -j ${THREAD} && make install
-cat > $php_install_dir/etc/php.d/ext-opcache.ini << EOF
+  $php_install_dir/bin/phpize
+  ./configure --with-php-config=$php_install_dir/bin/php-config
+  make -j ${THREAD} && make install
+  cat > $php_install_dir/etc/php.d/ext-opcache.ini << EOF
 [opcache]
 [opcache]
 zend_extension=opcache.so
 zend_extension=opcache.so
 opcache.enable=1
 opcache.enable=1
@@ -103,7 +102,7 @@ EOF
 }
 }
 
 
 Install_letsencrypt() {
 Install_letsencrypt() {
-if [ "$CentOS_RHEL_version" == '7' ];then
+  if [ "$CentOS_RHEL_version" == '7' ]; then
     [ ! -e /etc/yum.repos.d/epel.repo ] && cat > /etc/yum.repos.d/epel.repo << EOF
     [ ! -e /etc/yum.repos.d/epel.repo ] && cat > /etc/yum.repos.d/epel.repo << EOF
 [epel]
 [epel]
 name=Extra Packages for Enterprise Linux 7 - \$basearch
 name=Extra Packages for Enterprise Linux 7 - \$basearch
@@ -113,7 +112,7 @@ failovermethod=priority
 enabled=1
 enabled=1
 gpgcheck=0
 gpgcheck=0
 EOF
 EOF
-elif [ "$CentOS_RHEL_version" == '6' ];then
+  elif [ "$CentOS_RHEL_version" == '6' ]; then
     [ ! -e /etc/yum.repos.d/epel.repo ] && cat > /etc/yum.repos.d/epel.repo << EOF
     [ ! -e /etc/yum.repos.d/epel.repo ] && cat > /etc/yum.repos.d/epel.repo << EOF
 [epel]
 [epel]
 name=Extra Packages for Enterprise Linux 6 - \$basearch
 name=Extra Packages for Enterprise Linux 6 - \$basearch
@@ -123,41 +122,41 @@ failovermethod=priority
 enabled=1
 enabled=1
 gpgcheck=0
 gpgcheck=0
 EOF
 EOF
-fi
+  fi
 
 
-cd $oneinstack_dir/src
-src_url=https://dl.eff.org/certbot-auto && Download_src
-/bin/mv certbot-auto /usr/local/bin/
-chmod +x /usr/local/bin/certbot-auto
-certbot-auto -n
-certbot-auto -h | grep '\-\-standalone' > /dev/null && echo; echo "${CSUCCESS}Let's Encrypt client installed successfully! ${CEND}"
+  pushd $oneinstack_dir/src
+  src_url=https://dl.eff.org/certbot-auto && Download_src
+  /bin/mv certbot-auto /usr/local/bin/
+  chmod +x /usr/local/bin/certbot-auto
+  certbot-auto -n
+  certbot-auto -h | grep '\-\-standalone' > /dev/null && echo; echo "${CSUCCESS}Let's Encrypt client installed successfully! ${CEND}"
 }
 }
 
 
 Uninstall_letsencrypt() {
 Uninstall_letsencrypt() {
-rm -rf /usr/local/bin/cerbot-auto /etc/letsencrypt /var/log/letsencrypt
-[ "$OS" == 'CentOS' ] && Cron_file=/var/spool/cron/root || Cron_file=/var/spool/cron/crontabs/root
-sed -i '/certbot-auto/d' $Cron_file
-echo; echo "${CMSG}Let's Encrypt client uninstall completed${CEND}";
+  rm -rf /usr/local/bin/cerbot-auto /etc/letsencrypt /var/log/letsencrypt
+  [ "$OS" == 'CentOS' ] && Cron_file=/var/spool/cron/root || Cron_file=/var/spool/cron/crontabs/root
+  sed -i '/certbot-auto/d' $Cron_file
+  echo; echo "${CMSG}Let's Encrypt client uninstall completed${CEND}";
 }
 }
 
 
 ACTION_FUN() {
 ACTION_FUN() {
-while :; do
+  while :; do
     echo
     echo
     echo 'Please select an action:'
     echo 'Please select an action:'
     echo -e "\t${CMSG}1${CEND}. install"
     echo -e "\t${CMSG}1${CEND}. install"
     echo -e "\t${CMSG}2${CEND}. uninstall"
     echo -e "\t${CMSG}2${CEND}. uninstall"
     read -p "Please input a number:(Default 1 press Enter) " ACTION
     read -p "Please input a number:(Default 1 press Enter) " ACTION
     [ -z "$ACTION" ] && ACTION=1
     [ -z "$ACTION" ] && ACTION=1
-    if [[ ! $ACTION =~ ^[1,2]$ ]];then
-        echo "${CWARNING}input error! Please only input number 1,2${CEND}"
+    if [[ ! $ACTION =~ ^[1,2]$ ]]; then
+      echo "${CWARNING}input error! Please only input number 1,2${CEND}"
     else
     else
-        break
+      break
     fi
     fi
-done
+  done
 }
 }
 
 
 while :;do
 while :;do
-    printf "
+  printf "
 What Are You Doing?
 What Are You Doing?
 \t${CMSG}1${CEND}. Install/Uninstall PHP opcode cache
 \t${CMSG}1${CEND}. Install/Uninstall PHP opcode cache
 \t${CMSG}2${CEND}. Install/Uninstall ZendGuardLoader/ionCube PHP Extension
 \t${CMSG}2${CEND}. Install/Uninstall ZendGuardLoader/ionCube PHP Extension
@@ -168,265 +167,256 @@ What Are You Doing?
 \t${CMSG}7${CEND}. Install/Uninstall Let's Encrypt client
 \t${CMSG}7${CEND}. Install/Uninstall Let's Encrypt client
 \t${CMSG}q${CEND}. Exit
 \t${CMSG}q${CEND}. Exit
 "
 "
-    read -p "Please input the correct option: " Number
-    if [[ ! $Number =~ ^[1-7,q]$ ]];then
-        echo "${CFAILURE}input error! Please only input 1 ~ 7 and q${CEND}"
-    else
-        case "$Number" in
-        1)
-            ACTION_FUN
-            while :; do echo
-                echo 'Please select a opcode cache of the PHP:'
-                echo -e "\t${CMSG}1${CEND}. Zend OPcache"
-                echo -e "\t${CMSG}2${CEND}. XCache"
-                echo -e "\t${CMSG}3${CEND}. APCU"
-                echo -e "\t${CMSG}4${CEND}. eAccelerator"
-                read -p "Please input a number:(Default 1 press Enter) " PHP_cache
-                [ -z "$PHP_cache" ] && PHP_cache=1
-                if [[ ! $PHP_cache =~ ^[1-4]$ ]];then
-                    echo "${CWARNING}input error! Please only input number 1,2,3,4${CEND}"
-                else
-                    [ $PHP_cache = 1 ] && PHP_extension=opcache
-                    [ $PHP_cache = 2 ] && PHP_extension=xcache
-                    [ $PHP_cache = 3 ] && PHP_extension=apcu
-                    [ $PHP_cache = 4 ] && PHP_extension=eaccelerator
-                    break
-                fi
-            done
-            if [ $ACTION = 1 ];then
-                Check_PHP_Extension
-                if [ -e $php_install_dir/etc/php.d/ext-ZendGuardLoader.ini ];then
-                    echo; echo "${CWARNING}You have to install ZendGuardLoader, You need to uninstall it before install $PHP_extension! ${CEND}"; echo; exit 1
-                else
-                    if [ $PHP_cache = 1 ];then
-                        cd $oneinstack_dir/src
-                        if [[ $PHP_main_version =~ ^5.[3-4]$ ]];then
-                            src_url=https://pecl.php.net/get/zendopcache-${zendopcache_version}.tgz && Download_src
-                            Install_ZendOPcache
-                        elif [ "$PHP_main_version" == '5.5' ];then
-                            src_url=http://www.php.net/distributions/php-$php_5_version.tar.gz && Download_src
-                            tar xzf php-$php_5_version.tar.gz
-                            cd php-$php_5_version/ext/opcache
-                            Install_opcache
-                        elif [ "$PHP_main_version" == '5.6' ];then
-                            src_url=http://www.php.net/distributions/php-$php_6_version.tar.gz && Download_src
-                            tar xzf php-$php_6_version.tar.gz
-                            cd php-$php_6_version/ext/opcache
-                            Install_opcache
-                        elif [ "$PHP_main_version" == '7.0' ];then
-                            src_url=http://www.php.net/distributions/php-$php_7_version.tar.gz && Download_src
-                            tar xzf php-$php_7_version.tar.gz
-                            cd php-$php_7_version/ext/opcache
-                            Install_opcache
-                        fi
-                        Check_succ
-                    elif [ $PHP_cache = 2 ];then
-                        cd $oneinstack_dir/src 
-                        if [[ $PHP_main_version =~ ^5.[3-6]$ ]];then
-                            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
-                            src_url=http://xcache.lighttpd.net/pub/Releases/${xcache_version}/xcache-${xcache_version}.tar.gz && Download_src
-                            Install_XCache
-                            Check_succ
-                        else
-                            echo "${CWARNING}Your php does not support XCache! ${CEND}"; exit 1
-                        fi
-                    elif [ ${PHP_cache} = 3 ];then
-                        cd $oneinstack_dir/src 
-                        if [[ ${PHP_main_version} =~ ^5.[3-6]$ ]];then 
-                            src_url=http://pecl.php.net/get/apcu-${apcu_version}.tgz && Download_src
-                            Install_APCU
-                            Check_succ
-                        elif [[ ${PHP_main_version} =~ ^7.[0-1]$ ]];then
-                            src_url=http://pecl.php.net/get/apcu-${apcu_for_php7_version}.tgz && Download_src
-                            Install_APCU
-                            Check_succ
-                        else
-                            echo "${CWARNING}Your php does not support APCU! ${CEND}"; exit 1
-                        fi
-                    elif [ $PHP_cache = 4 ];then
-                        cd $oneinstack_dir/src 
-                        if [ "$PHP_main_version" == '5.3' ];then
-                            src_url=https://github.com/downloads/eaccelerator/eaccelerator/eaccelerator-${eaccelerator_version}.tar.bz2 && Download_src
-                            Install_eAccelerator-0-9
-                            Check_succ
-                        elif [ "$PHP_main_version" == '5.4' ];then
-                            src_url=https://github.com/eaccelerator/eaccelerator/tarball/master && Download_src
-                            Install_eAccelerator-1-0-dev
-                            Check_succ
-                        else
-                            echo "${CWARNING}Your php does not support eAccelerator! ${CEND}"; exit 1
-                        fi
-                    fi
-                fi
-            else
-                Uninstall_succ
-            fi
-            ;;
-        2)
-            ACTION_FUN
-            while :; do echo
-                echo 'Please select ZendGuardLoader/ionCube:'
-                echo -e "\t${CMSG}1${CEND}. ZendGuardLoader"
-                echo -e "\t${CMSG}2${CEND}. ionCube Loader"
-                read -p "Please input a number:(Default 1 press Enter) " Loader
-                [ -z "$Loader" ] && Loader=1
-                if [[ ! $Loader =~ ^[1,2]$ ]];then
-                    echo "${CWARNING}input error! Please only input number 1,2${CEND}"
-                else
-                    [ $Loader = 1 ] && PHP_extension=ZendGuardLoader
-                    [ $Loader = 2 ] && PHP_extension=0ioncube
-                    break
-                fi
-            done
-            if [ ${ACTION} = "1" ];then
-              Check_PHP_Extension
-              if [ ${Loader} = "1" ]; then
-                if [[ ${PHP_main_version} =~ ^5.[3-6]$ ]] || [ "${armPlatform}" != "y" ]; then
-                  if [ -e ${php_install_dir}/etc/php.d/ext-opcache.ini ]; then
-                    echo; echo "${CWARNING}You have to install OpCache, You need to uninstall it before install ZendGuardLoader! ${CEND}"; echo; exit 1
-                  else
-                    ZendGuardLoader_yn=y && checkDownload
-                    Install_ZendGuardLoader
-                    Check_succ
-                  fi
-                else
-                  echo; echo "${CWARNING}Your php ${PHP_detail_version} or platform ${TARGET_ARCH} does not support ${PHP_extension}! ${CEND}";
-                fi
-              elif [ ${Loader} = "2" ]; then
-                if [[ ${PHP_main_version} =~ ^5.[3-6]$|^7.0$ ]] || [ "${TARGET_ARCH}" != "arm64" ]; then
-                  ionCube_yn=y && checkDownload
-                  Install_ionCube
-                  Restart_PHP; echo "${CSUCCESS}PHP ioncube module installed successfully! ${CEND}";
-                else
-                  echo; echo "${CWARNING}Your php ${PHP_detail_version} or platform ${TARGET_ARCH} does not support ${PHP_extension}! ${CEND}";
-                fi
-              fi
-            else
-              Uninstall_succ
+  read -p "Please input the correct option: " Number
+  if [[ ! $Number =~ ^[1-7,q]$ ]]; then
+    echo "${CFAILURE}input error! Please only input 1 ~ 7 and q${CEND}"
+  else
+    case "$Number" in
+    1)
+      ACTION_FUN
+      while :; do echo
+        echo 'Please select a opcode cache of the PHP:'
+        echo -e "\t${CMSG}1${CEND}. Zend OPcache"
+        echo -e "\t${CMSG}2${CEND}. XCache"
+        echo -e "\t${CMSG}3${CEND}. APCU"
+        echo -e "\t${CMSG}4${CEND}. eAccelerator"
+        read -p "Please input a number:(Default 1 press Enter) " PHP_cache
+        [ -z "$PHP_cache" ] && PHP_cache=1
+        if [[ ! $PHP_cache =~ ^[1-4]$ ]]; then
+          echo "${CWARNING}input error! Please only input number 1,2,3,4${CEND}"
+        else
+          [ $PHP_cache = 1 ] && PHP_extension=opcache
+          [ $PHP_cache = 2 ] && PHP_extension=xcache
+          [ $PHP_cache = 3 ] && PHP_extension=apcu
+          [ $PHP_cache = 4 ] && PHP_extension=eaccelerator
+          break
+        fi
+      done
+      if [ $ACTION = 1 ]; then
+        Check_PHP_Extension
+        if [ -e $php_install_dir/etc/php.d/ext-ZendGuardLoader.ini ]; then
+          echo; echo "${CWARNING}You have to install ZendGuardLoader, You need to uninstall it before install $PHP_extension! ${CEND}"; echo; exit 1
+        else
+          if [ $PHP_cache = 1 ]; then
+            pushd $oneinstack_dir/src
+            if [[ $PHP_main_version =~ ^5.[3-4]$ ]]; then
+              src_url=https://pecl.php.net/get/zendopcache-${zendopcache_version}.tgz && Download_src
+              Install_ZendOPcache
+            elif [ "$PHP_main_version" == '5.5' ]; then
+              src_url=http://www.php.net/distributions/php-$php_5_version.tar.gz && Download_src
+              tar xzf php-$php_5_version.tar.gz
+              pushd php-$php_5_version/ext/opcache
+              Install_opcache
+            elif [ "$PHP_main_version" == '5.6' ]; then
+              src_url=http://www.php.net/distributions/php-$php_6_version.tar.gz && Download_src
+              tar xzf php-$php_6_version.tar.gz
+              pushd php-$php_6_version/ext/opcache
+              Install_opcache
+            elif [ "$PHP_main_version" == '7.0' ]; then
+              src_url=http://www.php.net/distributions/php-$php_7_version.tar.gz && Download_src
+              tar xzf php-$php_7_version.tar.gz
+              pushd php-$php_7_version/ext/opcache
+              Install_opcache
             fi
             fi
-            ;;
-        3)
-            ACTION_FUN
-            while :; do echo
-                echo 'Please select ImageMagick/GraphicsMagick:'
-                echo -e "\t${CMSG}1${CEND}. ImageMagick"
-                echo -e "\t${CMSG}2${CEND}. GraphicsMagick"
-                read -p "Please input a number:(Default 1 press Enter) " Magick
-                [ -z "$Magick" ] && Magick=1
-                if [[ ! $Magick =~ ^[1,2]$ ]];then
-                    echo "${CWARNING}input error! Please only input number 1,2${CEND}"
-                else
-                    [ $Magick = 1 ] && PHP_extension=imagick
-                    [ $Magick = 2 ] && PHP_extension=gmagick
-                    break
-                fi
-            done
-            if [ $ACTION = 1 ];then
-                Check_PHP_Extension
-                Magick_yn=y && checkDownload
-                if [ $Magick = 1 ];then
-                    [ ! -d "/usr/local/imagemagick" ] && Install_ImageMagick
-                    Install_php-imagick
-                    Check_succ
-                elif [ $Magick = 2 ];then
-                    [ ! -d "/usr/local/graphicsmagick" ] && Install_GraphicsMagick
-                    Install_php-gmagick
-                    Check_succ
-                fi
+            Check_succ
+          elif [ $PHP_cache = 2 ]; then
+            pushd $oneinstack_dir/src 
+            if [[ $PHP_main_version =~ ^5.[3-6]$ ]]; then
+              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
+              checkDownload 
+              Install_XCache
+              Check_succ
             else
             else
-                Uninstall_succ
-                [ -d "/usr/local/imagemagick" ] && rm -rf /usr/local/imagemagick
-                [ -d "/usr/local/graphicsmagick" ] && rm -rf /usr/local/graphicsmagick
+              echo "${CWARNING}Your php does not support XCache! ${CEND}"; exit 1
             fi
             fi
-            ;;
-        4)
-            ACTION_FUN
-            PHP_extension=fileinfo
-            if [ $ACTION = 1 ];then
-                Check_PHP_Extension
-                cd $oneinstack_dir/src
-                src_url=http://www.php.net/distributions/php-$PHP_detail_version.tar.gz && Download_src
-                tar xzf php-$PHP_detail_version.tar.gz
-                cd php-$PHP_detail_version/ext/fileinfo
-                $php_install_dir/bin/phpize
-                ./configure --with-php-config=$php_install_dir/bin/php-config
-                make -j ${THREAD} && make install
-                echo 'extension=fileinfo.so' > $php_install_dir/etc/php.d/ext-fileinfo.ini
-                Check_succ
+          elif [ ${PHP_cache} = 3 ]; then
+            checkDownload
+            Install_APCU
+            Check_succ
+          elif [ $PHP_cache = 4 ]; then
+            if [ "$PHP_main_version" == '5.3' ]; then
+              checkDownload
+              Install_eAccelerator-0-9
+              Check_succ
+            elif [ "$PHP_main_version" == '5.4' ]; then
+              checkDownload
+              Install_eAccelerator-1-0-dev
+              Check_succ
             else
             else
-                Uninstall_succ
+              echo "${CWARNING}Your php does not support eAccelerator! ${CEND}"; exit 1
             fi
             fi
-            ;;
-        5)
-            ACTION_FUN
-            while :; do echo
-                echo 'Please select memcache/memcached PHP Extension:'
-                echo -e "\t${CMSG}1${CEND}. memcache PHP Extension"
-                echo -e "\t${CMSG}2${CEND}. memcached PHP Extension"
-                echo -e "\t${CMSG}3${CEND}. memcache/memcached PHP Extension"
-                read -p "Please input a number:(Default 1 press Enter) " Memcache
-                [ -z "$Memcache" ] && Memcache=1
-                if [[ ! $Memcache =~ ^[1-3]$ ]];then
-                    echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
-                else
-                    [ $Memcache = 1 ] && PHP_extension=memcache
-                    [ $Memcache = 2 ] && PHP_extension=memcached
-                    break
-                fi
-            done
-            if [ $ACTION = 1 ];then
-                memcached_yn=y && checkDownload
-                if [ $Memcache = 1 ];then
-                    [ ! -d "$memcached_install_dir/include/memcached" ] && Install_memcached
-                    Check_PHP_Extension
-                    Install_php-memcache
-                    Check_succ
-                elif [ $Memcache = 2 ];then
-                    [ ! -d "$memcached_install_dir/include/memcached" ] && Install_memcached
-                    Check_PHP_Extension
-                    Install_php-memcached
-                    Check_succ
-                elif [ $Memcache = 3 ];then
-                    [ ! -d "$memcached_install_dir/include/memcached" ] && Install_memcached
-                    PHP_extension=memcache && Check_PHP_Extension
-                    Install_php-memcache
-                    PHP_extension=memcached && Check_PHP_Extension
-                    Install_php-memcached
-                    [ -f "${phpExtensionDir}/memcache.so" -a "${phpExtensionDir}/memcached.so" ] && { Restart_PHP; echo;echo "${CSUCCESS}PHP memcache/memcached module installed successfully! ${CEND}"; }
-                fi
+          fi
+        fi
+      else
+        Uninstall_succ
+      fi
+      ;;
+    2)
+      ACTION_FUN
+      while :; do echo
+        echo 'Please select ZendGuardLoader/ionCube:'
+        echo -e "\t${CMSG}1${CEND}. ZendGuardLoader"
+        echo -e "\t${CMSG}2${CEND}. ionCube Loader"
+        read -p "Please input a number:(Default 1 press Enter) " Loader
+        [ -z "$Loader" ] && Loader=1
+        if [[ ! $Loader =~ ^[1,2]$ ]]; then
+          echo "${CWARNING}input error! Please only input number 1,2${CEND}"
+        else
+          [ $Loader = 1 ] && PHP_extension=ZendGuardLoader
+          [ $Loader = 2 ] && PHP_extension=0ioncube
+          break
+        fi
+      done
+      if [ ${ACTION} = "1" ]; then
+        Check_PHP_Extension
+        if [ ${Loader} = "1" ]; then
+          if [[ ${PHP_main_version} =~ ^5.[3-6]$ ]] && [ "${armPlatform}" != "y" ]; then
+            if [ -e ${php_install_dir}/etc/php.d/ext-opcache.ini ]; then
+              echo; echo "${CWARNING}You have to install OpCache, You need to uninstall it before install ZendGuardLoader! ${CEND}"; echo; exit 1
             else
             else
-                PHP_extension=memcache && Uninstall_succ
-                PHP_extension=memcached && Uninstall_succ
-                [ -e "$memcached_install_dir" ] && { service memcached stop > /dev/null 2>&1; rm -rf $memcached_install_dir /etc/init.d/memcached /usr/bin/memcached; }
+              ZendGuardLoader_yn=y && checkDownload
+              Install_ZendGuardLoader
+              Check_succ
             fi
             fi
-            ;;
-        6)
-            ACTION_FUN
-            PHP_extension=redis
-            redis_yn=y && checkDownload
-            if [ $ACTION = 1 ];then
-                [ ! -d "$redis_install_dir" ] && Install_redis-server
-                Check_PHP_Extension
-                Install_php-redis
-            else
-                Uninstall_succ
-                [ -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-*; }
-            fi
-            ;;
-        7)
-            ACTION_FUN
-            if [ $ACTION = 1 ];then
-                Install_letsencrypt
-            else
-                Uninstall_letsencrypt
-            fi
-            ;;
-        q)
-            exit
-            ;;
-        esac
-    fi
+          else
+            echo; echo "${CWARNING}Your php ${PHP_detail_version} or platform arm does not support ${PHP_extension}! ${CEND}";
+          fi
+        elif [ ${Loader} = "2" ]; then
+          if [[ ${PHP_main_version} =~ ^5.[3-6]$|^7.0$ ]] && [ "${TARGET_ARCH}" != "arm64" ]; then
+            ionCube_yn=y && checkDownload
+            Install_ionCube
+            Restart_PHP; echo "${CSUCCESS}PHP ioncube module installed successfully! ${CEND}";
+          else
+            echo; echo "${CWARNING}Your php ${PHP_detail_version} or platform arm64 does not support ${PHP_extension}! ${CEND}";
+          fi
+        fi
+      else
+        Uninstall_succ
+      fi
+      ;;
+    3)
+      ACTION_FUN
+      while :; do echo
+        echo 'Please select ImageMagick/GraphicsMagick:'
+        echo -e "\t${CMSG}1${CEND}. ImageMagick"
+        echo -e "\t${CMSG}2${CEND}. GraphicsMagick"
+        read -p "Please input a number:(Default 1 press Enter) " Magick
+        [ -z "$Magick" ] && Magick=1
+        if [[ ! $Magick =~ ^[1,2]$ ]]; then
+          echo "${CWARNING}input error! Please only input number 1,2${CEND}"
+        else
+          [ $Magick = 1 ] && PHP_extension=imagick
+          [ $Magick = 2 ] && PHP_extension=gmagick
+          break
+        fi
+      done
+      if [ $ACTION = 1 ]; then
+        Check_PHP_Extension
+        Magick_yn=y && checkDownload
+        if [ $Magick = 1 ]; then
+          [ ! -d "/usr/local/imagemagick" ] && Install_ImageMagick
+          Install_php-imagick
+          Check_succ
+        elif [ $Magick = 2 ]; then
+          [ ! -d "/usr/local/graphicsmagick" ] && Install_GraphicsMagick
+          Install_php-gmagick
+          Check_succ
+        fi
+      else
+        Uninstall_succ
+        [ -d "/usr/local/imagemagick" ] && rm -rf /usr/local/imagemagick
+        [ -d "/usr/local/graphicsmagick" ] && rm -rf /usr/local/graphicsmagick
+      fi
+      ;;
+    4)
+      ACTION_FUN
+      PHP_extension=fileinfo
+      if [ $ACTION = 1 ]; then
+        Check_PHP_Extension
+        pushd $oneinstack_dir/src
+        src_url=http://www.php.net/distributions/php-$PHP_detail_version.tar.gz && Download_src
+        tar xzf php-$PHP_detail_version.tar.gz
+        pushd php-$PHP_detail_version/ext/fileinfo
+        $php_install_dir/bin/phpize
+        ./configure --with-php-config=$php_install_dir/bin/php-config
+        make -j ${THREAD} && make install
+        echo 'extension=fileinfo.so' > $php_install_dir/etc/php.d/ext-fileinfo.ini
+        Check_succ
+      else
+        Uninstall_succ
+      fi
+      ;;
+    5)
+      ACTION_FUN
+      while :; do echo
+        echo 'Please select memcache/memcached PHP Extension:'
+        echo -e "\t${CMSG}1${CEND}. memcache PHP Extension"
+        echo -e "\t${CMSG}2${CEND}. memcached PHP Extension"
+        echo -e "\t${CMSG}3${CEND}. memcache/memcached PHP Extension"
+        read -p "Please input a number:(Default 1 press Enter) " Memcache
+        [ -z "$Memcache" ] && Memcache=1
+        if [[ ! $Memcache =~ ^[1-3]$ ]]; then
+          echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
+        else
+          [ $Memcache = 1 ] && PHP_extension=memcache
+          [ $Memcache = 2 ] && PHP_extension=memcached
+          break
+        fi
+      done
+      if [ $ACTION = 1 ]; then
+        if [ $Memcache = 1 ]; then
+          Check_PHP_Extension
+          memcached_yn=y && checkDownload
+          [ ! -d "$memcached_install_dir/include/memcached" ] && Install_memcached
+          Install_php-memcache
+          Check_succ
+        elif [ $Memcache = 2 ]; then
+          Check_PHP_Extension
+          memcached_yn=y && checkDownload
+          [ ! -d "$memcached_install_dir/include/memcached" ] && Install_memcached
+          Install_php-memcached
+          Check_succ
+        elif [ $Memcache = 3 ]; then
+          PHP_extension=memcache && Check_PHP_Extension
+          PHP_extension=memcached && Check_PHP_Extension
+          memcached_yn=y && checkDownload
+          [ ! -d "$memcached_install_dir/include/memcached" ] && Install_memcached
+          Install_php-memcache
+          Install_php-memcached
+          [ -f "${phpExtensionDir}/memcache.so" -a "${phpExtensionDir}/memcached.so" ] && { Restart_PHP; echo;echo "${CSUCCESS}PHP memcache/memcached module installed successfully! ${CEND}"; }
+        fi
+      else
+        PHP_extension=memcache && Uninstall_succ
+        PHP_extension=memcached && Uninstall_succ
+        [ -e "$memcached_install_dir" ] && { service memcached stop > /dev/null 2>&1; rm -rf $memcached_install_dir /etc/init.d/memcached /usr/bin/memcached; }
+      fi
+      ;;
+    6)
+      ACTION_FUN
+      if [ $ACTION = 1 ]; then
+        PHP_extension=redis && Check_PHP_Extension
+        redis_yn=y && checkDownload
+        [ ! -d "$redis_install_dir" ] && Install_redis-server
+        Install_php-redis
+      else
+        Uninstall_succ
+        [ -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-*; }
+      fi
+      ;;
+    7)
+      ACTION_FUN
+      if [ $ACTION = 1 ]; then
+        Install_letsencrypt
+      else
+        Uninstall_letsencrypt
+      fi
+      ;;
+    q)
+      exit
+      ;;
+    esac
+  fi
 done
 done

+ 44 - 44
backup.sh

@@ -8,62 +8,62 @@
 #       https://oneinstack.com
 #       https://oneinstack.com
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
-cd tools
+pushd tools > /dev/null
 . ../options.conf
 . ../options.conf
 
 
 DB_Local_BK() {
 DB_Local_BK() {
-    for D in `echo $db_name | tr ',' ' '`
-    do
-        ./db_bk.sh $D
-    done
+  for D in `echo $db_name | tr ',' ' '`
+  do
+    ./db_bk.sh $D
+  done
 }
 }
 
 
 DB_Remote_BK() {
 DB_Remote_BK() {
-    for D in `echo $db_name | tr ',' ' '`
-    do
-        ./db_bk.sh $D
-        DB_GREP="DB_${D}_`date +%Y`"
-        DB_FILE=`ls -lrt $backup_dir | grep ${DB_GREP} | tail -1 | awk '{print $NF}'`
-        echo "file:::$backup_dir/$DB_FILE $backup_dir push" >> config_bakcup.txt
-        echo "com:::[ -e "$backup_dir/$DB_FILE" ] && rm -rf $backup_dir/DB_${D}_$(date +%Y%m%d --date="$expired_days days ago")_*.tgz" >> config_bakcup.txt
-    done
+  for D in `echo $db_name | tr ',' ' '`
+  do
+    ./db_bk.sh $D
+    DB_GREP="DB_${D}_`date +%Y`"
+    DB_FILE=`ls -lrt $backup_dir | grep ${DB_GREP} | tail -1 | awk '{print $NF}'`
+    echo "file:::$backup_dir/$DB_FILE $backup_dir push" >> config_bakcup.txt
+    echo "com:::[ -e "$backup_dir/$DB_FILE" ] && rm -rf $backup_dir/DB_${D}_$(date +%Y%m%d --date="$expired_days days ago")_*.tgz" >> config_bakcup.txt
+  done
 }
 }
 
 
 WEB_Local_BK() {
 WEB_Local_BK() {
-    for W in `echo $website_name | tr ',' ' '`
-    do
-        ./website_bk.sh $W
-    done
+  for W in `echo $website_name | tr ',' ' '`
+  do
+    ./website_bk.sh $W
+  done
 }
 }
 
 
 WEB_Remote_BK() {
 WEB_Remote_BK() {
-    for W in `echo $website_name | tr ',' ' '`
-    do
-        if [ `du -sm "$wwwroot_dir/$WebSite" | awk '{print $1}'` -lt 1024 ];then
-            ./website_bk.sh $W
-            Web_GREP="Web_${W}_`date +%Y`"
-            Web_FILE=`ls -lrt $backup_dir | grep ${Web_GREP} | tail -1 | awk '{print $NF}'`
-            echo "file:::$backup_dir/$Web_FILE $backup_dir push" >> config_bakcup.txt
-            echo "com:::[ -e "$backup_dir/$Web_FILE" ] && rm -rf $backup_dir/Web_${W}_$(date +%Y%m%d --date="$expired_days days ago")_*.tgz" >> config_bakcup.txt
-        else
-            echo "file:::$wwwroot_dir/$W $backup_dir push" >> config_bakcup.txt
-        fi
-    done
+  for W in `echo $website_name | tr ',' ' '`
+  do
+    if [ `du -sm "$wwwroot_dir/$WebSite" | awk '{print $1}'` -lt 1024 ]; then
+      ./website_bk.sh $W
+      Web_GREP="Web_${W}_`date +%Y`"
+      Web_FILE=`ls -lrt $backup_dir | grep ${Web_GREP} | tail -1 | awk '{print $NF}'`
+      echo "file:::$backup_dir/$Web_FILE $backup_dir push" >> config_bakcup.txt
+      echo "com:::[ -e "$backup_dir/$Web_FILE" ] && rm -rf $backup_dir/Web_${W}_$(date +%Y%m%d --date="$expired_days days ago")_*.tgz" >> config_bakcup.txt
+    else
+      echo "file:::$wwwroot_dir/$W $backup_dir push" >> config_bakcup.txt
+    fi
+  done
 }
 }
 
 
-if [ "$backup_destination" == 'local' ];then
-    [ -n "`echo $backup_content | grep -ow db`" ] && DB_Local_BK
-    [ -n "`echo $backup_content | grep -ow web`" ] && WEB_Local_BK
-elif [ "$backup_destination" == 'remote' ];then
-    echo "com:::[ ! -e "$backup_dir" ] && mkdir -p $backup_dir" > config_bakcup.txt
-    [ -n "`echo $backup_content | grep -ow db`" ] && DB_Remote_BK
-    [ -n "`echo $backup_content | grep -ow web`" ] && WEB_Remote_BK
-    ./mabs.sh -c config_bakcup.txt -T -1 | tee mabs.log
-elif [ "$backup_destination" == 'local,remote' ];then
-    echo "com:::[ ! -e "$backup_dir" ] && mkdir -p $backup_dir" > config_bakcup.txt
-    [ -n "`echo $backup_content | grep -ow db`" ] && DB_Local_BK
-    [ -n "`echo $backup_content | grep -ow web`" ] && WEB_Local_BK
-    [ -n "`echo $backup_content | grep -ow db`" ] && DB_Remote_BK
-    [ -n "`echo $backup_content | grep -ow web`" ] && WEB_Remote_BK
-    ./mabs.sh -c config_bakcup.txt -T -1 | tee mabs.log
+if [ "$backup_destination" == 'local' ]; then
+  [ -n "`echo $backup_content | grep -ow db`" ] && DB_Local_BK
+  [ -n "`echo $backup_content | grep -ow web`" ] && WEB_Local_BK
+elif [ "$backup_destination" == 'remote' ]; then
+  echo "com:::[ ! -e "$backup_dir" ] && mkdir -p $backup_dir" > config_bakcup.txt
+  [ -n "`echo $backup_content | grep -ow db`" ] && DB_Remote_BK
+  [ -n "`echo $backup_content | grep -ow web`" ] && WEB_Remote_BK
+  ./mabs.sh -c config_bakcup.txt -T -1 | tee mabs.log
+elif [ "$backup_destination" == 'local,remote' ]; then
+  echo "com:::[ ! -e "$backup_dir" ] && mkdir -p $backup_dir" > config_bakcup.txt
+  [ -n "`echo $backup_content | grep -ow db`" ] && DB_Local_BK
+  [ -n "`echo $backup_content | grep -ow web`" ] && WEB_Local_BK
+  [ -n "`echo $backup_content | grep -ow db`" ] && DB_Remote_BK
+  [ -n "`echo $backup_content | grep -ow web`" ] && WEB_Remote_BK
+  ./mabs.sh -c config_bakcup.txt -T -1 | tee mabs.log
 fi
 fi

+ 92 - 92
backup_setup.sh

@@ -26,17 +26,17 @@ printf "
 [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
 [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
 
 
 while :; do echo
 while :; do echo
-    echo 'Please select your backup destination:'
-    echo -e "\t${CMSG}1${CEND}. Only Localhost"
-    echo -e "\t${CMSG}2${CEND}. Only Remote host"
-    echo -e "\t${CMSG}3${CEND}. Localhost and Remote host"
-    read -p "Please input a number:(Default 1 press Enter) " DESC_BK
-    [ -z "$DESC_BK" ] && DESC_BK=1
-    if [[ ! $DESC_BK =~ ^[1-3]$ ]];then
-        echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
-    else
-        break
-    fi
+  echo 'Please select your backup destination:'
+  echo -e "\t${CMSG}1${CEND}. Only Localhost"
+  echo -e "\t${CMSG}2${CEND}. Only Remote host"
+  echo -e "\t${CMSG}3${CEND}. Localhost and Remote host"
+  read -p "Please input a number:(Default 1 press Enter) " DESC_BK
+  [ -z "$DESC_BK" ] && DESC_BK=1
+  if [[ ! $DESC_BK =~ ^[1-3]$ ]]; then
+    echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
+  else
+    break
+  fi
 done
 done
 
 
 [ "$DESC_BK" == '1' ] && sed -i 's@^backup_destination=.*@backup_destination=local@' ./options.conf
 [ "$DESC_BK" == '1' ] && sed -i 's@^backup_destination=.*@backup_destination=local@' ./options.conf
@@ -44,17 +44,17 @@ done
 [ "$DESC_BK" == '3' ] && sed -i 's@^backup_destination=.*@backup_destination=local,remote@' ./options.conf
 [ "$DESC_BK" == '3' ] && sed -i 's@^backup_destination=.*@backup_destination=local,remote@' ./options.conf
 
 
 while :; do echo
 while :; do echo
-    echo 'Please select your backup content:'
-    echo -e "\t${CMSG}1${CEND}. Only Database"
-    echo -e "\t${CMSG}2${CEND}. Only Website"
-    echo -e "\t${CMSG}3${CEND}. Database and Website"
-    read -p "Please input a number:(Default 1 press Enter) " CONTENT_BK
-    [ -z "$CONTENT_BK" ] && CONTENT_BK=1
-    if [[ ! $CONTENT_BK =~ ^[1-3]$ ]];then
-        echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
-    else
-        break
-    fi
+  echo 'Please select your backup content:'
+  echo -e "\t${CMSG}1${CEND}. Only Database"
+  echo -e "\t${CMSG}2${CEND}. Only Website"
+  echo -e "\t${CMSG}3${CEND}. Database and Website"
+  read -p "Please input a number:(Default 1 press Enter) " CONTENT_BK
+  [ -z "$CONTENT_BK" ] && CONTENT_BK=1
+  if [[ ! $CONTENT_BK =~ ^[1-3]$ ]]; then
+    echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
+  else
+    break
+  fi
 done
 done
 
 
 [ "$CONTENT_BK" == '1' ] && sed -i 's@^backup_content=.*@backup_content=db@' ./options.conf
 [ "$CONTENT_BK" == '1' ] && sed -i 's@^backup_content=.*@backup_content=db@' ./options.conf
@@ -62,57 +62,57 @@ done
 [ "$CONTENT_BK" == '3' ] && sed -i 's@^backup_content=.*@backup_content=db,web@' ./options.conf
 [ "$CONTENT_BK" == '3' ] && sed -i 's@^backup_content=.*@backup_content=db,web@' ./options.conf
 
 
 while :; do echo
 while :; do echo
-    echo "Please enter the directory for save the backup file: "
-    read -p "(Default directory: $backup_dir): " NEW_backup_dir
-    [ -z "$NEW_backup_dir" ] && NEW_backup_dir="$backup_dir"
-    if [ -z "`echo $NEW_backup_dir| grep '^/'`" ]; then
-        echo "${CWARNING}input error! ${CEND}"
-    else
-        break
-    fi
+  echo "Please enter the directory for save the backup file: "
+  read -p "(Default directory: $backup_dir): " NEW_backup_dir
+  [ -z "$NEW_backup_dir" ] && NEW_backup_dir="$backup_dir"
+  if [ -z "`echo $NEW_backup_dir| grep '^/'`" ]; then
+    echo "${CWARNING}input error! ${CEND}"
+  else
+    break
+  fi
 done
 done
 sed -i "s@^backup_dir=.*@backup_dir=$NEW_backup_dir@" ./options.conf
 sed -i "s@^backup_dir=.*@backup_dir=$NEW_backup_dir@" ./options.conf
 
 
 while :; do echo
 while :; do echo
-    echo "Pleas enter a valid backup number of days: "
-    read -p "(Default days: 5): " expired_days
-    [ -z "$expired_days" ] && expired_days=5
-    [ -n "`echo $expired_days | sed -n "/^[0-9]\+$/p"`" ] && break || echo "${CWARNING}input error! Please only enter numbers! ${CEND}"
+  echo "Pleas enter a valid backup number of days: "
+  read -p "(Default days: 5): " expired_days
+  [ -z "$expired_days" ] && expired_days=5
+  [ -n "`echo $expired_days | sed -n "/^[0-9]\+$/p"`" ] && break || echo "${CWARNING}input error! Please only enter numbers! ${CEND}"
 done
 done
 sed -i "s@^expired_days=.*@expired_days=$expired_days@" ./options.conf
 sed -i "s@^expired_days=.*@expired_days=$expired_days@" ./options.conf
 
 
-if [ "$CONTENT_BK" != '2' ];then
-    databases=`$db_install_dir/bin/mysql -uroot -p$dbrootpwd -e "show databases\G" | grep Database | awk '{print $2}' | grep -Evw "(performance_schema|information_schema|mysql|sys)"`
-    while :; do echo
-        echo "Please enter one or more name for database, separate multiple database names with commas: "
-        read -p "(Default database: `echo $databases | tr ' ' ','`) " db_name
-        db_name=`echo $db_name | tr -d ' '`
-        [ -z "$db_name" ] && db_name="`echo $databases | tr ' ' ','`"
-        D_tmp=0
-        for D in `echo $db_name | tr ',' ' '`
-        do
-            [ -z "`echo $databases | grep -w $D`" ] && { echo "${CWARNING}$D was not exist! ${CEND}" ; D_tmp=1; }
-        done
-        [ "$D_tmp" != '1' ] && break
+if [ "$CONTENT_BK" != '2' ]; then
+  databases=`$db_install_dir/bin/mysql -uroot -p$dbrootpwd -e "show databases\G" | grep Database | awk '{print $2}' | grep -Evw "(performance_schema|information_schema|mysql|sys)"`
+  while :; do echo
+    echo "Please enter one or more name for database, separate multiple database names with commas: "
+    read -p "(Default database: `echo $databases | tr ' ' ','`) " db_name
+    db_name=`echo $db_name | tr -d ' '`
+    [ -z "$db_name" ] && db_name="`echo $databases | tr ' ' ','`"
+    D_tmp=0
+    for D in `echo $db_name | tr ',' ' '`
+    do
+      [ -z "`echo $databases | grep -w $D`" ] && { echo "${CWARNING}$D was not exist! ${CEND}" ; D_tmp=1; }
     done
     done
-    sed -i "s@^db_name=.*@db_name=$db_name@" ./options.conf
+    [ "$D_tmp" != '1' ] && break
+  done
+  sed -i "s@^db_name=.*@db_name=$db_name@" ./options.conf
 fi
 fi
 
 
-if [ "$CONTENT_BK" != '1' ];then
-    websites=`ls $wwwroot_dir | grep -vw default`
-    while :; do echo
-        echo "Please enter one or more name for website, separate multiple website names with commas: "
-        read -p "(Default website: `echo $websites | tr ' ' ','`) " website_name
-        website_name=`echo $website_name | tr -d ' '`
-        [ -z "$website_name" ] && website_name="`echo $websites | tr ' ' ','`"
-        W_tmp=0
-        for W in `echo $website_name | tr ',' ' '`
-        do
-            [ ! -e "$wwwroot_dir/$W" ] && { echo "${CWARNING}$wwwroot_dir/$W not exist! ${CEND}" ; W_tmp=1; }
-        done
-        [ "$W_tmp" != '1' ] && break
+if [ "$CONTENT_BK" != '1' ]; then
+  websites=`ls $wwwroot_dir | grep -vw default`
+  while :; do echo
+    echo "Please enter one or more name for website, separate multiple website names with commas: "
+    read -p "(Default website: `echo $websites | tr ' ' ','`) " website_name
+    website_name=`echo $website_name | tr -d ' '`
+    [ -z "$website_name" ] && website_name="`echo $websites | tr ' ' ','`"
+    W_tmp=0
+    for W in `echo $website_name | tr ',' ' '`
+    do
+      [ ! -e "$wwwroot_dir/$W" ] && { echo "${CWARNING}$wwwroot_dir/$W not exist! ${CEND}" ; W_tmp=1; }
     done
     done
-    sed -i "s@^website_name=.*@website_name=$website_name@" ./options.conf
+    [ "$W_tmp" != '1' ] && break
+  done
+  sed -i "s@^website_name=.*@website_name=$website_name@" ./options.conf
 fi
 fi
 
 
 echo
 echo
@@ -120,35 +120,35 @@ echo "You have to backup the content:"
 [ "$CONTENT_BK" != '2' ] && echo "Database: ${CMSG}$db_name${CEND}"
 [ "$CONTENT_BK" != '2' ] && echo "Database: ${CMSG}$db_name${CEND}"
 [ "$CONTENT_BK" != '1' ] && echo "Website: ${CMSG}$website_name${CEND}"
 [ "$CONTENT_BK" != '1' ] && echo "Website: ${CMSG}$website_name${CEND}"
 
 
-if [[ "$DESC_BK" =~ ^[2,3]$ ]];then
-    > tools/iplist.txt
-    while :; do echo
-        read -p "Please enter the remote host ip: " remote_ip
-        [ -z "$remote_ip" -o "$remote_ip" == '127.0.0.1' ] && continue
-        echo
-        read -p "Please enter the remote host port(Default: 22) : " remote_port
-        [ -z "$remote_port" ] && remote_port=22
-        echo
-        read -p "Please enter the remote host user(Default: root) : " remote_user
-        [ -z "$remote_user" ] && remote_user=root
-        echo
-        read -p "Please enter the remote host password: " remote_password
-        IPcode=$(echo "ibase=16;$(echo "$remote_ip" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
-        Portcode=$(echo "ibase=16;$(echo "$remote_port" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
-        PWcode=$(echo "ibase=16;$(echo "$remote_password" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
-        [ -e "~/.ssh/known_hosts" ] && grep $remote_ip ~/.ssh/known_hosts | sed -i "/$remote_ip/d" ~/.ssh/known_hosts
-        ./tools/mssh.exp ${IPcode}P $remote_user ${PWcode}P ${Portcode}P true 10
-        if [ $? -eq 0 ];then
-            [ -z "`grep $remote_ip tools/iplist.txt`" ] && echo "$remote_ip $remote_port $remote_user $remote_password" >> tools/iplist.txt || echo "${CWARNING}$remote_ip has been added! ${CEND}"
-            while :; do
-                read -p "Do you want to add more host ? [y/n]: " more_host_yn
-                if [[ ! "$more_host_yn" =~ ^[y,n]$ ]];then
-                    echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
-                else
-                    break
-                fi
-            done
-            [ "$more_host_yn" == 'n' ] && break
+if [[ "$DESC_BK" =~ ^[2,3]$ ]]; then
+  > tools/iplist.txt
+  while :; do echo
+    read -p "Please enter the remote host ip: " remote_ip
+    [ -z "$remote_ip" -o "$remote_ip" == '127.0.0.1' ] && continue
+    echo
+    read -p "Please enter the remote host port(Default: 22) : " remote_port
+    [ -z "$remote_port" ] && remote_port=22
+    echo
+    read -p "Please enter the remote host user(Default: root) : " remote_user
+    [ -z "$remote_user" ] && remote_user=root
+    echo
+    read -p "Please enter the remote host password: " remote_password
+    IPcode=$(echo "ibase=16;$(echo "$remote_ip" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
+    Portcode=$(echo "ibase=16;$(echo "$remote_port" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
+    PWcode=$(echo "ibase=16;$(echo "$remote_password" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
+    [ -e "~/.ssh/known_hosts" ] && grep $remote_ip ~/.ssh/known_hosts | sed -i "/$remote_ip/d" ~/.ssh/known_hosts
+    ./tools/mssh.exp ${IPcode}P $remote_user ${PWcode}P ${Portcode}P true 10
+    if [ $? -eq 0 ]; then
+      [ -z "`grep $remote_ip tools/iplist.txt`" ] && echo "$remote_ip $remote_port $remote_user $remote_password" >> tools/iplist.txt || echo "${CWARNING}$remote_ip has been added! ${CEND}"
+      while :; do
+        read -p "Do you want to add more host ? [y/n]: " more_host_yn
+        if [[ ! "$more_host_yn" =~ ^[y,n]$ ]]; then
+          echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+        else
+          break
         fi
         fi
-    done
+      done
+      [ "$more_host_yn" == 'n' ] && break
+    fi
+  done
 fi
 fi

+ 1 - 1
config/index_cn.html

@@ -28,7 +28,7 @@ font-family:微软雅黑,sans-serif;
 <p><b>创建 FTP 虚拟账号执行脚本:</b>&nbsp;&nbsp;<font color="#008000">./pureftpd_vhost.sh</font></p>
 <p><b>创建 FTP 虚拟账号执行脚本:</b>&nbsp;&nbsp;<font color="#008000">./pureftpd_vhost.sh</font></p>
 <p><b>Github 项目地址:</b>&nbsp;&nbsp;<a target="_blank" class="links" href="https://github.com/lj2007331/oneinstack">https://github.com/lj2007331/oneinstack</a></p>
 <p><b>Github 项目地址:</b>&nbsp;&nbsp;<a target="_blank" class="links" href="https://github.com/lj2007331/oneinstack">https://github.com/lj2007331/oneinstack</a></p>
 <p><b>OneinStack 官网:</b>&nbsp;&nbsp;<a target="_blank" class="links" href="https://oneinstack.com">https://oneinstack.com</a></p>
 <p><b>OneinStack 官网:</b>&nbsp;&nbsp;<a target="_blank" class="links" href="https://oneinstack.com">https://oneinstack.com</a></p>
-<p><b>QQ 群:</b>&nbsp;&nbsp;558540514(付费千人群) 556824757(新) 213014293(满) 486321919(满) 438311066(满) 235258658(满)</p>
+<p><b>QQ 群:</b>&nbsp;&nbsp;558540514(付费千人群) 535783209(新)</p>
 <p><b>赞助我们:</b></p>
 <p><b>赞助我们:</b></p>
 <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;支付宝:&nbsp;&nbsp;lj2007331@gmail.com</p>
 <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;支付宝:&nbsp;&nbsp;lj2007331@gmail.com</p>
 <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PayPal:&nbsp;&nbsp;lj2007331@gmail.com</p>
 <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PayPal:&nbsp;&nbsp;lj2007331@gmail.com</p>

+ 30 - 35
include/GraphicsMagick.sh

@@ -9,44 +9,39 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_GraphicsMagick() {
 Install_GraphicsMagick() {
-    pushd $oneinstack_dir/src
-    tar xzf GraphicsMagick-$GraphicsMagick_version.tar.gz
-    pushd GraphicsMagick-$GraphicsMagick_version
-    ./configure --prefix=/usr/local/graphicsmagick --enable-shared --enable-static
-    make -j ${THREAD} && make install
-    popd
-    rm -rf GraphicsMagick-$GraphicsMagick_version
-    popd
+  pushd ${oneinstack_dir}/src
+  tar xzf GraphicsMagick-${GraphicsMagick_version}.tar.gz
+  pushd GraphicsMagick-${GraphicsMagick_version}
+  ./configure --prefix=/usr/local/graphicsmagick --enable-shared --enable-static
+  make -j ${THREAD} && make install
+  popd
+  rm -rf GraphicsMagick-${GraphicsMagick_version}
+  popd
 }
 }
 
 
 Install_php-gmagick() {
 Install_php-gmagick() {
-    pushd $oneinstack_dir/src
-    phpExtensionDir=`$php_install_dir/bin/php-config --extension-dir`
-    if [ -e "$php_install_dir/bin/phpize" ];then
-        if [ "`$php_install_dir/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}'`" == '7' ];then
-            tar xzf gmagick-2.0.4RC1.tgz
-            pushd gmagick-2.0.4RC1
-        else
-            tar xzf gmagick-$gmagick_version.tgz
-            pushd gmagick-$gmagick_version
-        fi
-        make clean
-        export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
-        $php_install_dir/bin/phpize
-        ./configure --with-php-config=$php_install_dir/bin/php-config --with-gmagick=/usr/local/graphicsmagick
-        make -j ${THREAD} && make install
-        popd
-        rm -rf gmagick-$gmagick_version
-    
-        if [ -f "${phpExtensionDir}/gmagick.so" ];then
-            cat > $php_install_dir/etc/php.d/ext-gmagick.ini << EOF
-[gmagick]
-extension=gmagick.so
-EOF
-            [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
-        else
-            echo "${CFAILURE}PHP gmagick module install failed, Please contact the author! ${CEND}"
-        fi
+  pushd ${oneinstack_dir}/src
+  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
+  if [ -e "${php_install_dir}/bin/phpize" ]; then
+    if [ "`${php_install_dir}/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}'`" == '7' ]; then
+      tar xzf gmagick-${gmagick_for_php7_version}.tgz 
+      pushd gmagick-${gmagick_for_php7_version} 
+    else
+      tar xzf gmagick-${gmagick_version}.tgz
+      pushd gmagick-${gmagick_version}
     fi
     fi
+    export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
+    ${php_install_dir}/bin/phpize
+    ./configure --with-php-config=${php_install_dir}/bin/php-config --with-gmagick=/usr/local/graphicsmagick
+    make -j ${THREAD} && make install
     popd
     popd
+    if [ -f "${phpExtensionDir}/gmagick.so" ]; then
+      echo 'extension=gmagick.so' > ${php_install_dir}/etc/php.d/ext-gmagick.ini
+      echo "${CSUCCESS}PHP gmagick module installed successfully! ${CEND}"
+      rm -rf gmagick-${gmagick_for_php7_version} gmagick-${gmagick_version}
+    else
+      echo "${CFAILURE}PHP gmagick module install failed, Please contact the author! ${CEND}"
+    fi
+  fi
+  popd
 }
 }

+ 30 - 35
include/ImageMagick.sh

@@ -9,44 +9,39 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_ImageMagick() {
 Install_ImageMagick() {
-    pushd $oneinstack_dir/src
-    tar xzf ImageMagick-$ImageMagick_version.tar.gz
-    pushd ImageMagick-$ImageMagick_version
-    ./configure --prefix=/usr/local/imagemagick --enable-shared --enable-static
-    make -j ${THREAD} && make install
-    popd
-    rm -rf ImageMagick-$ImageMagick_version
-    popd
+  pushd ${oneinstack_dir}/src
+  tar xzf ImageMagick-${ImageMagick_version}.tar.gz
+  pushd ImageMagick-${ImageMagick_version}
+  ./configure --prefix=/usr/local/imagemagick --enable-shared --enable-static
+  make -j ${THREAD} && make install
+  popd
+  rm -rf ImageMagick-${ImageMagick_version}
+  popd
 }
 }
 
 
 Install_php-imagick() {
 Install_php-imagick() {
-    pushd $oneinstack_dir/src
-    phpExtensionDir=`$php_install_dir/bin/php-config --extension-dir`
-    if [ -e "$php_install_dir/bin/phpize" ];then
-        if [ "`$php_install_dir/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1"."$2}'`" == '5.3' ];then
-            tar xzf imagick-${imagick_for_php53_version}.tgz
-            pushd imagick-${imagick_for_php53_version}
-        else
-            tar xzf imagick-$imagick_version.tgz
-            pushd imagick-$imagick_version
-        fi
-        make clean
-        export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
-        $php_install_dir/bin/phpize
-        ./configure --with-php-config=$php_install_dir/bin/php-config --with-imagick=/usr/local/imagemagick
-        make -j ${THREAD} && make install
-        popd
-        rm -rf imagick-$imagick_version
-    
-        if [ -f "${phpExtensionDir}/imagick.so" ];then
-            cat > $php_install_dir/etc/php.d/ext-imagick.ini << EOF
-[imagick]
-extension=imagick.so
-EOF
-            [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
-        else
-            echo "${CFAILURE}PHP imagick module install failed, Please contact the author! ${CEND}"
-        fi
+  pushd ${oneinstack_dir}/src
+  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
+  if [ -e "${php_install_dir}/bin/phpize" ]; then
+    if [ "`${php_install_dir}/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1"."$2}'`" == '5.3' ]; then
+      tar xzf imagick-${imagick_for_php53_version}.tgz
+      pushd imagick-${imagick_for_php53_version}
+    else
+      tar xzf imagick-${imagick_version}.tgz
+      pushd imagick-${imagick_version}
     fi
     fi
+    export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
+    ${php_install_dir}/bin/phpize
+    ./configure --with-php-config=${php_install_dir}/bin/php-config --with-imagick=/usr/local/imagemagick
+    make -j ${THREAD} && make install
     popd
     popd
+    if [ -f "${phpExtensionDir}/imagick.so" ]; then
+      echo 'extension=imagick.so' > ${php_install_dir}/etc/php.d/ext-imagick.ini
+      echo "${CSUCCESS}PHP imagick module installed successfully! ${CEND}"
+      rm -rf imagick-${imagick_for_php53_version} imagick-${imagick_version}
+    else
+      echo "${CFAILURE}PHP imagick module install failed, Please contact the author! ${CEND}"
+    fi
+  fi
+  popd
 }
 }

+ 60 - 62
include/ZendGuardLoader.sh

@@ -9,74 +9,72 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_ZendGuardLoader() {
 Install_ZendGuardLoader() {
-    pushd ${oneinstack_dir}/src
-    PHP_detail_version=`$php_install_dir/bin/php -r 'echo PHP_VERSION;'`
-    PHP_main_version=${PHP_detail_version%.*}
-    phpExtensionDir=`$php_install_dir/bin/php-config --extension-dir`
+  pushd ${oneinstack_dir}/src
+  PHP_detail_version=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
+  PHP_main_version=${PHP_detail_version%.*}
+  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
+  [ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir}
+  if [ "$OS_BIT" == '64' ]; then
+    if [ "$PHP_main_version" == '5.6' ]; then
+      tar xzf zend-loader-php5.6-linux-x86_64.tar.gz
+      /bin/cp zend-loader-php5.6-linux-x86_64/ZendGuardLoader.so ${phpExtensionDir}
+      rm -rf zend-loader-php5.6-linux-x86_64
+    fi
+
+    if [ "$PHP_main_version" == '5.5' ]; then
+      tar xzf zend-loader-php5.5-linux-x86_64.tar.gz
+      /bin/cp zend-loader-php5.5-linux-x86_64/ZendGuardLoader.so ${phpExtensionDir}
+      rm -rf zend-loader-php5.5-linux-x86_64
+    fi
+
+    if [ "$PHP_main_version" == '5.4' ]; then
+      tar xzf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz
+      /bin/cp ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/php-5.4.x/ZendGuardLoader.so ${phpExtensionDir}
+      rm -rf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64
+    fi
+
+    if [ "$PHP_main_version" == '5.3' ]; then
+      tar xzf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
+      /bin/cp ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so ${phpExtensionDir}
+      rm -rf ZendGuardLoader-php-5.3-linux-glibc23-x86_64
+    fi
+  else
+    if [ "$PHP_main_version" == '5.6' ]; then
+      tar xzf zend-loader-php5.6-linux-i386.tar.gz
+      /bin/cp zend-loader-php5.6-linux-i386/ZendGuardLoader.so ${phpExtensionDir}
+      rm -rf zend-loader-php5.6-linux-i386
+    fi
+
+    if [ "$PHP_main_version" == '5.5' ]; then
+      tar xzf zend-loader-php5.5-linux-i386.tar.gz
+      /bin/cp zend-loader-php5.5-linux-i386/ZendGuardLoader.so ${phpExtensionDir}
+      rm -rf zend-loader-php5.5-linux-x386
+    fi
 
 
-    [ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir}
-    if [ "$OS_BIT" == '64' ];then
-        if [ "$PHP_main_version" == '5.6' ];then
-            tar xzf zend-loader-php5.6-linux-x86_64.tar.gz
-            /bin/cp zend-loader-php5.6-linux-x86_64/ZendGuardLoader.so ${phpExtensionDir}
-            rm -rf zend-loader-php5.6-linux-x86_64
-        fi
-    
-        if [ "$PHP_main_version" == '5.5' ];then
-            tar xzf zend-loader-php5.5-linux-x86_64.tar.gz
-            /bin/cp zend-loader-php5.5-linux-x86_64/ZendGuardLoader.so ${phpExtensionDir} 
-            rm -rf zend-loader-php5.5-linux-x86_64
-        fi
-    
-        if [ "$PHP_main_version" == '5.4' ];then
-            tar xzf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz
-            /bin/cp ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64/php-5.4.x/ZendGuardLoader.so ${phpExtensionDir} 
-            rm -rf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64
-        fi
-    
-        if [ "$PHP_main_version" == '5.3' ];then
-            tar xzf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
-            /bin/cp ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so ${phpExtensionDir} 
-            rm -rf ZendGuardLoader-php-5.3-linux-glibc23-x86_64
-        fi
-    else
-        if [ "$PHP_main_version" == '5.6' ];then
-            tar xzf zend-loader-php5.6-linux-i386.tar.gz
-            /bin/cp zend-loader-php5.6-linux-i386/ZendGuardLoader.so ${phpExtensionDir} 
-            rm -rf zend-loader-php5.6-linux-i386
-        fi
-    
-        if [ "$PHP_main_version" == '5.5' ];then
-            tar xzf zend-loader-php5.5-linux-i386.tar.gz
-            /bin/cp zend-loader-php5.5-linux-i386/ZendGuardLoader.so ${phpExtensionDir} 
-            rm -rf zend-loader-php5.5-linux-x386
-        fi
-    
-        if [ "$PHP_main_version" == '5.4' ];then
-            tar xzf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386.tar.gz
-            /bin/cp ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386/php-5.4.x/ZendGuardLoader.so ${phpExtensionDir} 
-            rm -rf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386
-        fi
-    
-        if [ "$PHP_main_version" == '5.3' ];then
-            tar xzf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
-            /bin/cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so ${phpExtensionDir} 
-            rm -rf ZendGuardLoader-php-5.3-linux-glibc23-i386
-        fi
+    if [ "$PHP_main_version" == '5.4' ]; then
+      tar xzf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386.tar.gz
+      /bin/cp ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386/php-5.4.x/ZendGuardLoader.so ${phpExtensionDir}
+      rm -rf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386
     fi
     fi
-    
-    if [ -f "${phpExtensionDir}/ZendGuardLoader.so" ];then
-        cat > $php_install_dir/etc/php.d/ext-ZendGuardLoader.ini << EOF
+
+    if [ "$PHP_main_version" == '5.3' ]; then
+      tar xzf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
+      /bin/cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so ${phpExtensionDir}
+      rm -rf ZendGuardLoader-php-5.3-linux-glibc23-i386
+    fi
+  fi
+
+  if [ -f "${phpExtensionDir}/ZendGuardLoader.so" ]; then
+    cat > $php_install_dir/etc/php.d/ext-ZendGuardLoader.ini << EOF
 [Zend Guard Loader]
 [Zend Guard Loader]
 zend_extension=${phpExtensionDir}/ZendGuardLoader.so
 zend_extension=${phpExtensionDir}/ZendGuardLoader.so
 zend_loader.enable=1
 zend_loader.enable=1
 zend_loader.disable_licensing=0
 zend_loader.disable_licensing=0
 zend_loader.obfuscation_level_support=3
 zend_loader.obfuscation_level_support=3
 EOF
 EOF
-        echo "${CSUCCESS}PHP ZendGuardLoader module installed successfully! ${CEND}"
-        [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
-    else
-        echo "${CFAILURE}PHP ZendGuardLoader module install failed, Please contact the author! ${CEND}"
-    fi
-    popd
+    echo "${CSUCCESS}PHP ZendGuardLoader module installed successfully! ${CEND}"
+  else
+    echo "${CFAILURE}PHP ZendGuardLoader module install failed, Please contact the author! ${CEND}"
+  fi
+  popd
 }
 }

+ 46 - 48
include/apache-2.2.sh

@@ -9,59 +9,57 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_Apache-2-2() {
 Install_Apache-2-2() {
-cd $oneinstack_dir/src
-
-id -u $run_user >/dev/null 2>&1
-[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
-
-tar xzf httpd-$apache_2_version.tar.gz
-cd httpd-$apache_2_version
-[ ! -d "$apache_install_dir" ] && mkdir -p $apache_install_dir
-[ "$ZendGuardLoader_yn" == 'y' -o "$ionCube_yn" == 'y' ] && MPM=prefork || MPM=worker
-./configure --prefix=$apache_install_dir --enable-headers --enable-deflate --enable-mime-magic --enable-so --enable-rewrite --enable-ssl --with-ssl --enable-expires --enable-static-support --enable-suexec --disable-userdir --with-included-apr --with-mpm=$MPM --disable-userdir
-make -j ${THREAD} && make install
-if [ -e "$apache_install_dir/conf/httpd.conf" ];then
+  pushd ${oneinstack_dir}/src
+  id -u $run_user >/dev/null 2>&1
+  [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
+  tar xzf httpd-$apache_2_version.tar.gz
+  pushd httpd-$apache_2_version
+  [ ! -d "$apache_install_dir" ] && mkdir -p $apache_install_dir
+  [ "$ZendGuardLoader_yn" == 'y' -o "$ionCube_yn" == 'y' ] && MPM=prefork || MPM=worker
+  ./configure --prefix=$apache_install_dir --enable-headers --enable-deflate --enable-mime-magic --enable-so --enable-rewrite --enable-ssl --with-ssl --enable-expires --enable-static-support --enable-suexec --disable-userdir --with-included-apr --with-mpm=$MPM --disable-userdir
+  make -j ${THREAD} && make install
+  if [ -e "$apache_install_dir/conf/httpd.conf" ]; then
     echo "${CSUCCESS}Apache installed successfully! ${CEND}"
     echo "${CSUCCESS}Apache installed successfully! ${CEND}"
-    cd ..
+    popd
     rm -rf httpd-$apache_2_version
     rm -rf httpd-$apache_2_version
-else
+  else
     rm -rf $apache_install_dir
     rm -rf $apache_install_dir
     echo "${CFAILURE}Apache install failed, Please contact the author! ${CEND}"
     echo "${CFAILURE}Apache install failed, Please contact the author! ${CEND}"
     kill -9 $$
     kill -9 $$
-fi
-
-[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$apache_install_dir/bin:\$PATH" >> /etc/profile
-[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $apache_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$apache_install_dir/bin:\1@" /etc/profile
-. /etc/profile
+  fi
 
 
-/bin/cp $apache_install_dir/bin/apachectl /etc/init.d/httpd
-sed -i '2a # chkconfig: - 85 15' /etc/init.d/httpd
-sed -i '3a # description: Apache is a World Wide Web server. It is used to serve' /etc/init.d/httpd
-chmod +x /etc/init.d/httpd
-[ "$OS" == 'CentOS' ] && { chkconfig --add httpd; chkconfig httpd on; }
-[[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d httpd defaults
-
-sed -i "s@^User daemon@User $run_user@" $apache_install_dir/conf/httpd.conf
-sed -i "s@^Group daemon@Group $run_user@" $apache_install_dir/conf/httpd.conf
-if [ "$Nginx_version" == '4' -a ! -e "$web_install_dir/sbin/nginx" ];then
+  [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$apache_install_dir/bin:\$PATH" >> /etc/profile
+  [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $apache_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$apache_install_dir/bin:\1@" /etc/profile
+  . /etc/profile
+  
+  /bin/cp $apache_install_dir/bin/apachectl /etc/init.d/httpd
+  sed -i '2a # chkconfig: - 85 15' /etc/init.d/httpd
+  sed -i '3a # description: Apache is a World Wide Web server. It is used to serve' /etc/init.d/httpd
+  chmod +x /etc/init.d/httpd
+  [ "$OS" == 'CentOS' ] && { chkconfig --add httpd; chkconfig httpd on; }
+  [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d httpd defaults
+  
+  sed -i "s@^User daemon@User $run_user@" $apache_install_dir/conf/httpd.conf
+  sed -i "s@^Group daemon@Group $run_user@" $apache_install_dir/conf/httpd.conf
+  if [ "$Nginx_version" == '4' -a ! -e "$web_install_dir/sbin/nginx" ]; then
     sed -i 's/^#ServerName www.example.com:80/ServerName 0.0.0.0:80/' $apache_install_dir/conf/httpd.conf
     sed -i 's/^#ServerName www.example.com:80/ServerName 0.0.0.0:80/' $apache_install_dir/conf/httpd.conf
     TMP_PORT=80
     TMP_PORT=80
     TMP_IP=$IPADDR
     TMP_IP=$IPADDR
-elif [[ $Nginx_version =~ ^[1-3]$ ]] || [ -e "$web_install_dir/sbin/nginx" ];then
+  elif [[ $Nginx_version =~ ^[1-3]$ ]] || [ -e "$web_install_dir/sbin/nginx" ]; then
     sed -i 's/^#ServerName www.example.com:80/ServerName 127.0.0.1:88/' $apache_install_dir/conf/httpd.conf
     sed -i 's/^#ServerName www.example.com:80/ServerName 127.0.0.1:88/' $apache_install_dir/conf/httpd.conf
     sed -i 's@^Listen.*@Listen 127.0.0.1:88@' $apache_install_dir/conf/httpd.conf
     sed -i 's@^Listen.*@Listen 127.0.0.1:88@' $apache_install_dir/conf/httpd.conf
     TMP_PORT=88
     TMP_PORT=88
     TMP_IP=127.0.0.1
     TMP_IP=127.0.0.1
-fi
-sed -i "s@AddType\(.*\)Z@AddType\1Z\n    AddType application/x-httpd-php .php .phtml\n    AddType application/x-httpd-php-source .phps@" $apache_install_dir/conf/httpd.conf
-sed -i "s@#AddHandler cgi-script .cgi@AddHandler cgi-script .cgi .pl@" $apache_install_dir/conf/httpd.conf
-sed -i 's@DirectoryIndex index.html@DirectoryIndex index.html index.php@' $apache_install_dir/conf/httpd.conf
-sed -i "s@^DocumentRoot.*@DocumentRoot \"$wwwroot_dir/default\"@" $apache_install_dir/conf/httpd.conf
-sed -i "s@^<Directory \"$apache_install_dir/htdocs\">@<Directory \"$wwwroot_dir/default\">@" $apache_install_dir/conf/httpd.conf
-sed -i "s@^#Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf@" $apache_install_dir/conf/httpd.conf
-
-#logrotate apache log
-cat > /etc/logrotate.d/apache << EOF
+  fi
+  sed -i "s@AddType\(.*\)Z@AddType\1Z\n    AddType application/x-httpd-php .php .phtml\n    AddType application/x-httpd-php-source .phps@" $apache_install_dir/conf/httpd.conf
+  sed -i "s@#AddHandler cgi-script .cgi@AddHandler cgi-script .cgi .pl@" $apache_install_dir/conf/httpd.conf
+  sed -i 's@DirectoryIndex index.html@DirectoryIndex index.html index.php@' $apache_install_dir/conf/httpd.conf
+  sed -i "s@^DocumentRoot.*@DocumentRoot \"$wwwroot_dir/default\"@" $apache_install_dir/conf/httpd.conf
+  sed -i "s@^<Directory \"$apache_install_dir/htdocs\">@<Directory \"$wwwroot_dir/default\">@" $apache_install_dir/conf/httpd.conf
+  sed -i "s@^#Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf@" $apache_install_dir/conf/httpd.conf
+  
+  #logrotate apache log
+  cat > /etc/logrotate.d/apache << EOF
 $wwwlogs_dir/*apache.log {
 $wwwlogs_dir/*apache.log {
 daily
 daily
 rotate 5
 rotate 5
@@ -76,8 +74,8 @@ endscript
 }
 }
 EOF
 EOF
 
 
-mkdir $apache_install_dir/conf/vhost
-cat >> $apache_install_dir/conf/vhost/0.conf << EOF
+  mkdir $apache_install_dir/conf/vhost
+  cat >> $apache_install_dir/conf/vhost/0.conf << EOF
 NameVirtualHost *:$TMP_PORT
 NameVirtualHost *:$TMP_PORT
 <VirtualHost *:$TMP_PORT>
 <VirtualHost *:$TMP_PORT>
     ServerAdmin admin@linuxeye.com
     ServerAdmin admin@linuxeye.com
@@ -102,7 +100,7 @@ NameVirtualHost *:$TMP_PORT
 </VirtualHost>
 </VirtualHost>
 EOF
 EOF
 
 
-cat >> $apache_install_dir/conf/httpd.conf <<EOF
+  cat >> $apache_install_dir/conf/httpd.conf <<EOF
 <IfModule mod_headers.c>
 <IfModule mod_headers.c>
     AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript
     AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript
     <FilesMatch "\.(js|css|html|htm|png|jpg|swf|pdf|shtml|xml|flv|gif|ico|jpeg)\$">
     <FilesMatch "\.(js|css|html|htm|png|jpg|swf|pdf|shtml|xml|flv|gif|ico|jpeg)\$">
@@ -118,7 +116,7 @@ ServerSignature Off
 Include conf/vhost/*.conf
 Include conf/vhost/*.conf
 EOF
 EOF
 
 
-if [ "$Nginx_version" != '4' -o -e "$web_install_dir/sbin/nginx" ];then
+  if [ "$Nginx_version" != '4' -o -e "$web_install_dir/sbin/nginx" ]; then
     $apache_install_dir/bin/apxs -i -c -n mod_remoteip.so mod_remoteip.c
     $apache_install_dir/bin/apxs -i -c -n mod_remoteip.so mod_remoteip.c
     cat > $apache_install_dir/conf/extra/httpd-remoteip.conf << EOF
     cat > $apache_install_dir/conf/extra/httpd-remoteip.conf << EOF
 LoadModule remoteip_module modules/mod_remoteip.so
 LoadModule remoteip_module modules/mod_remoteip.so
@@ -126,8 +124,8 @@ RemoteIPHeader X-Forwarded-For
 RemoteIPInternalProxy 127.0.0.1
 RemoteIPInternalProxy 127.0.0.1
 EOF
 EOF
     sed -i "s@Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf\nInclude conf/extra/httpd-remoteip.conf@" $apache_install_dir/conf/httpd.conf
     sed -i "s@Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf\nInclude conf/extra/httpd-remoteip.conf@" $apache_install_dir/conf/httpd.conf
-fi
-ldconfig
-service httpd start
-cd ..
+  fi
+  ldconfig
+  service httpd start
+  popd 
 }
 }

+ 58 - 61
include/apache-2.4.sh

@@ -9,72 +9,69 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_Apache-2-4() {
 Install_Apache-2-4() {
-cd $oneinstack_dir/src
-
-tar xzf pcre-$pcre_version.tar.gz
-cd pcre-$pcre_version
-./configure
-make -j ${THREAD} && make install
-cd ..
-
-id -u $run_user >/dev/null 2>&1
-[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
-
-tar xzf httpd-$apache_4_version.tar.gz
-tar xzf apr-$apr_version.tar.gz
-tar xzf apr-util-$apr_util_version.tar.gz
-cd httpd-$apache_4_version
-[ ! -d "$apache_install_dir" ] && mkdir -p $apache_install_dir
-/bin/cp -R ../apr-$apr_version ./srclib/apr
-/bin/cp -R ../apr-util-$apr_util_version ./srclib/apr-util
-[ "$ZendGuardLoader_yn" == 'y' -o "$ionCube_yn" == 'y' ] && MPM=prefork || MPM=worker
-./configure --prefix=$apache_install_dir --enable-headers --enable-deflate --enable-mime-magic --enable-so --enable-rewrite --enable-ssl --with-ssl --enable-expires --enable-static-support --enable-suexec --disable-userdir --with-included-apr --with-mpm=$MPM --disable-userdir
-make -j ${THREAD} && make install
-if [ -e "$apache_install_dir/conf/httpd.conf" ];then
+  pushd ${oneinstack_dir}/src
+  tar xzf pcre-$pcre_version.tar.gz
+  pushd pcre-$pcre_version
+  ./configure
+  make -j ${THREAD} && make install
+  popd
+  id -u $run_user >/dev/null 2>&1
+  [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
+  tar xzf httpd-$apache_4_version.tar.gz
+  tar xzf apr-$apr_version.tar.gz
+  tar xzf apr-util-$apr_util_version.tar.gz
+  pushd httpd-$apache_4_version
+  [ ! -d "$apache_install_dir" ] && mkdir -p $apache_install_dir
+  /bin/cp -R ../apr-$apr_version ./srclib/apr
+  /bin/cp -R ../apr-util-$apr_util_version ./srclib/apr-util
+  [ "$ZendGuardLoader_yn" == 'y' -o "$ionCube_yn" == 'y' ] && MPM=prefork || MPM=worker
+  ./configure --prefix=$apache_install_dir --enable-headers --enable-deflate --enable-mime-magic --enable-so --enable-rewrite --enable-ssl --with-ssl --enable-expires --enable-static-support --enable-suexec --disable-userdir --with-included-apr --with-mpm=$MPM --disable-userdir
+  make -j ${THREAD} && make install
+  if [ -e "$apache_install_dir/conf/httpd.conf" ]; then
     echo "${CSUCCESS}Apache installed successfully! ${CEND}"
     echo "${CSUCCESS}Apache installed successfully! ${CEND}"
-    cd ..
+    popd 
     rm -rf httpd-$apache_4_version
     rm -rf httpd-$apache_4_version
-else
+  else
     rm -rf $apache_install_dir
     rm -rf $apache_install_dir
     echo "${CFAILURE}Apache install failed, Please contact the author! ${CEND}"
     echo "${CFAILURE}Apache install failed, Please contact the author! ${CEND}"
     kill -9 $$
     kill -9 $$
-fi
+  fi
 
 
-[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$apache_install_dir/bin:\$PATH" >> /etc/profile
-[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $apache_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$apache_install_dir/bin:\1@" /etc/profile
-. /etc/profile
-
-/bin/cp $apache_install_dir/bin/apachectl /etc/init.d/httpd
-sed -i '2a # chkconfig: - 85 15' /etc/init.d/httpd
-sed -i '3a # description: Apache is a World Wide Web server. It is used to serve' /etc/init.d/httpd
-chmod +x /etc/init.d/httpd
-[ "$OS" == 'CentOS' ] && { chkconfig --add httpd; chkconfig httpd on; }
-[[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d httpd defaults
-
-sed -i "s@^User daemon@User $run_user@" $apache_install_dir/conf/httpd.conf
-sed -i "s@^Group daemon@Group $run_user@" $apache_install_dir/conf/httpd.conf
-if [ "$Nginx_version" == '4' -a ! -e "$web_install_dir/sbin/nginx" ];then
+  [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$apache_install_dir/bin:\$PATH" >> /etc/profile
+  [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $apache_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$apache_install_dir/bin:\1@" /etc/profile
+  . /etc/profile
+  
+  /bin/cp $apache_install_dir/bin/apachectl /etc/init.d/httpd
+  sed -i '2a # chkconfig: - 85 15' /etc/init.d/httpd
+  sed -i '3a # description: Apache is a World Wide Web server. It is used to serve' /etc/init.d/httpd
+  chmod +x /etc/init.d/httpd
+  [ "$OS" == 'CentOS' ] && { chkconfig --add httpd; chkconfig httpd on; }
+  [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d httpd defaults
+  
+  sed -i "s@^User daemon@User $run_user@" $apache_install_dir/conf/httpd.conf
+  sed -i "s@^Group daemon@Group $run_user@" $apache_install_dir/conf/httpd.conf
+  if [ "$Nginx_version" == '4' -a ! -e "$web_install_dir/sbin/nginx" ]; then
     sed -i 's/^#ServerName www.example.com:80/ServerName 0.0.0.0:80/' $apache_install_dir/conf/httpd.conf
     sed -i 's/^#ServerName www.example.com:80/ServerName 0.0.0.0:80/' $apache_install_dir/conf/httpd.conf
     TMP_PORT=80
     TMP_PORT=80
     TMP_IP=$IPADDR
     TMP_IP=$IPADDR
-elif [[ $Nginx_version =~ ^[1-3]$ ]] || [ -e "$web_install_dir/sbin/nginx" ];then
+  elif [[ $Nginx_version =~ ^[1-3]$ ]] || [ -e "$web_install_dir/sbin/nginx" ]; then
     sed -i 's/^#ServerName www.example.com:80/ServerName 127.0.0.1:88/' $apache_install_dir/conf/httpd.conf
     sed -i 's/^#ServerName www.example.com:80/ServerName 127.0.0.1:88/' $apache_install_dir/conf/httpd.conf
     sed -i 's@^Listen.*@Listen 127.0.0.1:88@' $apache_install_dir/conf/httpd.conf
     sed -i 's@^Listen.*@Listen 127.0.0.1:88@' $apache_install_dir/conf/httpd.conf
     TMP_PORT=88
     TMP_PORT=88
     TMP_IP=127.0.0.1
     TMP_IP=127.0.0.1
-fi
-sed -i "s@AddType\(.*\)Z@AddType\1Z\n    AddType application/x-httpd-php .php .phtml\n    AddType application/x-httpd-php-source .phps@" $apache_install_dir/conf/httpd.conf
-sed -i "s@#AddHandler cgi-script .cgi@AddHandler cgi-script .cgi .pl@" $apache_install_dir/conf/httpd.conf
-sed -i 's@^#LoadModule rewrite_module@LoadModule rewrite_module@' $apache_install_dir/conf/httpd.conf
-sed -i 's@^#LoadModule\(.*\)mod_deflate.so@LoadModule\1mod_deflate.so@' $apache_install_dir/conf/httpd.conf
-sed -i 's@^#LoadModule\(.*\)mod_ssl.so@LoadModule\1mod_ssl.so@' $apache_install_dir/conf/httpd.conf
-sed -i 's@DirectoryIndex index.html@DirectoryIndex index.html index.php@' $apache_install_dir/conf/httpd.conf
-sed -i "s@^DocumentRoot.*@DocumentRoot \"$wwwroot_dir/default\"@" $apache_install_dir/conf/httpd.conf
-sed -i "s@^<Directory \"$apache_install_dir/htdocs\">@<Directory \"$wwwroot_dir/default\">@" $apache_install_dir/conf/httpd.conf
-sed -i "s@^#Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf@" $apache_install_dir/conf/httpd.conf
-
-#logrotate apache log
-cat > /etc/logrotate.d/apache << EOF
+  fi
+  sed -i "s@AddType\(.*\)Z@AddType\1Z\n    AddType application/x-httpd-php .php .phtml\n    AddType application/x-httpd-php-source .phps@" $apache_install_dir/conf/httpd.conf
+  sed -i "s@#AddHandler cgi-script .cgi@AddHandler cgi-script .cgi .pl@" $apache_install_dir/conf/httpd.conf
+  sed -i 's@^#LoadModule rewrite_module@LoadModule rewrite_module@' $apache_install_dir/conf/httpd.conf
+  sed -i 's@^#LoadModule\(.*\)mod_deflate.so@LoadModule\1mod_deflate.so@' $apache_install_dir/conf/httpd.conf
+  sed -i 's@^#LoadModule\(.*\)mod_ssl.so@LoadModule\1mod_ssl.so@' $apache_install_dir/conf/httpd.conf
+  sed -i 's@DirectoryIndex index.html@DirectoryIndex index.html index.php@' $apache_install_dir/conf/httpd.conf
+  sed -i "s@^DocumentRoot.*@DocumentRoot \"$wwwroot_dir/default\"@" $apache_install_dir/conf/httpd.conf
+  sed -i "s@^<Directory \"$apache_install_dir/htdocs\">@<Directory \"$wwwroot_dir/default\">@" $apache_install_dir/conf/httpd.conf
+  sed -i "s@^#Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf@" $apache_install_dir/conf/httpd.conf
+  
+  #logrotate apache log
+  cat > /etc/logrotate.d/apache << EOF
 $wwwlogs_dir/*apache.log {
 $wwwlogs_dir/*apache.log {
 daily
 daily
 rotate 5
 rotate 5
@@ -89,8 +86,8 @@ endscript
 }
 }
 EOF
 EOF
 
 
-mkdir $apache_install_dir/conf/vhost
-cat >> $apache_install_dir/conf/vhost/0.conf << EOF
+  mkdir $apache_install_dir/conf/vhost
+  cat >> $apache_install_dir/conf/vhost/0.conf << EOF
 <VirtualHost *:$TMP_PORT>
 <VirtualHost *:$TMP_PORT>
     ServerAdmin admin@linuxeye.com
     ServerAdmin admin@linuxeye.com
     DocumentRoot "$wwwroot_dir/default"
     DocumentRoot "$wwwroot_dir/default"
@@ -115,7 +112,7 @@ cat >> $apache_install_dir/conf/vhost/0.conf << EOF
 </VirtualHost>
 </VirtualHost>
 EOF
 EOF
 
 
-cat >> $apache_install_dir/conf/httpd.conf <<EOF
+  cat >> $apache_install_dir/conf/httpd.conf <<EOF
 <IfModule mod_headers.c>
 <IfModule mod_headers.c>
     AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript
     AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml text/javascript
     <FilesMatch "\.(js|css|html|htm|png|jpg|swf|pdf|shtml|xml|flv|gif|ico|jpeg)\$">
     <FilesMatch "\.(js|css|html|htm|png|jpg|swf|pdf|shtml|xml|flv|gif|ico|jpeg)\$">
@@ -131,7 +128,7 @@ ServerSignature Off
 Include conf/vhost/*.conf
 Include conf/vhost/*.conf
 EOF
 EOF
 
 
-if [ "$Nginx_version" != '4' -o -e "$web_install_dir/sbin/nginx" ];then
+  if [ "$Nginx_version" != '4' -o -e "$web_install_dir/sbin/nginx" ]; then
     cat > $apache_install_dir/conf/extra/httpd-remoteip.conf << EOF
     cat > $apache_install_dir/conf/extra/httpd-remoteip.conf << EOF
 LoadModule remoteip_module modules/mod_remoteip.so
 LoadModule remoteip_module modules/mod_remoteip.so
 RemoteIPHeader X-Forwarded-For
 RemoteIPHeader X-Forwarded-For
@@ -139,8 +136,8 @@ RemoteIPInternalProxy 127.0.0.1
 EOF
 EOF
     sed -i "s@Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf\nInclude conf/extra/httpd-remoteip.conf@" $apache_install_dir/conf/httpd.conf
     sed -i "s@Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf\nInclude conf/extra/httpd-remoteip.conf@" $apache_install_dir/conf/httpd.conf
     sed -i "s@LogFormat \"%h %l@LogFormat \"%h %a %l@g" $apache_install_dir/conf/httpd.conf
     sed -i "s@LogFormat \"%h %l@LogFormat \"%h %a %l@g" $apache_install_dir/conf/httpd.conf
-fi
-ldconfig
-service httpd start
-cd ..
+  fi
+  ldconfig
+  service httpd start
+  popd
 }
 }

+ 22 - 23
include/apcu.sh

@@ -9,21 +9,21 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_APCU() {
 Install_APCU() {
-    pushd ${oneinstack_dir}/src
-    phpExtensionDir=`$php_install_dir/bin/php-config --extension-dir`
-    if [ "`$php_install_dir/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}'`" == '7' ];then
-        tar xzf apcu-${apcu_for_php7_version}.tgz
-        pushd apcu-${apcu_for_php7_version}
-    else
-        tar xzf apcu-${apcu_version}.tgz
-        pushd apcu-${apcu_version}
-    fi
-  
-    ${php_install_dir}/bin/phpize
-    ./configure --with-php-config=${php_install_dir}/bin/php-config
-    make -j ${THREAD} && make install
-    if [ -f "${phpExtensionDir}/apcu.so" ];then
-        cat > ${php_install_dir}/etc/php.d/ext-apcu.ini << EOF
+  pushd ${oneinstack_dir}/src
+  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
+  if [ "`${php_install_dir}/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}'`" == '7' ]; then
+    tar xzf apcu-${apcu_for_php7_version}.tgz
+    pushd apcu-${apcu_for_php7_version}
+  else
+    tar xzf apcu-${apcu_version}.tgz
+    pushd apcu-${apcu_version}
+  fi
+
+  ${php_install_dir}/bin/phpize
+  ./configure --with-php-config=${php_install_dir}/bin/php-config
+  make -j ${THREAD} && make install
+  if [ -f "${phpExtensionDir}/apcu.so" ]; then
+    cat > ${php_install_dir}/etc/php.d/ext-apcu.ini << EOF
 [apcu]
 [apcu]
 extension=apcu.so
 extension=apcu.so
 apc.enabled=1
 apc.enabled=1
@@ -31,13 +31,12 @@ apc.shm_size=32M
 apc.ttl=7200
 apc.ttl=7200
 apc.enable_cli=1
 apc.enable_cli=1
 EOF
 EOF
-        [ "${Apache_version}" != '1' -a "${Apache_version}" != '2' ] && service php-fpm restart || service httpd restart
-        /bin/cp apc.php ${wwwroot_dir}/default
-        echo "${CSUCCESS}APCU module installed successfully! ${CEND}"
-    else
-        echo "${CFAILURE}APCU module install failed, Please contact the author! ${CEND}"
-    fi
-    popd
-    rm -rf apcu-${apcu_version}
+    /bin/cp apc.php ${wwwroot_dir}/default
+    echo "${CSUCCESS}APCU module installed successfully! ${CEND}"
     popd
     popd
+    rm -rf apcu-${apcu_for_php7_version} apcu-${apcu_version} package.xml
+  else
+    echo "${CFAILURE}APCU module install failed, Please contact the author! ${CEND}"
+  fi
+  popd
 }
 }

+ 5 - 8
include/boost.sh

@@ -8,10 +8,9 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 installBoost() {
 installBoost() {
-  pushd $oneinstack_dir/src
-
+  pushd ${oneinstack_dir}/src
   if [ ! -e "/usr/local/lib/libboost_system.so" ]; then
   if [ ! -e "/usr/local/lib/libboost_system.so" ]; then
-    boostVersion2=$(echo $boost_version | awk -F. '{print $1}')_$(echo $boost_version | awk -F. '{print $2}')_$(echo $boost_version | awk -F. '{print $3}')
+    boostVersion2=$(echo ${boost_version} | awk -F. '{print $1}')_$(echo ${boost_version} | awk -F. '{print $2}')_$(echo ${boost_version} | awk -F. '{print $3}')
     tar xvf boost_${boostVersion2}.tar.gz
     tar xvf boost_${boostVersion2}.tar.gz
     pushd boost_${boostVersion2}
     pushd boost_${boostVersion2}
     ./bootstrap.sh
     ./bootstrap.sh
@@ -19,15 +18,13 @@ installBoost() {
     ./b2 install
     ./b2 install
     popd
     popd
   fi
   fi
-  if [ -e "/usr/local/lib/libboost_system.so" ];then
-    echo "${CSUCCESS}Boost installed successfully! ${CEND}"
-    rm -rf boost_${boostVersion2}
+  if [ -e "/usr/local/lib/libboost_system.so" ]; then
     echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
     echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
     ldconfig
     ldconfig
-  else
+    echo "${CSUCCESS}Boost installed successfully! ${CEND}"
     rm -rf boost_${boostVersion2}
     rm -rf boost_${boostVersion2}
+  else
     echo "${CFAILURE}Boost installed failed, Please contact the author! ${CEND}"
     echo "${CFAILURE}Boost installed failed, Please contact the author! ${CEND}"
   fi
   fi
-
   popd
   popd
 }
 }

+ 620 - 622
include/check_download.sh

@@ -8,647 +8,645 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 checkDownload() {
 checkDownload() {
-    mirrorLink=http://mirrors.linuxeye.com/oneinstack/src
-    pushd ${oneinstack_dir}/src
+  pushd ${oneinstack_dir}/src
+  mirrorLink=http://mirrors.linuxeye.com/oneinstack/src
+  
+  # Web
+  if [ "${Web_yn}" == 'y' ]; then
+    echo "Download openSSL..."
+    src_url=https://www.openssl.org/source/openssl-${openssl_version}.tar.gz && Download_src
+    if [ "${Nginx_version}" == "1" ]; then
+      echo "Download nginx..."
+      src_url=http://nginx.org/download/nginx-${nginx_version}.tar.gz && Download_src
+    fi
+    if [ "${Nginx_version}" == "2" ]; then
+      echo "Download tengine..."
+      src_url=http://tengine.taobao.org/download/tengine-${tengine_version}.tar.gz && Download_src
+    fi
+    if [ "${Nginx_version}" == "3" ]; then
+      echo "Download openresty..."
+      src_url=https://openresty.org/download/openresty-${openresty_version}.tar.gz && Download_src
+    fi
     
     
-    # Web
-    if [ "${Web_yn}" == 'y' ];then
-        echo "Download openSSL..."
-        src_url=https://www.openssl.org/source/openssl-${openssl_version}.tar.gz && Download_src
-        if [ "${Nginx_version}" == "1" ];then
-            echo "Download nginx..."
-            src_url=http://nginx.org/download/nginx-${nginx_version}.tar.gz && Download_src
-        fi
-        if [ "${Nginx_version}" == "2" ];then
-            echo "Download tengine..."
-            src_url=http://tengine.taobao.org/download/tengine-${tengine_version}.tar.gz && Download_src
-        fi
-        if [ "${Nginx_version}" == "3" ];then
-            echo "Download openresty..."
-            src_url=https://openresty.org/download/openresty-${openresty_version}.tar.gz && Download_src
-        fi
-        
-        if [[ "${Nginx_version}" =~ ^[1-3]$ || ${Apache_version} == "1" ]];then
-            echo "Download pcre..."
-            src_url=${mirrorLink}/pcre-${pcre_version}.tar.gz && Download_src
-        fi
-        
-        # apache
-        if [ "${Apache_version}" == "1" ];then
-            echo "Download apache 2.4..."
-            src_url=http://archive.apache.org/dist/apr/apr-${apr_version}.tar.gz && Download_src
-            src_url=http://archive.apache.org/dist/apr/apr-util-${apr_util_version}.tar.gz && Download_src
-            src_url=http://mirrors.linuxeye.com/apache/httpd/httpd-${apache_4_version}.tar.gz && Download_src
-        fi
-        if [ "${Apache_version}" == "2" ];then
-            echo "Download apache 2.2..."
-            src_url=http://mirrors.linuxeye.com/apache/httpd/httpd-${apache_2_version}.tar.gz && Download_src
-            
-            echo "Download mod_remoteip.c for apache 2.2..."
-            src_url=${mirrorLink}/mod_remoteip.c && Download_src
-        fi
-        
-        # tomcat
-        if [ "${Tomcat_version}" == "1" ];then
-            echo "Download tomcat 8..."
-            src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat_8_version}/apache-tomcat-${tomcat_8_version}.tar.gz && Download_src
-            src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat_8_version}/catalina-jmx-remote.jar && Download_src
-        fi
-        if [ "${Tomcat_version}" == "2" ];then
-            echo "Download tomcat 7..."
-            src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat_7_version}/apache-tomcat-${tomcat_7_version}.tar.gz && Download_src
-            src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat_7_version}/catalina-jmx-remote.jar && Download_src
-        fi
-        if [ "${Tomcat_version}" == "3" ];then
-            echo "Download tomcat 6..."
-            src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat_6_version}/apache-tomcat-${tomcat_6_version}.tar.gz && Download_src
-            src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat_6_version}/catalina-jmx-remote.jar && Download_src
-        fi
-        
-        if [[ "${JDK_version}"  =~ ^[1-3]$ ]];then
-            if [ "${JDK_version}" == "1" ];then
-                 echo "Download jdk 1.8..."
-                 JDK_FILE="jdk-$(echo ${jdk_8_version} | awk -F. '{print $2}')u$(echo ${jdk_8_version} | awk -F_ '{print $NF}')-linux-${SYS_BIG_FLAG}.tar.gz"
-            fi
-            if [ "${JDK_version}" == "2" ];then
-                echo "Download jdk 1.7..."
-                JDK_FILE="jdk-$(echo ${jdk_7_version} | awk -F. '{print $2}')u$(echo ${jdk_7_version} | awk -F_ '{print $NF}')-linux-${SYS_BIG_FLAG}.tar.gz"
-            fi
-            if [ "${JDK_version}" == "3" ];then
-                echo "Download jdk 1.6..."
-                JDK_FILE="jdk-$(echo ${jdk_6_version} | awk -F. '{print $2}')u$(echo ${jdk_6_version} | awk -F_ '{print $NF}')-linux-${SYS_BIG_FLAG}.bin"
-            fi
-            src_url=http://mirrors.linuxeye.com/jdk/${JDK_FILE} && Download_src
-        fi
+    if [[ "${Nginx_version}" =~ ^[1-3]$ || ${Apache_version} == "1" ]]; then
+      echo "Download pcre..."
+      src_url=${mirrorLink}/pcre-${pcre_version}.tar.gz && Download_src
     fi
     fi
     
     
-    if [ "${DB_yn}" == "y" ];then
-        if [[ "${DB_version}" =~ ^[1,4,7]$ ]] && [ "${dbInstallMethods}" == "2" ];then
-            echo "Download boost..."
-            [ "${IPADDR_COUNTRY}"x == "CN"x ] && DOWN_ADDR_BOOST=${mirrorLink} || DOWN_ADDR_BOOST=http://downloads.sourceforge.net/project/boost/boost/${boost_version}
-            boostVersion2=$(echo ${boost_version} | awk -F. '{print $1}')_$(echo ${boost_version} | awk -F. '{print $2}')_$(echo ${boost_version} | awk -F. '{print $3}')
-            src_url=${DOWN_ADDR_BOOST}/boost_${boostVersion2}.tar.gz && Download_src
-        fi
-      
-        if [ "${DB_version}" == "1" ];then
-            # mysql 5.7
-            if [ "${IPADDR_COUNTRY}"x == "CN"x -a "${IPADDR_ISP}" == 'aliyun' -a "`../include/check_port.py aliyun-oss.linuxeye.com 80`" == 'True' ];then
-                DOWN_ADDR_MYSQL=http://aliyun-oss.linuxeye.com/mysql/MySQL-5.7
-            else
-                if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
-                    if [ "$(../include/check_port.py mirrors.tuna.tsinghua.edu.cn 443)" == 'True' ];then
-                        DOWN_ADDR_MYSQL=https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.7
-                    else
-                        DOWN_ADDR_MYSQL=http://mirrors.sohu.com/mysql/MySQL-5.6
-                        DOWN_ADDR_MYSQL_BK=${DOWN_ADDR_MYSQL}
-                    fi
-                else
-                    if [ "$(../include/check_port.py cdn.mysql.com 80)" == 'True' ];then
-                        DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.7
-                    else
-                        DOWN_ADDR_MYSQL=http://mysql.he.net/Downloads/MySQL-5.7
-                        DOWN_ADDR_MYSQL_BK=${DOWN_ADDR_MYSQL}
-                    fi
-                fi
-            fi
-            if [ "${dbInstallMethods}" == "1" ];then
-                echo "Download mysql 5.7 binary package..."
-                FILE_NAME=mysql-${mysql_5_7_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz
-            elif [ "${dbInstallMethods}" == "2" ];then
-                echo "Download mysql 5.7 source package..."
-                FILE_NAME=mysql-${mysql_5_7_version}.tar.gz
-            fi
-            wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME}
-            wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5
-            MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
-            while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MYSQL_TAR_MD5}" ];do
-                wget -4c --no-check-certificate ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME};sleep 1
-                [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MYSQL_TAR_MD5}" ] && break || continue
-            done
-        fi
-      
-        if [ "${DB_version}" == "2" ];then
-            # mysql 5.6
-            if [ "${IPADDR_COUNTRY}"x == "CN"x -a "${IPADDR_ISP}" == 'aliyun' -a "$(../include/check_port.py aliyun-oss.linuxeye.com 80)" == 'True' ];then
-                DOWN_ADDR_MYSQL=http://aliyun-oss.linuxeye.com/mysql/MySQL-5.6
-            else
-                if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
-                    if [ "$(../include/check_port.py mirrors.tuna.tsinghua.edu.cn 443)" == 'True' ];then
-                        DOWN_ADDR_MYSQL=https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.6
-                    else
-                        DOWN_ADDR_MYSQL=http://mirrors.sohu.com/mysql/MySQL-5.6
-                        DOWN_ADDR_MYSQL_BK=${DOWN_ADDR_MYSQL}
-                    fi
-                else
-                    if [ "$(../include/check_port.py cdn.mysql.com 80)" == 'True' ];then
-                        DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.6
-                    else
-                        DOWN_ADDR_MYSQL=http://mysql.he.net/Downloads/MySQL-5.6
-                        DOWN_ADDR_MYSQL_BK=${DOWN_ADDR_MYSQL}
-                    fi
-                fi
-            fi
-            if [ "${dbInstallMethods}" == "1" ];then
-                echo "Download mysql 5.6 binary package..."
-                FILE_NAME=mysql-${mysql_5_6_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz
-            elif [ "${dbInstallMethods}" == "2" ];then
-                echo "Download MySQL 5.5 source package..."
-                FILE_NAME=mysql-${mysql_5_6_version}.tar.gz
-            fi
-            wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME}
-            wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5
-            MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
-            while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MYSQL_TAR_MD5}" ];do
-                wget -4c --no-check-certificate ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME};sleep 1
-                [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MYSQL_TAR_MD5}" ] && break || continue
-            done
-        fi
-      
-        if [ "${DB_version}" == "3" ];then
-            # mysql 5.5
-            if [ "${IPADDR_COUNTRY}"x == "CN"x -a "${IPADDR_ISP}" == 'aliyun' -a "$(../include/check_port.py aliyun-oss.linuxeye.com 80)" == 'True' ];then
-                DOWN_ADDR_MYSQL=http://aliyun-oss.linuxeye.com/mysql/MySQL-5.5
-            else
-                if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
-                    if [ "$(../include/check_port.py mirrors.tuna.tsinghua.edu.cn 443)" == 'True' ];then
-                        DOWN_ADDR_MYSQL=https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.5
-                    else
-                        DOWN_ADDR_MYSQL=http://mirrors.sohu.com/mysql/MySQL-5.5
-                        DOWN_ADDR_MYSQL_BK=${DOWN_ADDR_MYSQL}
-                    fi
-                else
-                    if [ "$(../include/check_port.py cdn.mysql.com 80)" == 'True' ];then
-                        DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.5
-                    else
-                        DOWN_ADDR_MYSQL=http://mysql.he.net/Downloads/MySQL-5.5
-                        DOWN_ADDR_MYSQL_BK=${DOWN_ADDR_MYSQL}
-                    fi
-                fi
-            fi
-            if [ "${dbInstallMethods}" == "1" ];then
-                echo "Download mysql 5.5 binary package..."
-                FILE_NAME=mysql-${mysql_5_5_version}-linux2.6-${SYS_BIT_b}.tar.gz
-            elif [ "${dbInstallMethods}" == "2" ];then
-                echo "Download MySQL 5.5 source package..."
-                FILE_NAME=mysql-${mysql_5_5_version}.tar.gz
-                src_url=${mirrorLink}/mysql-5.5-fix-arm-client_plugin.patch && Download_src
-            fi
-            wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME}
-            wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5
-            MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
-      
-            while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MYSQL_TAR_MD5}" ];do
-                wget -c --no-check-certificate ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME};sleep 1
-                [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MYSQL_TAR_MD5}" ] && break || continue
-            done
-        fi
-      
-        if [ "${DB_version}" == "4" ];then
-            # mariaDB 10.1
-            if [ "${dbInstallMethods}" == "1" ];then
-                echo "Download mariaDB 10.1 binary package..."
-                FILE_NAME=mariadb-${mariadb_10_1_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz
-                if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
-                    DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_10_1_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}
-                    MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
-                    [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb_10_1_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); }
-                else
-                    DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb_10_1_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}
-                    MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb_10_1_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}/md5sums.txt |  grep ${FILE_NAME} | awk '{print $1}')
-                fi
-            elif [ "${dbInstallMethods}" == "2" ];then
-                echo "Download mariaDB 10.1 source package..."
-                FILE_NAME=mariadb-${mariadb_10_1_version}.tar.gz
-                if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
-                    DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_10_1_version}/source
-                    MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
-                    [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb_10_1_version}/source; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); }
-                else
-                    DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb_10_1_version}/source
-                    MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb_10_1_version}/source/md5sums.txt |  grep ${FILE_NAME} | awk '{print $1}')
-                fi
-            fi
-            tryDlCount=0
-            while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MARAIDB_TAR_MD5}" ];do
-                wget -c --no-check-certificate ${DOWN_ADDR_MARIADB}/${FILE_NAME};sleep 1
-                let "tryDlCount++"
-                [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MARAIDB_TAR_MD5}" -o "${tryDlCount}" == "6" ] && break || continue
-            done
-            if [ "${tryDlCount}" == "6" ];then
-                echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
-                kill -9 $$
-            else
-                echo "[${CMSG}${FILE_NAME}${CEND}] found."
-            fi
-        fi
-      
-        if [ "${DB_version}" == "5" ];then
-            # mariaDB 10.0
-            if [ "${dbInstallMethods}" == "1" ];then
-                echo "Download mariaDB 10.0 binary package..."
-                FILE_NAME=mariadb-${mariadb_10_0_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz
-                if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
-                    DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_10_0_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}
-                    MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
-                    [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb_10_0_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); }
-                else
-                    DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb_10_0_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}
-                    MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb_10_0_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}/md5sums.txt |  grep ${FILE_NAME} | awk '{print $1}')
-                fi
-            elif [ "${dbInstallMethods}" == "2" ];then
-                echo "Download mariaDB 10.0 source package..."
-                FILE_NAME=mariadb-${mariadb_10_0_version}.tar.gz
-                if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
-                    DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_10_0_version}/source
-                    MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
-                    [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb_10_0_version}/source; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); }
-                else
-                    DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb_10_0_version}/source
-                    MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb_10_0_version}/source/md5sums.txt |  grep ${FILE_NAME} | awk '{print $1}')
-                fi
-            fi
-            tryDlCount=0
-            while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MARAIDB_TAR_MD5}" ];do
-                wget -c --no-check-certificate ${DOWN_ADDR_MARIADB}/${FILE_NAME};sleep 1
-                let "tryDlCount++"
-                [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MARAIDB_TAR_MD5}" -o "${tryDlCount}" == "6" ] && break || continue
-            done
-            if [ "${tryDlCount}" == "6" ];then
-                echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
-                kill -9 $$
-            else
-                echo "[${CMSG}${FILE_NAME}${CEND}] found."
-            fi
-        fi
-        if [ "${DB_version}" == "6" ];then
-            # mariaDB 5.5
-            if [ "${dbInstallMethods}" == "1" ];then
-                echo "Download mariaDB 5.5 binary package..."
-                FILE_NAME=mariadb-${mariadb_5_5_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz
-                if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
-                    DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_5_5_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}
-                    MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
-                    [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb_5_5_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); }
-                else
-                    DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb_5_5_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}
-                    MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb_5_5_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}/md5sums.txt |  grep ${FILE_NAME} | awk '{print $1}')
-                fi
-            elif [ "${dbInstallMethods}" == "2" ];then
-                echo "Download mariaDB 10.0 source package..."
-                FILE_NAME=mariadb-${mariadb_5_5_version}.tar.gz
-                if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
-                    DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_5_5_version}/source
-                    MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
-                    [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb_5_5_version}/source; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); }
-                else
-                    DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb_5_5_version}/source
-                    MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb_5_5_version}/source/md5sums.txt |  grep ${FILE_NAME} | awk '{print $1}')
-                fi
-            fi
-            tryDlCount=0
-            while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MARAIDB_TAR_MD5}" ];do
-                wget -c --no-check-certificate ${DOWN_ADDR_MARIADB}/${FILE_NAME};sleep 1
-                let "tryDlCount++"
-                [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MARAIDB_TAR_MD5}" -o "${tryDlCount}" == "6" ] && break || continue
-            done
-            if [ "${tryDlCount}" == "6" ];then
-                echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
-                kill -9 $$
-            else
-                echo "[${CMSG}${FILE_NAME}${CEND}] found."
-            fi
-        fi
-      
-        if [ "${DB_version}" == "7" ];then
-            # precona 5.7
-            if [ "${dbInstallMethods}" == "1" ];then
-                echo "Download percona 5.7 binary package..."
-                FILE_NAME=Percona-Server-${percona_5_7_version}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz
-                DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-${percona_5_7_version}/binary/tarball
-                PERCONA_TAR_MD5=$(curl -Lk https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-${percona_5_7_version}/binary/tarball/${FILE_NAME}.md5sum |  grep ${FILE_NAME} | awk '{print $1}')
-            elif [ "${dbInstallMethods}" == "2" ];then
-                echo "Download percona 5.7 source package..."
-                FILE_NAME=percona-server-${percona_5_7_version}.tar.gz
-                if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
-                    DOWN_ADDR_PERCONA=${mirrorLink}
-                    DOWN_ADDR_PERCONA_2=https://www.percona.com/downloads/Percona-Server-5.7/source/tarball
-                    PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_2}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
-                    [ -z "${PERCONA_TAR_MD5}" ] && { DOWN_ADDR_PERCONA=${mirrorLink}; PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_2}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}'); }
-                else
-                    DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-${percona_5_7_version}/source/tarball
-                    PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA}/${FILE_NAME}.md5sum |  grep ${FILE_NAME} | awk '{print $1}')
-                fi
-            fi
-            tryDlCount=0
-            while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PERCONA_TAR_MD5}" ];do
-                wget -c --no-check-certificate ${DOWN_ADDR_PERCONA}/${FILE_NAME};sleep 1
-                let "tryDlCount++"
-                [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${PERCONA_TAR_MD5}" -o "${tryDlCount}" == "6" ] && break || continue
-            done
-            if [ "${tryDlCount}" == "6" ];then
-                echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
-                kill -9 $$
-            else
-                echo "[${CMSG}${FILE_NAME}${CEND}] found."
-            fi
-        fi
-      
-        if [ "${DB_version}" == "8" ];then
-            # precona 5.6
-            if [ "${dbInstallMethods}" == "1" ];then
-                echo "Download percona 5.6 binary package..."
-                perconaVerStr1=$(echo ${percona_5_6_version} | sed "s@-@-rel@")
-                FILE_NAME=Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz
-                DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-${percona_5_6_version}/binary/tarball
-                PERCONA_TAR_MD5=$(curl -Lk https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-${percona_5_6_version}/binary/tarball/${FILE_NAME}.md5sum |  grep ${FILE_NAME} | awk '{print $1}')
-            elif [ "${dbInstallMethods}" == "2" ];then
-                echo "Download percona 5.6 source package..."
-                FILE_NAME=percona-server-${percona_5_6_version}.tar.gz
-                if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
-                    DOWN_ADDR_PERCONA=${mirrorLink}
-                    DOWN_ADDR_PERCONA_2=https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-${percona_5_6_version}/source/tarball
-                    PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_2}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
-                    [ -z "${PERCONA_TAR_MD5}" ] && { DOWN_ADDR_PERCONA=${mirrorLink}; PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_2}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}'); }
-                else
-                    DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-${percona_5_6_version}/source/tarball
-                    PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA}/${FILE_NAME}.md5sum |  grep ${FILE_NAME} | awk '{print $1}')
-                fi
-            fi
-            tryDlCount=0
-            while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PERCONA_TAR_MD5}" ];do
-                wget -c --no-check-certificate ${DOWN_ADDR_PERCONA}/${FILE_NAME};sleep 1
-                let "tryDlCount++"
-                [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${PERCONA_TAR_MD5}" -o "${tryDlCount}" == "6" ] && break || continue
-            done
-            if [ "${tryDlCount}" == "6" ];then
-                echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
-                kill -9 $$
-            else
-                echo "[${CMSG}${FILE_NAME}${CEND}] found."
-            fi
-        fi
-      
-        if [ "${DB_version}" == "9" ];then
-            # precona 5.5
-            if [ "${dbInstallMethods}" == "1" ];then
-                echo "Download percona 5.5 binary package..."
-                perconaVerStr1=$(echo ${percona_5_5_version} | sed "s@-@-rel@")
-                FILE_NAME=Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz
-                DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona_5_5_version}/binary/tarball
-                PERCONA_TAR_MD5=$(curl -Lk https://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona_5_5_version}/binary/tarball/${FILE_NAME}.md5sum |  grep ${FILE_NAME} | awk '{print $1}')
-            elif [ "${dbInstallMethods}" == "2" ];then
-                echo "Download percona 5.5 source package..."
-                FILE_NAME=percona-server-${percona_5_5_version}.tar.gz
-                if [ "${IPADDR_COUNTRY}"x == "CN"x ];then
-                    DOWN_ADDR_PERCONA=${mirrorLink}
-                    DOWN_ADDR_PERCONA_2=https://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona_5_5_version}/source/tarball
-                    PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_2}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
-                    [ -z "${PERCONA_TAR_MD5}" ] && { DOWN_ADDR_PERCONA=${mirrorLink}; PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_2}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}'); }
-                else
-                    DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona_5_5_version}/source/tarball
-                    PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
-                fi
-            fi
-            tryDlCount=0
-            while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PERCONA_TAR_MD5}" ];do
-                wget -c --no-check-certificate ${DOWN_ADDR_PERCONA}/${FILE_NAME};sleep 1
-                let "tryDlCount++"
-                [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${PERCONA_TAR_MD5}" -o "${tryDlCount}" == "6" ] && break || continue
-            done
-      
-            if [ "${tryDlCount}" == "6" ];then
-                echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
-                kill -9 $$
-            else
-                echo "[${CMSG}${FILE_NAME}${CEND}] found."
-            fi
-        fi
+    # apache
+    if [ "${Apache_version}" == "1" ]; then
+      echo "Download apache 2.4..."
+      src_url=http://archive.apache.org/dist/apr/apr-${apr_version}.tar.gz && Download_src
+      src_url=http://archive.apache.org/dist/apr/apr-util-${apr_util_version}.tar.gz && Download_src
+      src_url=http://mirrors.linuxeye.com/apache/httpd/httpd-${apache_4_version}.tar.gz && Download_src
     fi
     fi
-    # PHP
-    if [ "${PHP_yn}" == "y" ];then
-        # php 5.3 5.4 5.5 5.6 5.7
-        echo "PHP common..."
-        src_url=http://ftp.gnu.org/pub/gnu/libiconv/libiconv-${libiconv_version}.tar.gz && Download_src
-        src_url=https://curl.haxx.se/download/curl-${curl_version}.tar.gz && Download_src
-        src_url=http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/${libmcrypt_version}/libmcrypt-${libmcrypt_version}.tar.gz && Download_src
-        src_url=http://downloads.sourceforge.net/project/mhash/mhash/${mhash_version}/mhash-${mhash_version}.tar.gz && Download_src
-        src_url=http://downloads.sourceforge.net/project/mcrypt/MCrypt/${mcrypt_version}/mcrypt-${mcrypt_version}.tar.gz && Download_src
-        src_url=${mirrorLink}/libiconv-glibc-2.16.patch && Download_src
-      
-        if [[ "${PHP_version}" =~ ^[1-3]$ ]];then
-            # php 5.3 5.4 5.5
-            src_url=${mirrorLink}/fpm-race-condition.patch && Download_src
-        fi
-      
-        if [ "${PHP_version}" == "1" ];then
-            # php 5.3
-            src_url=${mirrorLink}/debian_patches_disable_SSLv2_for_openssl_1_0_0.patch && Download_src
-            src_url=${mirrorLink}/php5.3patch && Download_src
-            if [ "$Debian_version" == '8' -o "$Ubuntu_version" == '16' ];then
-                if [ ! -e "/usr/local/openssl/lib/libcrypto.a" ];then
-                    src_url=${mirrorLink}/openssl-1.0.0s.tar.gz && Download_src
-                fi
-            fi
-            src_url=http://www.php.net/distributions/php-${php_3_version}.tar.gz && Download_src
-        fi
-        if [ "${PHP_version}" == "2" ];then
-            src_url=http://www.php.net/distributions/php-${php_4_version}.tar.gz && Download_src
-        fi
-        if [ "${PHP_version}" == "3" ];then
-            src_url=http://www.php.net/distributions/php-${php_5_version}.tar.gz && Download_src
-        fi
-        if [ "${PHP_version}" == "4" ];then
-            src_url=http://www.php.net/distributions/php-${php_6_version}.tar.gz && Download_src
-        fi
-        if [ "${PHP_version}" == "5" ];then
-            src_url=http://www.php.net/distributions/php-${php_7_version}.tar.gz && Download_src
-        fi
-      
-        # PHP OPCache
-        if [ "${PHP_cache}" == "1" ] && [[ "$PHP_version" =~ ^[1,2]$ ]];then
-            # php 5.3 5.4
-            echo "Download Zend OPCache..."
-            src_url=https://pecl.php.net/get/zendopcache-${zendopcache_version}.tgz && Download_src
-        fi
-        if [ "${PHP_cache}" == "2" ] && [[ "$PHP_version" =~ ^[1-4]$ ]];then
-            # php 5.3 5.4 5.5 5.6
-            echo "Download xcache..."
-            src_url=http://xcache.lighttpd.net/pub/Releases/${xcache_version}/xcache-${xcache_version}.tar.gz && Download_src
-        fi
-        if [ "${PHP_cache}" == "3" ];then
-            # php 5.3 5.4 5.5 5.6 7.0
-            echo "Download apcu..."
-            if [ "${PHP_version}" != "5" ]; then
-                src_url=http://pecl.php.net/get/apcu-${apcu_version}.tgz && Download_src
-            else
-                src_url=http://pecl.php.net/get/apcu-${apcu_for_php7_version}.tgz && Download_src
-            fi
-        fi
-        if [ "${PHP_cache}" == "4" -a "${PHP_version}" == "2" ];then
-            echo "Download eaccelerator 1.0 dev..."
-            src_url=https://github.com/eaccelerator/eaccelerator/tarball/master && Download_src
-        elif [ "${PHP_cache}" == "4" -a "${PHP_version}" == "1" ];then
-            echo "Download eaccelerator 0.9..."
-            src_url=https://github.com/downloads/eaccelerator/eaccelerator/eaccelerator-${eaccelerator_version}.tar.bz2 && Download_src
-        fi
-      
-        # Zend Guard Loader
-        if [ "${ZendGuardLoader_yn}" == "y" -a "${armPlatform}" != "y" ];then
-            if [ "${PHP_version}" == "4" ];then
-                if [ "${OS_BIT}" == "64" ];then
-                    # 64 bit
-                    echo "Download zend loader for php 5.6..."
-                    src_url=${mirrorLink}/zend-loader-php5.6-linux-x86_64.tar.gz && Download_src
-                else
-                    # 32 bit
-                    echo "Download zend loader for php 5.6..."
-                    src_url=${mirrorLink}/zend-loader-php5.6-linux-i386.tar.gz && Download_src
-                fi
-            fi
-            if [ "${PHP_version}" == "3" ];then
-                if [ "${OS_BIT}" == "64" ];then
-                    # 64 bit
-                    echo "Download zend loader for php 5.5..."
-                    src_url=${mirrorLink}/zend-loader-php5.5-linux-x86_64.tar.gz && Download_src
-                else
-                    # 32 bit
-                    echo "Download zend loader for php 5.5..."
-                    src_url=${mirrorLink}/zend-loader-php5.5-linux-i386.tar.gz && Download_src
-                fi
-            fi
-            if [ "${PHP_version}" == "2" ];then
-                if [ "${OS_BIT}" == "64" ];then
-                    # 64 bit
-                    echo "Download zend loader for php 5.4..."
-                    src_url=${mirrorLink}/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz && Download_src
-                else
-                    # 32 bit
-                    echo "Download zend loader for php 5.4..."
-                    src_url=${mirrorLink}/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386.tar.gz && Download_src
-                fi
-            fi
-            if [ "${PHP_version}" == "1" ];then
-                if [ "${OS_BIT}" == "64" ];then
-                    # 64 bit
-                    echo "Download zend loader for php 5.3..."
-                    src_url=${mirrorLink}/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz && Download_src
-                else
-                    # 32 bit
-                    echo "Download zend loader for php 5.3..."
-                    src_url=${mirrorLink}/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz && Download_src
-                fi
-            fi
-        fi
-      
-        if [ "${ionCube_yn}" == "y" ];then
-            echo "Download ioncube..."
-            if [ "${OS_BIT}" == '64' ];then
-                src_url=http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz && Download_src
-            else
-                if [ "${TARGET_ARCH}" == "armv7" ]; then
-                    src_url=http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_armv7l.tar.gz && Download_src
-                else
-                    src_url=http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz && Download_src
-                fi
-            fi
-        fi
-      
-        if [ "${Magick_yn}" == "y" ];then
-            if [ "${Magick}" == "1" ];then
-                echo "Download ImageMagick..."
-                src_url=${mirrorLink}/ImageMagick-${ImageMagick_version}.tar.gz && Download_src
-                if [ "${PHP_version}" == "1" ];then 
-                    echo "Download image for php 5.3..."
-                    src_url=https://pecl.php.net/get/imagick-${imagick_for_php53_version}.tgz && Download_src
-                else 
-                    echo "Download imagick..."
-                    src_url=http://pecl.php.net/get/imagick-${imagick_version}.tgz && Download_src
-                fi
-            else
-                echo "Download graphicsmagick..."
-                src_url=http://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/${GraphicsMagick_version}/GraphicsMagick-${GraphicsMagick_version}.tar.gz && Download_src
-                if [ "${PHP_version}" == "5" ];then 
-                    echo "Download gmagick for php7..."
-                    src_url=https://pecl.php.net/get/gmagick-${gmagick_for_php7_version}.tgz && Download_src
-                else
-                    echo "Download gmagick for php..."
-                    src_url=http://pecl.php.net/get/gmagick-${gmagick_version}.tgz && Download_src
-                fi
-            fi
-        fi
+    if [ "${Apache_version}" == "2" ]; then
+      echo "Download apache 2.2..."
+      src_url=http://mirrors.linuxeye.com/apache/httpd/httpd-${apache_2_version}.tar.gz && Download_src
       
       
+      echo "Download mod_remoteip.c for apache 2.2..."
+      src_url=${mirrorLink}/mod_remoteip.c && Download_src
     fi
     fi
     
     
-    if [ "${FTP_yn}" == "y" ];then
-        echo "Download pureftpd..."
-        src_url=http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-${pureftpd_version}.tar.gz && Download_src
+    # tomcat
+    if [ "${Tomcat_version}" == "1" ]; then
+      echo "Download tomcat 8..."
+      src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat_8_version}/apache-tomcat-${tomcat_8_version}.tar.gz && Download_src
+      src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat_8_version}/catalina-jmx-remote.jar && Download_src
     fi
     fi
-    
-    if [ "${phpMyAdmin_yn}" == "y" ];then
-        echo "Download phpMyAdmin..."
-        src_url=https://files.phpmyadmin.net/phpMyAdmin/${phpMyAdmin_version}/phpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz && Download_src
+    if [ "${Tomcat_version}" == "2" ]; then
+      echo "Download tomcat 7..."
+      src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat_7_version}/apache-tomcat-${tomcat_7_version}.tar.gz && Download_src
+      src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat_7_version}/catalina-jmx-remote.jar && Download_src
+    fi
+    if [ "${Tomcat_version}" == "3" ]; then
+      echo "Download tomcat 6..."
+      src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat_6_version}/apache-tomcat-${tomcat_6_version}.tar.gz && Download_src
+      src_url=http://mirrors.linuxeye.com/apache/tomcat/v${tomcat_6_version}/catalina-jmx-remote.jar && Download_src
     fi
     fi
     
     
-    if [ "${redis_yn}" == "y" ];then
-        echo "Download redis..."
-        src_url=http://download.redis.io/releases/redis-${redis_version}.tar.gz && Download_src
-        if [ "${OS}" == "CentOS" ];then
-            echo "Download start-stop-daemon.c for CentOS..."
-            src_url=${mirrorLink}/start-stop-daemon.c && Download_src
-        fi
-        # redis addon
-        if [ "${PHP_version}" == "5" ];then
-            echo "Download redis pecl for php7..."
-            src_url=http://pecl.php.net/get/redis-${redis_pecl_for_php7_version}.tgz && Download_src
+    if [[ "${JDK_version}"  =~ ^[1-3]$ ]]; then
+      if [ "${JDK_version}" == "1" ]; then
+        echo "Download jdk 1.8..."
+        JDK_FILE="jdk-$(echo ${jdk_8_version} | awk -F. '{print $2}')u$(echo ${jdk_8_version} | awk -F_ '{print $NF}')-linux-${SYS_BIG_FLAG}.tar.gz"
+      fi
+      if [ "${JDK_version}" == "2" ]; then
+        echo "Download jdk 1.7..."
+        JDK_FILE="jdk-$(echo ${jdk_7_version} | awk -F. '{print $2}')u$(echo ${jdk_7_version} | awk -F_ '{print $NF}')-linux-${SYS_BIG_FLAG}.tar.gz"
+      fi
+      if [ "${JDK_version}" == "3" ]; then
+        echo "Download jdk 1.6..."
+        JDK_FILE="jdk-$(echo ${jdk_6_version} | awk -F. '{print $2}')u$(echo ${jdk_6_version} | awk -F_ '{print $NF}')-linux-${SYS_BIG_FLAG}.bin"
+      fi
+      src_url=http://mirrors.linuxeye.com/jdk/${JDK_FILE} && Download_src
+    fi
+  fi
+  
+  if [ "${DB_yn}" == "y" ]; then
+    if [[ "${DB_version}" =~ ^[1,4,7]$ ]] && [ "${dbInstallMethods}" == "2" ]; then
+      echo "Download boost..."
+      [ "${IPADDR_COUNTRY}"x == "CN"x ] && DOWN_ADDR_BOOST=${mirrorLink} || DOWN_ADDR_BOOST=http://downloads.sourceforge.net/project/boost/boost/${boost_version}
+      boostVersion2=$(echo ${boost_version} | awk -F. '{print $1}')_$(echo ${boost_version} | awk -F. '{print $2}')_$(echo ${boost_version} | awk -F. '{print $3}')
+      src_url=${DOWN_ADDR_BOOST}/boost_${boostVersion2}.tar.gz && Download_src
+    fi
+  
+    if [ "${DB_version}" == "1" ]; then
+      # mysql 5.7
+      if [ "${IPADDR_COUNTRY}"x == "CN"x -a "${IPADDR_ISP}" == 'aliyun' -a "`../include/check_port.py aliyun-oss.linuxeye.com 80`" == 'True' ]; then
+        DOWN_ADDR_MYSQL=http://aliyun-oss.linuxeye.com/mysql/MySQL-5.7
+      else
+        if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
+          if [ "$(../include/check_port.py mirrors.tuna.tsinghua.edu.cn 443)" == 'True' ]; then
+            DOWN_ADDR_MYSQL=https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.7
+          else
+            DOWN_ADDR_MYSQL=http://mirrors.sohu.com/mysql/MySQL-5.6
+            DOWN_ADDR_MYSQL_BK=${DOWN_ADDR_MYSQL}
+          fi
         else
         else
-            echo "Download redis pecl..."
-            src_url=http://pecl.php.net/get/redis-${redis_pecl_version}.tgz && Download_src
-        fi
+          if [ "$(../include/check_port.py cdn.mysql.com 80)" == 'True' ]; then
+            DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.7
+          else
+            DOWN_ADDR_MYSQL=http://mysql.he.net/Downloads/MySQL-5.7
+            DOWN_ADDR_MYSQL_BK=${DOWN_ADDR_MYSQL}
+          fi
+        fi
+      fi
+      if [ "${dbInstallMethods}" == "1" ]; then
+        echo "Download MySQL 5.7 binary package..."
+        FILE_NAME=mysql-${mysql_5_7_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz
+      elif [ "${dbInstallMethods}" == "2" ]; then
+        echo "Download MySQL 5.7 source package..."
+        FILE_NAME=mysql-${mysql_5_7_version}.tar.gz
+      fi
+      wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME}
+      wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5
+      MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
+      while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MYSQL_TAR_MD5}" ];do
+        wget -4c --no-check-certificate ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME};sleep 1
+        [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MYSQL_TAR_MD5}" ] && break || continue
+      done
     fi
     fi
-    
-    if [ "${memcached_yn}" == "y" ];then
-        echo "Download memcached..."
-        src_url=http://www.memcached.org/files/memcached-${memcached_version}.tar.gz && Download_src
-        if [ "${PHP_version}" == "5" ];then
-            echo "Download pecl memcache for php7..."
-            src_url=${mirrorLink}/pecl-memcache-php7.tgz && Download_src
-            echo "Download php-memcached for php7..."
-            src_url=${mirrorLink}/php-memcached-php7.tgz && Download_src
+  
+    if [ "${DB_version}" == "2" ]; then
+      # mysql 5.6
+      if [ "${IPADDR_COUNTRY}"x == "CN"x -a "${IPADDR_ISP}" == 'aliyun' -a "$(../include/check_port.py aliyun-oss.linuxeye.com 80)" == 'True' ]; then
+        DOWN_ADDR_MYSQL=http://aliyun-oss.linuxeye.com/mysql/MySQL-5.6
+      else
+        if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
+          if [ "$(../include/check_port.py mirrors.tuna.tsinghua.edu.cn 443)" == 'True' ]; then
+            DOWN_ADDR_MYSQL=https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.6
+          else
+            DOWN_ADDR_MYSQL=http://mirrors.sohu.com/mysql/MySQL-5.6
+            DOWN_ADDR_MYSQL_BK=${DOWN_ADDR_MYSQL}
+          fi
         else
         else
-            echo "Download pecl memcache for php7..."
-            src_url=http://pecl.php.net/get/memcache-${memcache_pecl_version}.tgz && Download_src
-            echo "Download php-memcached for php7..."
-            src_url=http://pecl.php.net/get/memcached-${memcached_pecl_version}.tgz && Download_src
-        fi
-      
-        echo "Download libmemcached..."
-        src_url=https://launchpad.net/libmemcached/1.0/${libmemcached_version}/+download/libmemcached-${libmemcached_version}.tar.gz && Download_src
+          if [ "$(../include/check_port.py cdn.mysql.com 80)" == 'True' ]; then
+            DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.6
+          else
+            DOWN_ADDR_MYSQL=http://mysql.he.net/Downloads/MySQL-5.6
+            DOWN_ADDR_MYSQL_BK=${DOWN_ADDR_MYSQL}
+          fi
+        fi
+      fi
+      if [ "${dbInstallMethods}" == "1" ]; then
+        echo "Download  MySQL 5.6 binary package..."
+        FILE_NAME=mysql-${mysql_5_6_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz
+      elif [ "${dbInstallMethods}" == "2" ]; then
+        echo "Download MySQL 5.5 source package..."
+        FILE_NAME=mysql-${mysql_5_6_version}.tar.gz
+      fi
+      wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME}
+      wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5
+      MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
+      while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MYSQL_TAR_MD5}" ];do
+        wget -4c --no-check-certificate ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME};sleep 1
+        [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MYSQL_TAR_MD5}" ] && break || continue
+      done
+    fi
+  
+    if [ "${DB_version}" == "3" ]; then
+      # mysql 5.5
+      if [ "${IPADDR_COUNTRY}"x == "CN"x -a "${IPADDR_ISP}" == 'aliyun' -a "$(../include/check_port.py aliyun-oss.linuxeye.com 80)" == 'True' ]; then
+        DOWN_ADDR_MYSQL=http://aliyun-oss.linuxeye.com/mysql/MySQL-5.5
+      else
+        if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
+          if [ "$(../include/check_port.py mirrors.tuna.tsinghua.edu.cn 443)" == 'True' ]; then
+            DOWN_ADDR_MYSQL=https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.5
+          else
+            DOWN_ADDR_MYSQL=http://mirrors.sohu.com/mysql/MySQL-5.5
+            DOWN_ADDR_MYSQL_BK=${DOWN_ADDR_MYSQL}
+          fi
+        else
+          if [ "$(../include/check_port.py cdn.mysql.com 80)" == 'True' ]; then
+            DOWN_ADDR_MYSQL=http://cdn.mysql.com/Downloads/MySQL-5.5
+          else
+            DOWN_ADDR_MYSQL=http://mysql.he.net/Downloads/MySQL-5.5
+            DOWN_ADDR_MYSQL_BK=${DOWN_ADDR_MYSQL}
+          fi
+        fi
+      fi
+      if [ "${dbInstallMethods}" == "1" ]; then
+        echo "Download MySQL 5.5 binary package..."
+        FILE_NAME=mysql-${mysql_5_5_version}-linux2.6-${SYS_BIT_b}.tar.gz
+      elif [ "${dbInstallMethods}" == "2" ]; then
+        echo "Download MySQL 5.5 source package..."
+        FILE_NAME=mysql-${mysql_5_5_version}.tar.gz
+        src_url=${mirrorLink}/mysql-5.5-fix-arm-client_plugin.patch && Download_src
+      fi
+      wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME}
+      wget --tries=6 -c --no-check-certificate ${DOWN_ADDR_MYSQL}/${FILE_NAME}.md5
+      MYSQL_TAR_MD5=$(awk '{print $1}' ${FILE_NAME}.md5)
+  
+      while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MYSQL_TAR_MD5}" ];do
+        wget -c --no-check-certificate ${DOWN_ADDR_MYSQL_BK}/${FILE_NAME};sleep 1
+        [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MYSQL_TAR_MD5}" ] && break || continue
+      done
+    fi
+  
+    if [ "${DB_version}" == "4" ]; then
+      # mariaDB 10.1
+      if [ "${dbInstallMethods}" == "1" ]; then
+        echo "Download MariaDB 10.1 binary package..."
+        FILE_NAME=mariadb-${mariadb_10_1_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz
+        if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
+          DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_10_1_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}
+          MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
+          [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb_10_1_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); }
+        else
+          DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb_10_1_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}
+          MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb_10_1_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}/md5sums.txt |  grep ${FILE_NAME} | awk '{print $1}')
+        fi
+      elif [ "${dbInstallMethods}" == "2" ]; then
+        echo "Download MariaDB 10.1 source package..."
+        FILE_NAME=mariadb-${mariadb_10_1_version}.tar.gz
+        if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
+          DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_10_1_version}/source
+          MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
+          [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb_10_1_version}/source; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); }
+        else
+          DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb_10_1_version}/source
+          MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb_10_1_version}/source/md5sums.txt |  grep ${FILE_NAME} | awk '{print $1}')
+        fi
+      fi
+      tryDlCount=0
+      while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MARAIDB_TAR_MD5}" ];do
+        wget -c --no-check-certificate ${DOWN_ADDR_MARIADB}/${FILE_NAME};sleep 1
+        let "tryDlCount++"
+        [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MARAIDB_TAR_MD5}" -o "${tryDlCount}" == "6" ] && break || continue
+      done
+      if [ "${tryDlCount}" == "6" ]; then
+        echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
+        kill -9 $$
+      else
+        echo "[${CMSG}${FILE_NAME}${CEND}] found."
+      fi
+    fi
+  
+    if [ "${DB_version}" == "5" ]; then
+      # mariaDB 10.0
+      if [ "${dbInstallMethods}" == "1" ]; then
+        echo "Download MariaDB 10.0 binary package..."
+        FILE_NAME=mariadb-${mariadb_10_0_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz
+        if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
+          DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_10_0_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}
+          MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
+          [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb_10_0_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); }
+        else
+          DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb_10_0_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}
+          MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb_10_0_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}/md5sums.txt |  grep ${FILE_NAME} | awk '{print $1}')
+        fi
+      elif [ "${dbInstallMethods}" == "2" ]; then
+        echo "Download MariaDB 10.0 source package..."
+        FILE_NAME=mariadb-${mariadb_10_0_version}.tar.gz
+        if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
+          DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_10_0_version}/source
+          MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
+          [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb_10_0_version}/source; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); }
+        else
+          DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb_10_0_version}/source
+          MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb_10_0_version}/source/md5sums.txt |  grep ${FILE_NAME} | awk '{print $1}')
+        fi
+      fi
+      tryDlCount=0
+      while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MARAIDB_TAR_MD5}" ];do
+        wget -c --no-check-certificate ${DOWN_ADDR_MARIADB}/${FILE_NAME};sleep 1
+        let "tryDlCount++"
+        [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MARAIDB_TAR_MD5}" -o "${tryDlCount}" == "6" ] && break || continue
+      done
+      if [ "${tryDlCount}" == "6" ]; then
+          echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
+          kill -9 $$
+      else
+          echo "[${CMSG}${FILE_NAME}${CEND}] found."
+      fi
+    fi
+    if [ "${DB_version}" == "6" ]; then
+      # mariaDB 5.5
+      if [ "${dbInstallMethods}" == "1" ]; then
+        echo "Download MariaDB 5.5 binary package..."
+        FILE_NAME=mariadb-${mariadb_5_5_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz
+        if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
+          DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_5_5_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}
+          MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
+          [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb_5_5_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); }
+        else
+          DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb_5_5_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}
+          MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb_5_5_version}/bintar-${GLIBC_FLAG}-${SYS_BIT_a}/md5sums.txt |  grep ${FILE_NAME} | awk '{print $1}')
+        fi
+      elif [ "${dbInstallMethods}" == "2" ]; then
+        echo "Download MariaDB 5.5 source package..."
+        FILE_NAME=mariadb-${mariadb_5_5_version}.tar.gz
+        if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
+          DOWN_ADDR_MARIADB=https://mirrors.tuna.tsinghua.edu.cn/mariadb/mariadb-${mariadb_5_5_version}/source
+          MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}')
+          [ -z "${MARAIDB_TAR_MD5}" ] && { DOWN_ADDR_MARIADB=https://mirrors.ustc.edu.cn/mariadb/mariadb-${mariadb_5_5_version}/source; MARAIDB_TAR_MD5=$(curl -Lk ${DOWN_ADDR_MARIADB}/md5sums.txt | grep ${FILE_NAME} | awk '{print $1}'); }
+        else
+          DOWN_ADDR_MARIADB=https://downloads.mariadb.org/interstitial/mariadb-${mariadb_5_5_version}/source
+          MARAIDB_TAR_MD5=$(curl -Lk http://archive.mariadb.org/mariadb-${mariadb_5_5_version}/source/md5sums.txt |  grep ${FILE_NAME} | awk '{print $1}')
+        fi
+      fi
+      tryDlCount=0
+      while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${MARAIDB_TAR_MD5}" ];do
+        wget -c --no-check-certificate ${DOWN_ADDR_MARIADB}/${FILE_NAME};sleep 1
+        let "tryDlCount++"
+        [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${MARAIDB_TAR_MD5}" -o "${tryDlCount}" == "6" ] && break || continue
+      done
+      if [ "${tryDlCount}" == "6" ]; then
+        echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
+        kill -9 $$
+      else
+        echo "[${CMSG}${FILE_NAME}${CEND}] found."
+      fi
     fi
     fi
+  
+    if [ "${DB_version}" == "7" ]; then
+      # precona 5.7
+      if [ "${dbInstallMethods}" == "1" ]; then
+        echo "Download Percona 5.7 binary package..."
+        FILE_NAME=Percona-Server-${percona_5_7_version}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz
+        DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-${percona_5_7_version}/binary/tarball
+        PERCONA_TAR_MD5=$(curl -Lk https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-${percona_5_7_version}/binary/tarball/${FILE_NAME}.md5sum |  grep ${FILE_NAME} | awk '{print $1}')
+      elif [ "${dbInstallMethods}" == "2" ]; then
+        echo "Download Percona 5.7 source package..."
+        FILE_NAME=percona-server-${percona_5_7_version}.tar.gz
+        if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
+          DOWN_ADDR_PERCONA=${mirrorLink}
+          DOWN_ADDR_PERCONA_2=https://www.percona.com/downloads/Percona-Server-5.7/source/tarball
+          PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_2}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
+          [ -z "${PERCONA_TAR_MD5}" ] && { DOWN_ADDR_PERCONA=${mirrorLink}; PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_2}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}'); }
+        else
+          DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-${percona_5_7_version}/source/tarball
+          PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA}/${FILE_NAME}.md5sum |  grep ${FILE_NAME} | awk '{print $1}')
+        fi
+      fi
+      tryDlCount=0
+      while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PERCONA_TAR_MD5}" ];do
+        wget -c --no-check-certificate ${DOWN_ADDR_PERCONA}/${FILE_NAME};sleep 1
+        let "tryDlCount++"
+        [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${PERCONA_TAR_MD5}" -o "${tryDlCount}" == "6" ] && break || continue
+      done
+      if [ "${tryDlCount}" == "6" ]; then
+        echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
+        kill -9 $$
+      else
+        echo "[${CMSG}${FILE_NAME}${CEND}] found."
+      fi
+    fi
+  
+    if [ "${DB_version}" == "8" ]; then
+      # precona 5.6
+      if [ "${dbInstallMethods}" == "1" ]; then
+        echo "Download Percona 5.6 binary package..."
+        perconaVerStr1=$(echo ${percona_5_6_version} | sed "s@-@-rel@")
+        FILE_NAME=Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz
+        DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-${percona_5_6_version}/binary/tarball
+        PERCONA_TAR_MD5=$(curl -Lk https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-${percona_5_6_version}/binary/tarball/${FILE_NAME}.md5sum |  grep ${FILE_NAME} | awk '{print $1}')
+      elif [ "${dbInstallMethods}" == "2" ]; then
+        echo "Download Percona 5.6 source package..."
+        FILE_NAME=percona-server-${percona_5_6_version}.tar.gz
+        if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
+          DOWN_ADDR_PERCONA=${mirrorLink}
+          DOWN_ADDR_PERCONA_2=https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-${percona_5_6_version}/source/tarball
+          PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_2}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
+          [ -z "${PERCONA_TAR_MD5}" ] && { DOWN_ADDR_PERCONA=${mirrorLink}; PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_2}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}'); }
+        else
+          DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.6/Percona-Server-${percona_5_6_version}/source/tarball
+          PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA}/${FILE_NAME}.md5sum |  grep ${FILE_NAME} | awk '{print $1}')
+        fi
+      fi
+      tryDlCount=0
+      while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PERCONA_TAR_MD5}" ];do
+        wget -c --no-check-certificate ${DOWN_ADDR_PERCONA}/${FILE_NAME};sleep 1
+        let "tryDlCount++"
+        [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${PERCONA_TAR_MD5}" -o "${tryDlCount}" == "6" ] && break || continue
+      done
+      if [ "${tryDlCount}" == "6" ]; then
+        echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
+        kill -9 $$
+      else
+        echo "[${CMSG}${FILE_NAME}${CEND}] found."
+      fi
+    fi
+  
+    if [ "${DB_version}" == "9" ]; then
+      # precona 5.5
+      if [ "${dbInstallMethods}" == "1" ]; then
+        echo "Download Percona 5.5 binary package..."
+        perconaVerStr1=$(echo ${percona_5_5_version} | sed "s@-@-rel@")
+        FILE_NAME=Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz
+        DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona_5_5_version}/binary/tarball
+        PERCONA_TAR_MD5=$(curl -Lk https://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona_5_5_version}/binary/tarball/${FILE_NAME}.md5sum |  grep ${FILE_NAME} | awk '{print $1}')
+      elif [ "${dbInstallMethods}" == "2" ]; then
+        echo "Download Percona 5.5 source package..."
+        FILE_NAME=percona-server-${percona_5_5_version}.tar.gz
+        if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
+          DOWN_ADDR_PERCONA=${mirrorLink}
+          DOWN_ADDR_PERCONA_2=https://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona_5_5_version}/source/tarball
+          PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_2}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
+          [ -z "${PERCONA_TAR_MD5}" ] && { DOWN_ADDR_PERCONA=${mirrorLink}; PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA_2}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}'); }
+        else
+          DOWN_ADDR_PERCONA=https://www.percona.com/downloads/Percona-Server-5.5/Percona-Server-${percona_5_5_version}/source/tarball
+          PERCONA_TAR_MD5=$(curl -Lk ${DOWN_ADDR_PERCONA}/${FILE_NAME}.md5sum | grep ${FILE_NAME} | awk '{print $1}')
+        fi
+      fi
+      tryDlCount=0
+      while [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" != "${PERCONA_TAR_MD5}" ];do
+        wget -c --no-check-certificate ${DOWN_ADDR_PERCONA}/${FILE_NAME};sleep 1
+        let "tryDlCount++"
+        [ "$(md5sum ${FILE_NAME} | awk '{print $1}')" == "${PERCONA_TAR_MD5}" -o "${tryDlCount}" == "6" ] && break || continue
+      done
+  
+      if [ "${tryDlCount}" == "6" ]; then
+        echo "${CFAILURE}${FILE_NAME} download failed, Please contact the author! ${CEND}"
+        kill -9 $$
+      else
+        echo "[${CMSG}${FILE_NAME}${CEND}] found."
+      fi
+    fi
+  fi
+  # PHP
+  if [ "${PHP_yn}" == "y" ]; then
+    # php 5.3 5.4 5.5 5.6 5.7
+    echo "PHP common..."
+    src_url=http://ftp.gnu.org/pub/gnu/libiconv/libiconv-${libiconv_version}.tar.gz && Download_src
+    src_url=https://curl.haxx.se/download/curl-${curl_version}.tar.gz && Download_src
+    src_url=http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/${libmcrypt_version}/libmcrypt-${libmcrypt_version}.tar.gz && Download_src
+    src_url=http://downloads.sourceforge.net/project/mhash/mhash/${mhash_version}/mhash-${mhash_version}.tar.gz && Download_src
+    src_url=http://downloads.sourceforge.net/project/mcrypt/MCrypt/${mcrypt_version}/mcrypt-${mcrypt_version}.tar.gz && Download_src
+    src_url=${mirrorLink}/libiconv-glibc-2.16.patch && Download_src
     
     
-    if [ "${je_tc_malloc_yn}" == "y" ];then
-        if [ "${je_tc_malloc}" == "1" ];then
-            echo "Download jemalloc..."
-            src_url=${mirrorLink}/jemalloc-${jemalloc_version}.tar.bz2 && Download_src
-        elif [ "${je_tc_malloc}" == "2" ];then
-            echo "Download tcmalloc..."
-            src_url=${mirrorLink}/gperftools-${tcmalloc_version}.tar.gz && Download_src
-        fi
+    if [[ "${PHP_version}" =~ ^[1-3]$ ]]; then
+      # php 5.3 5.4 5.5
+      src_url=${mirrorLink}/fpm-race-condition.patch && Download_src
     fi
     fi
     
     
-    # others
-    if [ "${OS}" == "CentOS" ];then
-        echo "Download tmux for CentOS..."
-        src_url=${mirrorLink}/libevent-${libevent_version}.tar.gz && Download_src
-        src_url=${mirrorLink}/tmux-${tmux_version}.tar.gz && Download_src
-      
-        echo "Download htop for CentOS..."
-        src_url=http://hisham.hm/htop/releases/${htop_version}/htop-${htop_version}.tar.gz && Download_src
+    if [ "${PHP_version}" == "1" ]; then
+      # php 5.3
+      src_url=${mirrorLink}/debian_patches_disable_SSLv2_for_openssl_1_0_0.patch && Download_src
+      src_url=${mirrorLink}/php5.3patch && Download_src
+      if [ "$Debian_version" == '8' -o "$Ubuntu_version" == '16' ]; then
+        if [ ! -e "/usr/local/openssl/lib/libcrypto.a" ]; then
+          src_url=${mirrorLink}/openssl-1.0.0s.tar.gz && Download_src
+        fi
+      fi
+      src_url=http://www.php.net/distributions/php-${php_3_version}.tar.gz && Download_src
+    fi
+    if [ "${PHP_version}" == "2" ]; then
+      src_url=http://www.php.net/distributions/php-${php_4_version}.tar.gz && Download_src
+    fi
+    if [ "${PHP_version}" == "3" ]; then
+      src_url=http://www.php.net/distributions/php-${php_5_version}.tar.gz && Download_src
+    fi
+    if [ "${PHP_version}" == "4" ]; then
+      src_url=http://www.php.net/distributions/php-${php_6_version}.tar.gz && Download_src
+    fi
+    if [ "${PHP_version}" == "5" ]; then
+      src_url=http://www.php.net/distributions/php-${php_7_version}.tar.gz && Download_src
+    fi
+  fi
+    
+  # PHP OPCache
+  if [ "${PHP_cache}" == "1" ] && [[ "$PHP_version" =~ ^[1,2]$ ]]; then
+    # php 5.3 5.4
+    echo "Download Zend OPCache..."
+    src_url=https://pecl.php.net/get/zendopcache-${zendopcache_version}.tgz && Download_src
+  fi
+  if [ "${PHP_cache}" == "2" ] && [[ "$PHP_version" =~ ^[1-4]$ ]]; then
+    # php 5.3 5.4 5.5 5.6
+    echo "Download xcache..."
+    src_url=http://xcache.lighttpd.net/pub/Releases/${xcache_version}/xcache-${xcache_version}.tar.gz && Download_src
+  fi
+  if [ "${PHP_cache}" == "3" ]; then
+    # php 5.3 5.4 5.5 5.6 7.0
+    echo "Download apcu..."
+    if [ "${PHP_version}" != "5" ]; then
+      src_url=http://pecl.php.net/get/apcu-${apcu_version}.tgz && Download_src
+    else
+      src_url=http://pecl.php.net/get/apcu-${apcu_for_php7_version}.tgz && Download_src
+    fi
+  fi
+  if [ "${PHP_cache}" == "4" -a "${PHP_version}" == "2" ]; then
+    echo "Download eaccelerator 1.0 dev..."
+    src_url=https://github.com/eaccelerator/eaccelerator/tarball/master && Download_src
+  elif [ "${PHP_cache}" == "4" -a "${PHP_version}" == "1" ]; then
+    echo "Download eaccelerator 0.9..."
+    src_url=https://github.com/downloads/eaccelerator/eaccelerator/eaccelerator-${eaccelerator_version}.tar.bz2 && Download_src
+  fi
+  
+  # Zend Guard Loader
+  if [ "${ZendGuardLoader_yn}" == "y" -a "${armPlatform}" != "y" ]; then
+    if [ "${PHP_version}" == "4" ]; then
+      if [ "${OS_BIT}" == "64" ]; then
+        # 64 bit
+        echo "Download ZendGuardLoader for php 5.6..."
+        src_url=${mirrorLink}/zend-loader-php5.6-linux-x86_64.tar.gz && Download_src
+      else
+        # 32 bit
+        echo "Download ZendGuardLoader for php 5.6..."
+        src_url=${mirrorLink}/zend-loader-php5.6-linux-i386.tar.gz && Download_src
+      fi
+    fi
+    if [ "${PHP_version}" == "3" ]; then
+      if [ "${OS_BIT}" == "64" ]; then
+        # 64 bit
+        echo "Download ZendGuardLoader for php 5.5..."
+        src_url=${mirrorLink}/zend-loader-php5.5-linux-x86_64.tar.gz && Download_src
+      else
+        # 32 bit
+        echo "Download ZendGuardLoader for php 5.5..."
+        src_url=${mirrorLink}/zend-loader-php5.5-linux-i386.tar.gz && Download_src
+      fi
+    fi
+    if [ "${PHP_version}" == "2" ]; then
+      if [ "${OS_BIT}" == "64" ]; then
+        # 64 bit
+        echo "Download ZendGuardLoader for php 5.4..."
+        src_url=${mirrorLink}/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-x86_64.tar.gz && Download_src
+      else
+        # 32 bit
+        echo "Download ZendGuardLoader for php 5.4..."
+        src_url=${mirrorLink}/ZendGuardLoader-70429-PHP-5.4-linux-glibc23-i386.tar.gz && Download_src
+      fi
+    fi
+    if [ "${PHP_version}" == "1" ]; then
+      if [ "${OS_BIT}" == "64" ]; then
+        # 64 bit
+        echo "Download ZendGuardLoader for php 5.3..."
+        src_url=${mirrorLink}/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz && Download_src
+      else
+        # 32 bit
+        echo "Download ZendGuardLoader for php 5.3..."
+        src_url=${mirrorLink}/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz && Download_src
+      fi
+    fi
+  fi
+  
+  if [ "${ionCube_yn}" == "y" ]; then
+    echo "Download ioncube..."
+    if [ "${OS_BIT}" == '64' ]; then
+      src_url=http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz && Download_src
+    else
+      if [ "${TARGET_ARCH}" == "armv7" ]; then
+        src_url=http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_armv7l.tar.gz && Download_src
+      else
+        src_url=http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz && Download_src
+      fi
+    fi
+  fi
+  
+  if [ "${Magick_yn}" == "y" ]; then
+    if [ "${Magick}" == "1" ]; then
+      echo "Download ImageMagick..."
+      src_url=${mirrorLink}/ImageMagick-${ImageMagick_version}.tar.gz && Download_src
+      if [ "${PHP_version}" == "1" ]; then 
+        echo "Download image for php 5.3..."
+        src_url=https://pecl.php.net/get/imagick-${imagick_for_php53_version}.tgz && Download_src
+      else 
+        echo "Download imagick..."
+        src_url=http://pecl.php.net/get/imagick-${imagick_version}.tgz && Download_src
+      fi
+    else
+      echo "Download graphicsmagick..."
+      src_url=http://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/${GraphicsMagick_version}/GraphicsMagick-${GraphicsMagick_version}.tar.gz && Download_src
+      if [ "${PHP_version}" == "5" ]; then 
+        echo "Download gmagick for php7..."
+        src_url=https://pecl.php.net/get/gmagick-${gmagick_for_php7_version}.tgz && Download_src
+      else
+        echo "Download gmagick for php..."
+        src_url=http://pecl.php.net/get/gmagick-${gmagick_version}.tgz && Download_src
+      fi
+    fi
+  fi
+  
+  if [ "${FTP_yn}" == "y" ]; then
+    echo "Download pureftpd..."
+    src_url=http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-${pureftpd_version}.tar.gz && Download_src
+  fi
+  
+  if [ "${phpMyAdmin_yn}" == "y" ]; then
+    echo "Download phpMyAdmin..."
+    src_url=https://files.phpmyadmin.net/phpMyAdmin/${phpMyAdmin_version}/phpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz && Download_src
+  fi
+  
+  if [ "${redis_yn}" == "y" ]; then
+    echo "Download redis..."
+    src_url=http://download.redis.io/releases/redis-${redis_version}.tar.gz && Download_src
+    if [ "${OS}" == "CentOS" ]; then
+      echo "Download start-stop-daemon.c for CentOS..."
+      src_url=${mirrorLink}/start-stop-daemon.c && Download_src
+    fi
+    # redis addon
+    if [ "${PHP_version}" == "5" ]; then
+      echo "Download redis pecl for php7..."
+      src_url=http://pecl.php.net/get/redis-${redis_pecl_for_php7_version}.tgz && Download_src
+    else
+      echo "Download redis pecl..."
+      src_url=http://pecl.php.net/get/redis-${redis_pecl_version}.tgz && Download_src
+    fi
+  fi
+  
+  if [ "${memcached_yn}" == "y" ]; then
+    echo "Download memcached..."
+    src_url=http://www.memcached.org/files/memcached-${memcached_version}.tar.gz && Download_src
+    if [ "${PHP_version}" == "5" ]; then
+      echo "Download pecl memcache for php7..."
+      src_url=${mirrorLink}/pecl-memcache-php7.tgz && Download_src
+      echo "Download php-memcached for php7..."
+      src_url=${mirrorLink}/php-memcached-php7.tgz && Download_src
+    else
+      echo "Download pecl memcache for php7..."
+      src_url=http://pecl.php.net/get/memcache-${memcache_pecl_version}.tgz && Download_src
+      echo "Download php-memcached for php7..."
+      src_url=http://pecl.php.net/get/memcached-${memcached_pecl_version}.tgz && Download_src
     fi
     fi
     
     
-    if [[ "${Ubuntu_version}" =~ ^14$|^15$ ]];then
-        echo "Download bison for Ubuntu..."
-        src_url=http://ftp.gnu.org/gnu/bison/bison-${bison_version}.tar.gz && Download_src
+    echo "Download libmemcached..."
+    src_url=https://launchpad.net/libmemcached/1.0/${libmemcached_version}/+download/libmemcached-${libmemcached_version}.tar.gz && Download_src
+  fi
+  
+  if [ "${je_tc_malloc_yn}" == "y" ]; then
+    if [ "${je_tc_malloc}" == "1" ]; then
+      echo "Download jemalloc..."
+      src_url=${mirrorLink}/jemalloc-${jemalloc_version}.tar.bz2 && Download_src
+    elif [ "${je_tc_malloc}" == "2" ]; then
+      echo "Download tcmalloc..."
+      src_url=${mirrorLink}/gperftools-${tcmalloc_version}.tar.gz && Download_src
     fi
     fi
+  fi
+  
+  # others
+  if [ "${OS}" == "CentOS" ]; then
+    echo "Download tmux for CentOS..."
+    src_url=${mirrorLink}/libevent-${libevent_version}.tar.gz && Download_src
+    src_url=${mirrorLink}/tmux-${tmux_version}.tar.gz && Download_src
     
     
-    popd
+    echo "Download htop for CentOS..."
+    src_url=http://hisham.hm/htop/releases/${htop_version}/htop-${htop_version}.tar.gz && Download_src
+  fi
+  
+  if [[ "${Ubuntu_version}" =~ ^14$|^15$ ]]; then
+    echo "Download bison for Ubuntu..."
+    src_url=http://ftp.gnu.org/gnu/bison/bison-${bison_version}.tar.gz && Download_src
+  fi
+  popd
 }
 }

+ 50 - 50
include/check_os.sh

@@ -8,51 +8,51 @@
 #       https://oneinstack.com
 #       https://oneinstack.com
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
-if [ -n "$(grep 'Aliyun Linux release' /etc/issue)" -o -e /etc/redhat-release ];then
-    OS=CentOS
-    [ -n "$(grep ' 7\.' /etc/redhat-release)" ] && CentOS_RHEL_version=7
-    [ -n "$(grep ' 6\.' /etc/redhat-release)" -o -n "$(grep 'Aliyun Linux release6 15' /etc/issue)" ] && CentOS_RHEL_version=6
-    [ -n "$(grep ' 5\.' /etc/redhat-release)" -o -n "$(grep 'Aliyun Linux release5' /etc/issue)" ] && CentOS_RHEL_version=5
-elif [ -n "$(grep 'Amazon Linux AMI release' /etc/issue)" -o -e /etc/system-release ];then
-    OS=CentOS
-    CentOS_RHEL_version=6
-elif [ -n "$(grep bian /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == 'Debian' ];then
-    OS=Debian
-    [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
-    Debian_version=$(lsb_release -sr | awk -F. '{print $1}')
-elif [ -n "$(grep Deepin /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == 'Deepin' ];then
-    OS=Debian
-    [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
-    Debian_version=$(lsb_release -sr | awk -F. '{print $1}')
-elif [ -n "$(grep Ubuntu /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == 'Ubuntu' -o -n "$(grep 'Linux Mint' /etc/issue)" ];then
-    OS=Ubuntu
-    [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
-    Ubuntu_version=$(lsb_release -sr | awk -F. '{print $1}')
-    [ -n "$(grep 'Linux Mint 18' /etc/issue)" ] && Ubuntu_version=16
+if [ -n "$(grep 'Aliyun Linux release' /etc/issue)" -o -e /etc/redhat-release ]; then
+  OS=CentOS
+  [ -n "$(grep ' 7\.' /etc/redhat-release)" ] && CentOS_RHEL_version=7
+  [ -n "$(grep ' 6\.' /etc/redhat-release)" -o -n "$(grep 'Aliyun Linux release6 15' /etc/issue)" ] && CentOS_RHEL_version=6
+  [ -n "$(grep ' 5\.' /etc/redhat-release)" -o -n "$(grep 'Aliyun Linux release5' /etc/issue)" ] && CentOS_RHEL_version=5
+elif [ -n "$(grep 'Amazon Linux AMI release' /etc/issue)" -o -e /etc/system-release ]; then
+  OS=CentOS
+  CentOS_RHEL_version=6
+elif [ -n "$(grep bian /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == 'Debian' ]; then
+  OS=Debian
+  [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
+  Debian_version=$(lsb_release -sr | awk -F. '{print $1}')
+elif [ -n "$(grep Deepin /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == 'Deepin' ]; then
+  OS=Debian
+  [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
+  Debian_version=$(lsb_release -sr | awk -F. '{print $1}')
+elif [ -n "$(grep Ubuntu /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == 'Ubuntu' -o -n "$(grep 'Linux Mint' /etc/issue)" ]; then
+  OS=Ubuntu
+  [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
+  Ubuntu_version=$(lsb_release -sr | awk -F. '{print $1}')
+  [ -n "$(grep 'Linux Mint 18' /etc/issue)" ] && Ubuntu_version=16
 else
 else
-    echo "${CFAILURE}Does not support this OS, Please contact the author! ${CEND}"
-    kill -9 $$
+  echo "${CFAILURE}Does not support this OS, Please contact the author! ${CEND}"
+  kill -9 $$
 fi
 fi
 
 
 if uname -m | grep -Eqi "arm"; then
 if uname -m | grep -Eqi "arm"; then
-    armPlatform="y"
-    if uname -m | grep -Eqi "armv7"; then
-        TARGET_ARCH="armv7"
-    elif uname -m | grep -Eqi "armv8"; then
-        TARGET_ARCH="arm64"
-    else
-        TARGET_ARCH="unknown"
-    fi
+  armPlatform="y"
+  if uname -m | grep -Eqi "armv7"; then
+    TARGET_ARCH="armv7"
+  elif uname -m | grep -Eqi "armv8"; then
+    TARGET_ARCH="arm64"
+  else
+    TARGET_ARCH="unknown"
+  fi
 fi
 fi
 
 
-if [ $(getconf WORD_BIT) == 32 ] && [ $(getconf LONG_BIT) == 64 ];then
-    OS_BIT=64
-    SYS_BIG_FLAG=x64 #jdk
-    SYS_BIT_a=x86_64;SYS_BIT_b=x86_64; #mariadb
+if [ $(getconf WORD_BIT) == 32 ] && [ $(getconf LONG_BIT) == 64 ]; then
+  OS_BIT=64
+  SYS_BIG_FLAG=x64 #jdk
+  SYS_BIT_a=x86_64;SYS_BIT_b=x86_64; #mariadb
 else
 else
-    OS_BIT=32
-    SYS_BIG_FLAG=i586
-    SYS_BIT_a=x86;SYS_BIT_b=i686;
+  OS_BIT=32
+  SYS_BIG_FLAG=i586
+  SYS_BIT_a=x86;SYS_BIT_b=i686;
 fi
 fi
 
 
 LIBC_YN=$(awk -v A=$(getconf -a | grep GNU_LIBC_VERSION | awk '{print $NF}') -v B=2.14 'BEGIN{print(A>=B)?"0":"1"}')
 LIBC_YN=$(awk -v A=$(getconf -a | grep GNU_LIBC_VERSION | awk '{print $NF}') -v B=2.14 'BEGIN{print(A>=B)?"0":"1"}')
@@ -61,16 +61,16 @@ LIBC_YN=$(awk -v A=$(getconf -a | grep GNU_LIBC_VERSION | awk '{print $NF}') -v
 THREAD=$(grep 'processor' /proc/cpuinfo | sort -u | wc -l)
 THREAD=$(grep 'processor' /proc/cpuinfo | sort -u | wc -l)
 
 
 # Percona
 # Percona
-if [ -f "/usr/lib/x86_64-linux-gnu/libssl.so.1.0.0" ];then
-    if [ "${Debian_version}" == "6" ];then
-        sslLibVer=ssl098
-    else
-        sslLibVer=ssl100
-    fi
-elif [ -f "/usr/lib64/libssl.so.10" ];then
-    if [ "${CentOS_RHEL_version}" == "5" ];then
-        sslLibVer=ssl098e
-    else
-        sslLibVer=ssl101
-    fi
+if [ -f "/usr/lib/x86_64-linux-gnu/libssl.so.1.0.0" ]; then
+  if [ "${Debian_version}" == "6" ]; then
+    sslLibVer=ssl098
+  else
+    sslLibVer=ssl100
+  fi
+elif [ -f "/usr/lib64/libssl.so.10" ]; then
+  if [ "${CentOS_RHEL_version}" == "5" ]; then
+    sslLibVer=ssl098e
+  else
+    sslLibVer=ssl101
+  fi
 fi
 fi

+ 9 - 9
include/check_port.py

@@ -1,13 +1,13 @@
 #!/usr/bin/env python
 #!/usr/bin/env python
 import sys,os,socket
 import sys,os,socket
 def IsOpen(ip,port):
 def IsOpen(ip,port):
-    socket.setdefaulttimeout(5)
-    s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
-    try:
-        s.connect((ip,int(port)))
-        s.shutdown(2)
-        print True
-    except:
-        print False
+  socket.setdefaulttimeout(5)
+  s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
+  try:
+    s.connect((ip,int(port)))
+    s.shutdown(2)
+    print True
+  except:
+    print False
 if __name__ == '__main__':
 if __name__ == '__main__':
-    IsOpen(sys.argv[1],int(sys.argv[2]))
+  IsOpen(sys.argv[1],int(sys.argv[2]))

+ 5 - 5
include/color.sh

@@ -10,11 +10,11 @@
 
 
 echo=echo
 echo=echo
 for cmd in echo /bin/echo; do
 for cmd in echo /bin/echo; do
-    $cmd >/dev/null 2>&1 || continue
-    if ! $cmd -e "" | grep -qE '^-e';then
-        echo=$cmd
-        break
-    fi
+  $cmd >/dev/null 2>&1 || continue
+  if ! $cmd -e "" | grep -qE '^-e'; then
+    echo=$cmd
+    break
+  fi
 done
 done
 CSI=$($echo -e "\033[")
 CSI=$($echo -e "\033[")
 CEND="${CSI}0m"
 CEND="${CSI}0m"

+ 32 - 26
include/demo.sh

@@ -9,36 +9,42 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 DEMO() {
 DEMO() {
-cd $oneinstack_dir/src
+  pushd ${oneinstack_dir}/src
 
 
-[ "$IPADDR_COUNTRY"x == "CN"x ] && /bin/cp ../config/index_cn.html $wwwroot_dir/default/index.html || /bin/cp ../config/index.html $wwwroot_dir/default
+  [ "${IPADDR_COUNTRY}"x == "CN"x ] && /bin/cp ${oneinstack_dir}/config/index_cn.html ${wwwroot_dir}/default/index.html || /bin/cp ${oneinstack_dir}/config/index.html ${wwwroot_dir}/default
 
 
-if [ -e "$php_install_dir/bin/php" ];then
-    if [ "$IPADDR_COUNTRY"x == "CN"x ];then
-        src_url=http://mirrors.linuxeye.com/oneinstack/src/tz.zip && Download_src
-        unzip -q tz.zip -d $wwwroot_dir/default
+  if [ -e "${php_install_dir}/bin/php" ]; then
+    if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
+      src_url=http://mirrors.linuxeye.com/oneinstack/src/tz.zip && Download_src
+      unzip -q tz.zip -d ${wwwroot_dir}/default
     else
     else
-        src_url=http://mirrors.linuxeye.com/oneinstack/src/tz_e.zip && Download_src
-        unzip -q tz_e.zip -d $wwwroot_dir/default;/bin/mv $wwwroot_dir/default/{tz_e.php,proberv.php}
-        sed -i 's@https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js@http://lib.sinaapp.com/js/jquery/1.7/jquery.min.js@' $wwwroot_dir/default/proberv.php
+      src_url=http://mirrors.linuxeye.com/oneinstack/src/tz_e.zip && Download_src
+      unzip -q tz_e.zip -d ${wwwroot_dir}/default;/bin/mv ${wwwroot_dir}/default/{tz_e.php,proberv.php}
+      sed -i 's@https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js@http://lib.sinaapp.com/js/jquery/1.7/jquery.min.js@' ${wwwroot_dir}/default/proberv.php
     fi
     fi
 
 
-    echo '<?php phpinfo() ?>' > $wwwroot_dir/default/phpinfo.php
-    if [ "$PHP_cache" == '1' ];then
+    echo '<?php phpinfo() ?>' > ${wwwroot_dir}/default/phpinfo.php
+    case "${PHP_cache}" in
+      1)
         src_url=http://mirrors.linuxeye.com/oneinstack/src/ocp.php && Download_src
         src_url=http://mirrors.linuxeye.com/oneinstack/src/ocp.php && Download_src
-        /bin/cp ocp.php $wwwroot_dir/default
-    elif [ "$PHP_cache" == '2' ];then
-        sed -i 's@<a href="/ocp.php" target="_blank" class="links">Opcache</a>@<a href="/xcache" target="_blank" class="links">xcache</a>@' $wwwroot_dir/default/index.html
-    elif [ "$PHP_cache" == '3' ];then
-        sed -i 's@<a href="/ocp.php" target="_blank" class="links">Opcache</a>@<a href="/apc.php" target="_blank" class="links">APC</a>@' $wwwroot_dir/default/index.html
-    elif [ "$PHP_cache" == '4' ];then
-        /bin/cp eaccelerator-*/control.php $wwwroot_dir/default
-        sed -i 's@<a href="/ocp.php" target="_blank" class="links">Opcache</a>@<a href="/control.php" target="_blank" class="links">eAccelerator</a>@' $wwwroot_dir/default/index.html
-    else
-        sed -i 's@<a href="/ocp.php" target="_blank" class="links">Opcache</a>@@' $wwwroot_dir/default/index.html
-    fi
-fi
-chown -R ${run_user}.$run_user $wwwroot_dir/default
-[ -e /usr/bin/systemctl ] && systemctl daemon-reload
-cd ..
+        /bin/cp ocp.php ${wwwroot_dir}/default
+        ;;
+      2)
+        sed -i 's@<a href="/ocp.php" target="_blank" class="links">Opcache</a>@<a href="/xcache" target="_blank" class="links">xcache</a>@' ${wwwroot_dir}/default/index.html
+        ;;
+      3)
+        sed -i 's@<a href="/ocp.php" target="_blank" class="links">Opcache</a>@<a href="/apc.php" target="_blank" class="links">APC</a>@' ${wwwroot_dir}/default/index.html
+        ;;
+      4)
+        /bin/cp eaccelerator-*/control.php ${wwwroot_dir}/default
+        sed -i 's@<a href="/ocp.php" target="_blank" class="links">Opcache</a>@<a href="/control.php" target="_blank" class="links">eAccelerator</a>@' ${wwwroot_dir}/default/index.html
+        ;;
+      *)
+        sed -i 's@<a href="/ocp.php" target="_blank" class="links">Opcache</a>@@' ${wwwroot_dir}/default/index.html
+        ;;
+    esac
+  fi
+  chown -R ${run_user}.${run_user} ${wwwroot_dir}/default
+  [ -e /usr/bin/systemctl ] && systemctl daemon-reload
+  popd
 }
 }

+ 5 - 5
include/download.sh

@@ -9,9 +9,9 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Download_src() {
 Download_src() {
-    [ -s "${src_url##*/}" ] && echo "[${CMSG}${src_url##*/}${CEND}] found" || { wget --tries=6 -c --no-check-certificate $src_url; sleep 1; }
-    if [ ! -e "${src_url##*/}" ];then
-        echo "${CFAILURE}${src_url##*/} download failed, Please contact the author! ${CEND}"
-        kill -9 $$
-    fi
+  [ -s "${src_url##*/}" ] && echo "[${CMSG}${src_url##*/}${CEND}] found" || { wget --tries=6 -c --no-check-certificate $src_url; sleep 1; }
+  if [ ! -e "${src_url##*/}" ]; then
+    echo "${CFAILURE}${src_url##*/} download failed, Please contact the author! ${CEND}"
+    kill -9 $$
+  fi
 }
 }

+ 19 - 21
include/eaccelerator-0.9.sh

@@ -9,18 +9,17 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_eAccelerator-0-9() {
 Install_eAccelerator-0-9() {
-    pushd $oneinstack_dir/src
-    phpExtensionDir=`$php_install_dir/bin/php-config --extension-dir`
-    tar jxf eaccelerator-${eaccelerator_version}.tar.bz2
-    pushd eaccelerator-${eaccelerator_version}
-    make clean
-    $php_install_dir/bin/phpize
-    ./configure --enable-eaccelerator=shared --with-php-config=$php_install_dir/bin/php-config
-    make -j ${THREAD} && make install
-    
-    if [ -f "${phpExtensionDir}/eaccelerator.so" ];then
-        mkdir /var/eaccelerator_cache;chown -R ${run_user}.$run_user /var/eaccelerator_cache
-        cat > $php_install_dir/etc/php.d/ext-eaccelerator.ini << EOF
+  pushd ${oneinstack_dir}/src
+  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
+  tar jxf eaccelerator-${eaccelerator_version}.tar.bz2
+  pushd eaccelerator-${eaccelerator_version}
+  ${php_install_dir}/bin/phpize
+  ./configure --enable-eaccelerator=shared --with-php-config=${php_install_dir}/bin/php-config
+  make -j ${THREAD} && make install
+  popd
+  if [ -f "${phpExtensionDir}/eaccelerator.so" ]; then
+    mkdir /var/eaccelerator_cache;chown -R ${run_user}.${run_user} /var/eaccelerator_cache
+    cat > ${php_install_dir}/etc/php.d/ext-eaccelerator.ini << EOF
 [eaccelerator]
 [eaccelerator]
 zend_extension=${phpExtensionDir}/eaccelerator.so
 zend_extension=${phpExtensionDir}/eaccelerator.so
 eaccelerator.shm_size=64
 eaccelerator.shm_size=64
@@ -40,13 +39,12 @@ eaccelerator.keys=disk_only
 eaccelerator.sessions=disk_only
 eaccelerator.sessions=disk_only
 eaccelerator.content=disk_only
 eaccelerator.content=disk_only
 EOF
 EOF
-        echo "${CSUCCESS}Accelerator module installed successfully! ${CEND}"
-        popd
-        [ -z "`grep 'kernel.shmmax = 67108864' /etc/sysctl.conf`" ] && echo 'kernel.shmmax = 67108864' >> /etc/sysctl.conf
-        sysctl -p
-        [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
-    else
-        echo "${CFAILURE}Accelerator module install failed, Please contact the author! ${CEND}"
-    fi
-    popd
+    echo "${CSUCCESS}Accelerator module installed successfully! ${CEND}"
+    [ -z "`grep 'kernel.shmmax = 67108864' /etc/sysctl.conf`" ] && echo 'kernel.shmmax = 67108864' >> /etc/sysctl.conf
+    sysctl -p
+    rm -rf eaccelerator-${eaccelerator_version}
+  else
+    echo "${CFAILURE}Accelerator module install failed, Please contact the author! ${CEND}"
+  fi
+  popd
 }
 }

+ 20 - 21
include/eaccelerator-1.0-dev.sh

@@ -9,18 +9,18 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_eAccelerator-1-0-dev() {
 Install_eAccelerator-1-0-dev() {
-    pushd $oneinstack_dir/src
-    phpExtensionDir=`$php_install_dir/bin/php-config --extension-dir`
-    /bin/mv master eaccelerator-eaccelerator-42067ac.tar.gz
-    tar xzf eaccelerator-eaccelerator-42067ac.tar.gz
-    pushd eaccelerator-eaccelerator-42067ac
-    make clean
-    $php_install_dir/bin/phpize
-    ./configure --enable-eaccelerator=shared --with-php-config=$php_install_dir/bin/php-config
-    make -j ${THREAD} && make install
-    if [ -f "${phpExtensionDir}/eaccelerator.so" ];then
-        mkdir /var/eaccelerator_cache;chown -R ${run_user}.$run_user /var/eaccelerator_cache
-        cat > $php_install_dir/etc/php.d/ext-eaccelerator.ini << EOF
+  pushd ${oneinstack_dir}/src
+  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
+  /bin/mv master eaccelerator-eaccelerator-42067ac.tar.gz
+  tar xzf eaccelerator-eaccelerator-42067ac.tar.gz
+  pushd eaccelerator-eaccelerator-42067ac
+  ${php_install_dir}/bin/phpize
+  ./configure --enable-eaccelerator=shared --with-php-config=${php_install_dir}/bin/php-config
+  make -j ${THREAD} && make install
+  popd
+  if [ -f "${phpExtensionDir}/eaccelerator.so" ]; then
+    mkdir /var/eaccelerator_cache;chown -R ${run_user}.${run_user} /var/eaccelerator_cache
+    cat > ${php_install_dir}/etc/php.d/ext-eaccelerator.ini << EOF
 [eaccelerator]
 [eaccelerator]
 zend_extension=${phpExtensionDir}/eaccelerator.so
 zend_extension=${phpExtensionDir}/eaccelerator.so
 eaccelerator.shm_size=64
 eaccelerator.shm_size=64
@@ -40,13 +40,12 @@ eaccelerator.keys=disk_only
 eaccelerator.sessions=disk_only
 eaccelerator.sessions=disk_only
 eaccelerator.content=disk_only
 eaccelerator.content=disk_only
 EOF
 EOF
-        echo "${CSUCCESS}Accelerator module installed successfully! ${CEND}"
-        popd 
-        [ -z "`grep 'kernel.shmmax = 67108864' /etc/sysctl.conf`" ] && echo 'kernel.shmmax = 67108864' >> /etc/sysctl.conf
-        sysctl -p
-        [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
-    else
-        echo "${CFAILURE}Accelerator module install failed, Please contact the author! ${CEND}"
-    fi
-    popd
+    echo "${CSUCCESS}Accelerator module installed successfully! ${CEND}"
+    rm -rf eaccelerator-eaccelerator-42067ac
+    [ -z "`grep 'kernel.shmmax = 67108864' /etc/sysctl.conf`" ] && echo 'kernel.shmmax = 67108864' >> /etc/sysctl.conf
+    sysctl -p
+  else
+    echo "${CFAILURE}Accelerator module install failed, Please contact the author! ${CEND}"
+  fi
+  popd
 }
 }

+ 17 - 17
include/get_ipaddr.py

@@ -1,22 +1,22 @@
 #!/usr/bin/env python
 #!/usr/bin/env python
 import socket
 import socket
 def Get_local_ip():
 def Get_local_ip():
-    """
-    Returns the actual ip of the local machine.
-    This code figures out what source address would be used if some traffic
-    were to be sent out to some well known address on the Internet. In this
-    case, a Google DNS server is used, but the specific address does not
-    matter much.  No traffic is actually sent.
-    """
-    try:
-        csock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
-        csock.connect(('8.8.8.8', 80))
-        (addr, port) = csock.getsockname()
-        csock.close()
-        return addr
-    except socket.error:
-        return "127.0.0.1"
+  """
+  Returns the actual ip of the local machine.
+  This code figures out what source address would be used if some traffic
+  were to be sent out to some well known address on the Internet. In this
+  case, a Google DNS server is used, but the specific address does not
+  matter much.  No traffic is actually sent.
+  """
+  try:
+    csock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
+    csock.connect(('8.8.8.8', 80))
+    (addr, port) = csock.getsockname()
+    csock.close()
+    return addr
+  except socket.error:
+    return "127.0.0.1"
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":
-    IPADDR = Get_local_ip()
-    print IPADDR
+  IPADDR = Get_local_ip()
+  print IPADDR

+ 10 - 10
include/get_ipaddr_state.py

@@ -2,14 +2,14 @@
 #coding:utf-8
 #coding:utf-8
 import sys,urllib2,socket
 import sys,urllib2,socket
 try:
 try:
-    socket.setdefaulttimeout(10)
-    apiurl = "http://ip.taobao.com/service/getIpInfo.php?ip=%s" % sys.argv[1]
-    content = urllib2.urlopen(apiurl).read()
-    data = eval(content)['data']
-    code = eval(content)['code']
-    if code == 0:
-        print data['country_id'],data['isp_id']
-    else:
-        print data
+  socket.setdefaulttimeout(10)
+  apiurl = "http://ip.taobao.com/service/getIpInfo.php?ip=%s" % sys.argv[1]
+  content = urllib2.urlopen(apiurl).read()
+  data = eval(content)['data']
+  code = eval(content)['code']
+  if code == 0:
+    print data['country_id'],data['isp_id']
+  else:
+    print data
 except:
 except:
-    print "Usage:%s IP" % sys.argv[0]
+  print "Usage:%s IP" % sys.argv[0]

+ 16 - 16
include/get_public_ipaddr.py

@@ -1,21 +1,21 @@
 #!/usr/bin/env python
 #!/usr/bin/env python
 import re,urllib2
 import re,urllib2
 class Get_public_ip:
 class Get_public_ip:
-    def getip(self):
-        try:
-            myip = self.visit("http://ip.chinaz.com/getip.aspx")
-        except:
-            try:
-                myip = self.visit("http://ipv4.icanhazip.com/")
-            except:
-                myip = "So sorry!!!"
-        return myip
-    def visit(self,url):
-        opener = urllib2.urlopen(url)
-        if url == opener.geturl():
-            str = opener.read()
-        return re.search('\d+\.\d+\.\d+\.\d+',str).group(0)
+  def getip(self):
+    try:
+      myip = self.visit("http://ip.chinaz.com/getip.aspx")
+    except:
+      try:
+        myip = self.visit("http://ipv4.icanhazip.com/")
+      except:
+        myip = "So sorry!!!"
+    return myip
+  def visit(self,url):
+    opener = urllib2.urlopen(url)
+    if url == opener.geturl():
+      str = opener.read()
+    return re.search('\d+\.\d+\.\d+\.\d+',str).group(0)
 
 
 if __name__ == "__main__":
 if __name__ == "__main__":
-    getmyip = Get_public_ip()
-    print getmyip.getip()
+  getmyip = Get_public_ip()
+  print getmyip.getip()

+ 32 - 34
include/hhvm_CentOS.sh

@@ -9,12 +9,10 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_hhvm_CentOS() {
 Install_hhvm_CentOS() {
-cd $oneinstack_dir/src
-
-id -u $run_user >/dev/null 2>&1
-[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
-
-if [ "$CentOS_RHEL_version" == '7' ];then
+  pushd ${oneinstack_dir}/src
+  id -u $run_user >/dev/null 2>&1
+  [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
+  if [ "$CentOS_RHEL_version" == '7' ]; then
     [ ! -e /etc/yum.repos.d/epel.repo ] && cat > /etc/yum.repos.d/epel.repo << EOF
     [ ! -e /etc/yum.repos.d/epel.repo ] && cat > /etc/yum.repos.d/epel.repo << EOF
 [epel]
 [epel]
 name=Extra Packages for Enterprise Linux 7 - \$basearch
 name=Extra Packages for Enterprise Linux 7 - \$basearch
@@ -33,9 +31,9 @@ gpgcheck=0
 EOF
 EOF
     yum -y install hhvm
     yum -y install hhvm
     [ ! -e "/usr/bin/hhvm" -a "/usr/local/bin/hhvm" ] && ln -s /usr/local/bin/hhvm /usr/bin/hhvm
     [ ! -e "/usr/bin/hhvm" -a "/usr/local/bin/hhvm" ] && ln -s /usr/local/bin/hhvm /usr/bin/hhvm
-fi
+  fi
 
 
-if [ "$CentOS_RHEL_version" == '6' ];then
+  if [ "$CentOS_RHEL_version" == '6' ]; then
     [ ! -e /etc/yum.repos.d/epel.repo ] && cat > /etc/yum.repos.d/epel.repo << EOF
     [ ! -e /etc/yum.repos.d/epel.repo ] && cat > /etc/yum.repos.d/epel.repo << EOF
 [epel]
 [epel]
 name=Extra Packages for Enterprise Linux 6 - \$basearch
 name=Extra Packages for Enterprise Linux 6 - \$basearch
@@ -62,13 +60,13 @@ gpgcheck=0
 EOF
 EOF
     yum --disablerepo=epel -y install mysql mysql-devel mysql-libs
     yum --disablerepo=epel -y install mysql mysql-devel mysql-libs
     yum --disablerepo=epel -y install hhvm
     yum --disablerepo=epel -y install hhvm
-fi
-
-userdel -r nginx;userdel -r saslauth
-rm -rf /var/log/hhvm
-mkdir /var/log/hhvm
-chown -R ${run_user}.${run_user} /var/log/hhvm
-cat > /etc/hhvm/config.hdf << EOF
+  fi
+  
+  userdel -r nginx;userdel -r saslauth
+  rm -rf /var/log/hhvm
+  mkdir /var/log/hhvm
+  chown -R ${run_user}.${run_user} /var/log/hhvm
+  cat > /etc/hhvm/config.hdf << EOF
 ResourceLimit {
 ResourceLimit {
   CoreFileSize = 0          # in bytes
   CoreFileSize = 0          # in bytes
   MaxSocket = 10000         # must be not 0, otherwise HHVM will not start
   MaxSocket = 10000         # must be not 0, otherwise HHVM will not start
@@ -107,7 +105,7 @@ Mail {
 }
 }
 EOF
 EOF
 
 
-cat > /etc/hhvm/server.ini << EOF
+  cat > /etc/hhvm/server.ini << EOF
 ; php options
 ; php options
 pid = /var/log/hhvm/pid
 pid = /var/log/hhvm/pid
 
 
@@ -121,29 +119,29 @@ hhvm.log.file = /var/log/hhvm/error.log
 hhvm.repo.central.path = /var/log/hhvm/hhvm.hhbc
 hhvm.repo.central.path = /var/log/hhvm/hhvm.hhbc
 EOF
 EOF
 
 
-cat > /etc/hhvm/php.ini << EOF
+  cat > /etc/hhvm/php.ini << EOF
 hhvm.mysql.socket = /tmp/mysql.sock
 hhvm.mysql.socket = /tmp/mysql.sock
 expose_php = 0
 expose_php = 0
 memory_limit = 400000000
 memory_limit = 400000000
 post_max_size = 50000000
 post_max_size = 50000000
 EOF
 EOF
 
 
-if [ -e "$web_install_dir/sbin/nginx" -a -e "/usr/bin/hhvm" -a ! -e "$php_install_dir" ];then
+  if [ -e "$web_install_dir/sbin/nginx" -a -e "/usr/bin/hhvm" -a ! -e "$php_install_dir" ]; then
     sed -i 's@/dev/shm/php-cgi.sock@/var/log/hhvm/sock@' $web_install_dir/conf/nginx.conf
     sed -i 's@/dev/shm/php-cgi.sock@/var/log/hhvm/sock@' $web_install_dir/conf/nginx.conf
     [ -z "`grep 'fastcgi_param SCRIPT_FILENAME' $web_install_dir/conf/nginx.conf`" ] && sed -i "s@fastcgi_index index.php;@&\n\t\tfastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;@" $web_install_dir/conf/nginx.conf
     [ -z "`grep 'fastcgi_param SCRIPT_FILENAME' $web_install_dir/conf/nginx.conf`" ] && sed -i "s@fastcgi_index index.php;@&\n\t\tfastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;@" $web_install_dir/conf/nginx.conf
     sed -i 's@include fastcgi.conf;@include fastcgi_params;@' $web_install_dir/conf/nginx.conf
     sed -i 's@include fastcgi.conf;@include fastcgi_params;@' $web_install_dir/conf/nginx.conf
     service nginx reload
     service nginx reload
-fi
-
-rm -rf /etc/ld.so.conf.d/*_64.conf
-ldconfig
-# Supervisor
-yum -y install python-setuptools
-ping pypi.python.org -c 4 >/dev/null 2>&1
-easy_install supervisor
-echo_supervisord_conf > /etc/supervisord.conf
-sed -i 's@pidfile=/tmp/supervisord.pid@pidfile=/var/run/supervisord.pid@' /etc/supervisord.conf
-[ -z "`grep 'program:hhvm' /etc/supervisord.conf`" ] && cat >> /etc/supervisord.conf << EOF
+  fi
+  
+  rm -rf /etc/ld.so.conf.d/*_64.conf
+  ldconfig
+  # Supervisor
+  yum -y install python-setuptools
+  ping pypi.python.org -c 4 >/dev/null 2>&1
+  easy_install supervisor
+  echo_supervisord_conf > /etc/supervisord.conf
+  sed -i 's@pidfile=/tmp/supervisord.pid@pidfile=/var/run/supervisord.pid@' /etc/supervisord.conf
+  [ -z "`grep 'program:hhvm' /etc/supervisord.conf`" ] && cat >> /etc/supervisord.conf << EOF
 [program:hhvm]
 [program:hhvm]
 command=/usr/bin/hhvm --mode server --user $run_user --config /etc/hhvm/server.ini --config /etc/hhvm/php.ini --config /etc/hhvm/config.hdf
 command=/usr/bin/hhvm --mode server --user $run_user --config /etc/hhvm/server.ini --config /etc/hhvm/php.ini --config /etc/hhvm/config.hdf
 numprocs=1 ; number of processes copies to start (def 1)
 numprocs=1 ; number of processes copies to start (def 1)
@@ -152,9 +150,9 @@ autostart=true ; start at supervisord start (default: true)
 autorestart=unexpected ; whether/when to restart (default: unexpected)
 autorestart=unexpected ; whether/when to restart (default: unexpected)
 stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
 stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
 EOF
 EOF
-/bin/cp ../init.d/Supervisor-init-CentOS /etc/init.d/supervisord
-chmod +x /etc/init.d/supervisord
-chkconfig supervisord on
-service supervisord start
-cd ..
+  /bin/cp ../init.d/Supervisor-init-CentOS /etc/init.d/supervisord
+  chmod +x /etc/init.d/supervisord
+  chkconfig supervisord on
+  service supervisord start
+  popd
 }
 }

+ 55 - 55
include/init_CentOS.sh

@@ -13,15 +13,15 @@ yum clean all
 
 
 yum makecache
 yum makecache
 
 
-if [ "$CentOS_RHEL_version" == '7' ];then
-    yum -y groupremove "Basic Web Server" "MySQL Database server" "MySQL Database client" "File and Print Server"
-    yum -y install iptables-services
-    systemctl mask firewalld.service
-    systemctl enable iptables.service
-elif [ "$CentOS_RHEL_version" == '6' ];then
-    yum -y groupremove "FTP Server" "PostgreSQL Database client" "PostgreSQL Database server" "MySQL Database server" "MySQL Database client" "Web Server" "Office Suite and Productivity" "E-mail server" "Ruby Support" "Printing client"
-elif [ "$CentOS_RHEL_version" == '5' ];then
-    yum -y groupremove "FTP Server" "Windows File Server" "PostgreSQL Database" "News Server" "MySQL Database" "DNS Name Server" "Web Server" "Dialup Networking Support" "Mail Server" "Ruby" "Office/Productivity" "Sound and Video" "Printing Support" "OpenFabrics Enterprise Distribution"
+if [ "$CentOS_RHEL_version" == '7' ]; then
+  yum -y groupremove "Basic Web Server" "MySQL Database server" "MySQL Database client" "File and Print Server"
+  yum -y install iptables-services
+  systemctl mask firewalld.service
+  systemctl enable iptables.service
+elif [ "$CentOS_RHEL_version" == '6' ]; then
+  yum -y groupremove "FTP Server" "PostgreSQL Database client" "PostgreSQL Database server" "MySQL Database server" "MySQL Database client" "Web Server" "Office Suite and Productivity" "E-mail server" "Ruby Support" "Printing client"
+elif [ "$CentOS_RHEL_version" == '5' ]; then
+  yum -y groupremove "FTP Server" "Windows File Server" "PostgreSQL Database" "News Server" "MySQL Database" "DNS Name Server" "Web Server" "Dialup Networking Support" "Mail Server" "Ruby" "Office/Productivity" "Sound and Video" "Printing Support" "OpenFabrics Enterprise Distribution"
 fi
 fi
 
 
 yum check-update
 yum check-update
@@ -29,15 +29,15 @@ yum check-update
 # Install needed packages
 # Install needed packages
 for Package in deltarpm gcc gcc-c++ make cmake autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel libaio readline-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel libxslt-devel libicu-devel libevent-devel libtool libtool-ltdl bison gd-devel vim-enhanced pcre-devel zip unzip ntpdate sysstat patch bc expect rsync git lsof lrzsz
 for Package in deltarpm gcc gcc-c++ make cmake autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel libaio readline-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel openssl openssl-devel libxslt-devel libicu-devel libevent-devel libtool libtool-ltdl bison gd-devel vim-enhanced pcre-devel zip unzip ntpdate sysstat patch bc expect rsync git lsof lrzsz
 do
 do
-    yum -y install $Package
+  yum -y install $Package
 done
 done
 
 
 yum -y update bash openssl glibc
 yum -y update bash openssl glibc
 
 
 # use gcc-4.4
 # use gcc-4.4
-if [ -n "`gcc --version | head -n1 | grep '4\.1\.'`" ];then
-    yum -y install gcc44 gcc44-c++ libstdc++44-devel
-    export CC="gcc44" CXX="g++44"
+if [ -n "`gcc --version | head -n1 | grep '4\.1\.'`" ]; then
+  yum -y install gcc44 gcc44-c++ libstdc++44-devel
+  export CC="gcc44" CXX="g++44"
 fi
 fi
 
 
 # closed Unnecessary services and remove obsolete rpm package
 # closed Unnecessary services and remove obsolete rpm package
@@ -134,16 +134,16 @@ net.netfilter.nf_conntrack_tcp_timeout_established = 3600
 EOF
 EOF
 sysctl -p
 sysctl -p
 
 
-if [ "$CentOS_RHEL_version" == '5' ];then
-    sed -i 's@^[3-6]:2345:respawn@#&@g' /etc/inittab
-    sed -i 's@^ca::ctrlaltdel@#&@' /etc/inittab
-    sed -i 's@LANG=.*$@LANG="en_US.UTF-8"@g' /etc/sysconfig/i18n
-elif [ "$CentOS_RHEL_version" == '6' ];then
-    sed -i 's@^ACTIVE_CONSOLES.*@ACTIVE_CONSOLES=/dev/tty[1-2]@' /etc/sysconfig/init
-    sed -i 's@^start@#start@' /etc/init/control-alt-delete.conf
-    sed -i 's@LANG=.*$@LANG="en_US.UTF-8"@g' /etc/sysconfig/i18n
-elif [ "$CentOS_RHEL_version" == '7' ];then
-    sed -i 's@LANG=.*$@LANG="en_US.UTF-8"@g' /etc/locale.conf
+if [ "$CentOS_RHEL_version" == '5' ]; then
+  sed -i 's@^[3-6]:2345:respawn@#&@g' /etc/inittab
+  sed -i 's@^ca::ctrlaltdel@#&@' /etc/inittab
+  sed -i 's@LANG=.*$@LANG="en_US.UTF-8"@g' /etc/sysconfig/i18n
+elif [ "$CentOS_RHEL_version" == '6' ]; then
+  sed -i 's@^ACTIVE_CONSOLES.*@ACTIVE_CONSOLES=/dev/tty[1-2]@' /etc/sysconfig/init
+  sed -i 's@^start@#start@' /etc/init/control-alt-delete.conf
+  sed -i 's@LANG=.*$@LANG="en_US.UTF-8"@g' /etc/sysconfig/i18n
+elif [ "$CentOS_RHEL_version" == '7' ]; then
+  sed -i 's@LANG=.*$@LANG="en_US.UTF-8"@g' /etc/locale.conf
 fi
 fi
 
 
 # Update time
 # Update time
@@ -151,15 +151,15 @@ ntpdate pool.ntp.org
 [ ! -e "/var/spool/cron/root" -o -z "`grep 'ntpdate' /var/spool/cron/root`" ] && { echo "*/20 * * * * `which ntpdate` pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/root;chmod 600 /var/spool/cron/root; }
 [ ! -e "/var/spool/cron/root" -o -z "`grep 'ntpdate' /var/spool/cron/root`" ] && { echo "*/20 * * * * `which ntpdate` pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/root;chmod 600 /var/spool/cron/root; }
 
 
 # iptables
 # iptables
-if [ -e '/etc/sysconfig/iptables' ] && [ -n "`grep '^:INPUT DROP' /etc/sysconfig/iptables`" -a -n "`grep 'NEW -m tcp --dport 22 -j ACCEPT' /etc/sysconfig/iptables`" -a -n "`grep 'NEW -m tcp --dport 80 -j ACCEPT' /etc/sysconfig/iptables`" ];then
-    IPTABLES_STATUS=yes
+if [ -e '/etc/sysconfig/iptables' ] && [ -n "`grep '^:INPUT DROP' /etc/sysconfig/iptables`" -a -n "`grep 'NEW -m tcp --dport 22 -j ACCEPT' /etc/sysconfig/iptables`" -a -n "`grep 'NEW -m tcp --dport 80 -j ACCEPT' /etc/sysconfig/iptables`" ]; then
+  IPTABLES_STATUS=yes
 else
 else
-    IPTABLES_STATUS=no
+  IPTABLES_STATUS=no
 fi
 fi
 
 
-if [ "$IPTABLES_STATUS" == 'no' ];then
-    [ -e '/etc/sysconfig/iptables' ] && /bin/mv /etc/sysconfig/iptables{,_bk}
-    cat > /etc/sysconfig/iptables << EOF
+if [ "$IPTABLES_STATUS" == 'no' ]; then
+  [ -e '/etc/sysconfig/iptables' ] && /bin/mv /etc/sysconfig/iptables{,_bk}
+  cat > /etc/sysconfig/iptables << EOF
 # Firewall configuration written by system-config-securitylevel
 # Firewall configuration written by system-config-securitylevel
 # Manual customization of this file is not recommended.
 # Manual customization of this file is not recommended.
 *filter
 *filter
@@ -188,35 +188,35 @@ service iptables restart
 service sshd restart
 service sshd restart
 
 
 # install tmux
 # install tmux
-if [ ! -e "`which tmux`" ];then
-    cd src
-    tar xzf libevent-${libevent_version}.tar.gz
-    cd libevent-${libevent_version}
-    ./configure
-    make -j ${THREAD} && make install
-    cd ..
-
-    tar xzf tmux-${tmux_version}.tar.gz
-    cd tmux-${tmux_version}
-    CFLAGS="-I/usr/local/include" LDFLAGS="-L//usr/local/lib" ./configure
-    make -j ${THREAD} && make install
-    cd ../../
-
-    if [ "$OS_BIT" == '64' ];then
-        ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
-    else
-        ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
-    fi
+if [ ! -e "`which tmux`" ]; then
+  pushd ${oneinstack_dir}/src
+  tar xzf libevent-${libevent_version}.tar.gz
+  pushd libevent-${libevent_version}
+  ./configure
+  make -j ${THREAD} && make install
+  popd
+
+  tar xzf tmux-${tmux_version}.tar.gz
+  pushd tmux-${tmux_version}
+  CFLAGS="-I/usr/local/include" LDFLAGS="-L//usr/local/lib" ./configure
+  make -j ${THREAD} && make install
+  popd
+
+  if [ "$OS_BIT" == '64' ]; then
+    ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib64/libevent-2.0.so.5
+  else
+    ln -s /usr/local/lib/libevent-2.0.so.5 /usr/lib/libevent-2.0.so.5
+  fi
 fi
 fi
 
 
 # install htop
 # install htop
-if [ ! -e "`which htop`" ];then
-    cd src
-    tar xzf htop-${htop_version}.tar.gz
-    cd htop-${htop_version}
-    ./configure
-    make -j ${THREAD} && make install
-    cd ../../
+if [ ! -e "`which htop`" ]; then
+  tar xzf htop-${htop_version}.tar.gz
+  pushd htop-${htop_version}
+  ./configure
+  make -j ${THREAD} && make install
+  popd
 fi
 fi
 
 
 . /etc/profile
 . /etc/profile
+popd

+ 8 - 8
include/init_Debian.sh

@@ -10,7 +10,7 @@
 
 
 for Package in apache2 apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker mysql-client mysql-server mysql-common libmysqlclient18 php5 php5-common php5-cgi php5-mysql php5-curl php5-gd libmysql* mysql-*
 for Package in apache2 apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker mysql-client mysql-server mysql-common libmysqlclient18 php5 php5-common php5-cgi php5-mysql php5-curl php5-gd libmysql* mysql-*
 do
 do
-    apt-get -y remove --purge $Package
+  apt-get -y remove --purge $Package
 done
 done
 dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
 dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
 
 
@@ -23,7 +23,7 @@ apt-get -y upgrade -o Dir::Etc::SourceList=/tmp/security.sources.list
 # Install needed packages
 # Install needed packages
 for Package in gcc g++ make cmake autoconf libjpeg8 libjpeg8-dev libjpeg-dev libpng12-0 libpng12-dev libpng3 libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev libreadline-dev curl libcurl3 libcurl4-openssl-dev libcurl4-gnutls-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl libssl-dev libtool libevent-dev bison re2c libsasl2-dev libxslt1-dev libicu-dev locales libcloog-ppl0 patch vim zip unzip tmux htop bc expect rsync git lsof lrzsz cron logrotate ntpdate psmisc
 for Package in gcc g++ make cmake autoconf libjpeg8 libjpeg8-dev libjpeg-dev libpng12-0 libpng12-dev libpng3 libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev libreadline-dev curl libcurl3 libcurl4-openssl-dev libcurl4-gnutls-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl libssl-dev libtool libevent-dev bison re2c libsasl2-dev libxslt1-dev libicu-dev locales libcloog-ppl0 patch vim zip unzip tmux htop bc expect rsync git lsof lrzsz cron logrotate ntpdate psmisc
 do
 do
-    apt-get -y install $Package
+  apt-get -y install $Package
 done
 done
 
 
 # Custom profile
 # Custom profile
@@ -108,15 +108,15 @@ ntpdate pool.ntp.org
 [ ! -e "/var/spool/cron/crontabs/root" -o -z "`grep ntpdate /var/spool/cron/crontabs/root 2>/dev/null`" ] && { echo "*/20 * * * * `which ntpdate` pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/crontabs/root;chmod 600 /var/spool/cron/crontabs/root; }
 [ ! -e "/var/spool/cron/crontabs/root" -o -z "`grep ntpdate /var/spool/cron/crontabs/root 2>/dev/null`" ] && { echo "*/20 * * * * `which ntpdate` pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/crontabs/root;chmod 600 /var/spool/cron/crontabs/root; }
 
 
 # iptables
 # iptables
-if [ -e '/etc/iptables.up.rules' ] && [ -n "`grep '^:INPUT DROP' /etc/iptables.up.rules`" -a -n "`grep 'NEW -m tcp --dport 22 -j ACCEPT' /etc/iptables.up.rules`" -a -n "`grep 'NEW -m tcp --dport 80 -j ACCEPT' /etc/iptables.up.rules`" ];then
-    IPTABLES_STATUS=yes
+if [ -e '/etc/iptables.up.rules' ] && [ -n "`grep '^:INPUT DROP' /etc/iptables.up.rules`" -a -n "`grep 'NEW -m tcp --dport 22 -j ACCEPT' /etc/iptables.up.rules`" -a -n "`grep 'NEW -m tcp --dport 80 -j ACCEPT' /etc/iptables.up.rules`" ]; then
+  IPTABLES_STATUS=yes
 else
 else
-    IPTABLES_STATUS=no
+  IPTABLES_STATUS=no
 fi
 fi
 
 
-if [ "$IPTABLES_STATUS" == 'no' ];then
-    [ -e '/etc/iptables.up.rules' ] && /bin/mv /etc/iptables.up.rules{,_bk}
-    cat > /etc/iptables.up.rules << EOF
+if [ "$IPTABLES_STATUS" == 'no' ]; then
+  [ -e '/etc/iptables.up.rules' ] && /bin/mv /etc/iptables.up.rules{,_bk}
+  cat > /etc/iptables.up.rules << EOF
 # Firewall configuration written by system-config-securitylevel
 # Firewall configuration written by system-config-securitylevel
 # Manual customization of this file is not recommended.
 # Manual customization of this file is not recommended.
 *filter
 *filter

+ 24 - 24
include/init_Ubuntu.sh

@@ -10,7 +10,7 @@
 
 
 for Package in apache2 apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker mysql-client mysql-server mysql-common libmysqlclient18 php5 php5-common php5-cgi php5-mysql php5-curl php5-gd libmysql* mysql-*
 for Package in apache2 apache2-doc apache2-utils apache2.2-common apache2.2-bin apache2-mpm-prefork apache2-doc apache2-mpm-worker mysql-client mysql-server mysql-common libmysqlclient18 php5 php5-common php5-cgi php5-mysql php5-curl php5-gd libmysql* mysql-*
 do
 do
-    apt-get -y remove --purge $Package
+  apt-get -y remove --purge $Package
 done
 done
 dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
 dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
 
 
@@ -23,25 +23,24 @@ apt-get -y upgrade -o Dir::Etc::SourceList=/tmp/security.sources.list
 # Install needed packages
 # Install needed packages
 for Package in gcc g++ make cmake autoconf libjpeg8 libjpeg8-dev libpng12-0 libpng12-dev libpng3 libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev libreadline-dev curl libcurl3 libcurl4-openssl-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl libssl-dev libtool libevent-dev re2c libsasl2-dev libxslt1-dev libicu-dev patch vim zip unzip tmux htop bc expect rsync git lsof lrzsz ntpdate
 for Package in gcc g++ make cmake autoconf libjpeg8 libjpeg8-dev libpng12-0 libpng12-dev libpng3 libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev libreadline-dev curl libcurl3 libcurl4-openssl-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl libssl-dev libtool libevent-dev re2c libsasl2-dev libxslt1-dev libicu-dev patch vim zip unzip tmux htop bc expect rsync git lsof lrzsz ntpdate
 do
 do
-    apt-get -y install $Package
+  apt-get -y install $Package
 done
 done
 
 
-if [[ "$Ubuntu_version" =~ ^14$|^15$ ]];then
-    apt-get -y install libcloog-ppl1
-    apt-get -y remove bison
-    cd src
-    tar xzf bison-${bison_version}.tar.gz
-    cd bison-${bison_version}
-    ./configure
-    make -j ${THREAD} && make install
-    cd ..
-    rm -rf bison-${bison_version}
-    cd ..
-    ln -sf /usr/include/freetype2 /usr/include/freetype2/freetype
-elif [ "$Ubuntu_version" == '13' ];then
-    apt-get -y install bison libcloog-ppl1
-elif [ "$Ubuntu_version" == '12' ];then
-    apt-get -y install bison libcloog-ppl0
+if [[ "$Ubuntu_version" =~ ^14$|^15$ ]]; then
+  apt-get -y install libcloog-ppl1
+  apt-get -y remove bison
+  pushd ${oneinstack_dir}/src 
+  tar xzf bison-${bison_version}.tar.gz
+  pushd bison-${bison_version}
+  ./configure
+  make -j ${THREAD} && make install
+  popd
+  rm -rf bison-${bison_version}
+  ln -sf /usr/include/freetype2 /usr/include/freetype2/freetype
+elif [ "$Ubuntu_version" == '13' ]; then
+  apt-get -y install bison libcloog-ppl1
+elif [ "$Ubuntu_version" == '12' ]; then
+  apt-get -y install bison libcloog-ppl0
 fi
 fi
 
 
 # Custom profile
 # Custom profile
@@ -129,15 +128,15 @@ ntpdate pool.ntp.org
 [ ! -e "/var/spool/cron/crontabs/root" -o -z "`grep ntpdate /var/spool/cron/crontabs/root 2>/dev/null`" ] && { echo "*/20 * * * * `which ntpdate` pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/crontabs/root;chmod 600 /var/spool/cron/crontabs/root; }
 [ ! -e "/var/spool/cron/crontabs/root" -o -z "`grep ntpdate /var/spool/cron/crontabs/root 2>/dev/null`" ] && { echo "*/20 * * * * `which ntpdate` pool.ntp.org > /dev/null 2>&1" >> /var/spool/cron/crontabs/root;chmod 600 /var/spool/cron/crontabs/root; }
 
 
 # iptables
 # iptables
-if [ -e '/etc/iptables.up.rules' ] && [ -n "`grep '^:INPUT DROP' /etc/iptables.up.rules`" -a -n "`grep 'NEW -m tcp --dport 22 -j ACCEPT' /etc/iptables.up.rules`" -a -n "`grep 'NEW -m tcp --dport 80 -j ACCEPT' /etc/iptables.up.rules`" ];then
-    IPTABLES_STATUS=yes
+if [ -e '/etc/iptables.up.rules' ] && [ -n "`grep '^:INPUT DROP' /etc/iptables.up.rules`" -a -n "`grep 'NEW -m tcp --dport 22 -j ACCEPT' /etc/iptables.up.rules`" -a -n "`grep 'NEW -m tcp --dport 80 -j ACCEPT' /etc/iptables.up.rules`" ]; then
+  IPTABLES_STATUS=yes
 else
 else
-    IPTABLES_STATUS=no
+  IPTABLES_STATUS=no
 fi
 fi
 
 
-if [ "$IPTABLES_STATUS" == 'no' ];then
-    [ -e '/etc/iptables.up.rules' ] && /bin/mv /etc/iptables.up.rules{,_bk}
-    cat > /etc/iptables.up.rules << EOF
+if [ "$IPTABLES_STATUS" == 'no' ]; then
+  [ -e '/etc/iptables.up.rules' ] && /bin/mv /etc/iptables.up.rules{,_bk}
+  cat > /etc/iptables.up.rules << EOF
 # Firewall configuration written by system-config-securitylevel
 # Firewall configuration written by system-config-securitylevel
 # Manual customization of this file is not recommended.
 # Manual customization of this file is not recommended.
 *filter
 *filter
@@ -172,3 +171,4 @@ service ssh restart
 
 
 . /etc/profile
 . /etc/profile
 . ~/.bashrc
 . ~/.bashrc
+popd

+ 43 - 43
include/ioncube.sh

@@ -9,49 +9,49 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_ionCube() {
 Install_ionCube() {
-    pushd ${oneinstack_dir}/src
-  
-    PHP_detail_version=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
-    PHP_main_version=${PHP_detail_version%.*}
-    phpExtensionDir=`$php_install_dir/bin/php-config --extension-dir`
-  
-    if [ "${OS_BIT}" == '64' ];then
-        tar xzf ioncube_loaders_lin_x86-64.tar.gz
+  pushd ${oneinstack_dir}/src
+  PHP_detail_version=`${php_install_dir}/bin/php -r 'echo PHP_VERSION;'`
+  PHP_main_version=${PHP_detail_version%.*}
+  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
+  if [ "${OS_BIT}" == '64' ]; then
+      tar xzf ioncube_loaders_lin_x86-64.tar.gz
+  else
+    if  [ "${TARGET_ARCH}" == "armv7" ]; then
+      tar xzf ioncube_loaders_lin_armv7l.tar.gz
     else
     else
-        if [ "${TARGET_ARCH}" == "armv7" ];then
-            tar xzf ioncube_loaders_lin_armv7l.tar.gz
-        else
-            tar xzf ioncube_loaders_lin_x86.tar.gz
-        fi
+      tar xzf ioncube_loaders_lin_x86.tar.gz
     fi
     fi
-  
-    [ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir}
-    if [ "$PHP_main_version" == '7.0' ]; then
-        /bin/cp ioncube/ioncube_loader_lin_7.0.so ${phpExtensionDir}
-        zend_extension="${phpExtensionDir}/ioncube_loader_lin_7.0.so"
-    elif [ "$PHP_main_version" == '5.6' ]; then
-        /bin/cp ioncube/ioncube_loader_lin_5.6.so ${phpExtensionDir}
-        zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.6.so"
-    elif [ "$PHP_main_version" == '5.5' ]; then
-        /bin/cp ioncube/ioncube_loader_lin_5.5.so ${phpExtensionDir}
-        zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.5.so"
-    elif [ "$PHP_main_version" == '5.4' ]; then
-        /bin/cp ioncube/ioncube_loader_lin_5.4.so ${phpExtensionDir}
-        zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.4.so"
-    elif [ "$PHP_main_version" == '5.3' ]; then
-        /bin/cp ioncube/ioncube_loader_lin_5.3.so ${phpExtensionDir}
-        zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.3.so"
-    else
-        echo "Error! Your PHP ${PHP_detail_version} does not support ionCube!"
-        rm -rf ioncube
-        exit 1
-    fi
-  
-    rm -rf ioncube
-    cat > ${php_install_dir}/etc/php.d/ext-0ioncube.ini << EOF
-[ionCube Loader]
-zend_extension=${zend_extension}
-EOF
-    [ "${Apache_version}" != '1' -a "${Apache_version}" != '2' ] && service php-fpm restart || service httpd restart
-    popd
+  fi
+
+  [ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir}
+  case "${PHP_main_version}" in
+    7.0)
+      /bin/cp ioncube/ioncube_loader_lin_7.0.so ${phpExtensionDir}
+      zend_extension="${phpExtensionDir}/ioncube_loader_lin_7.0.so"
+      ;;
+    5.6)
+      /bin/cp ioncube/ioncube_loader_lin_5.6.so ${phpExtensionDir}
+      zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.6.so"
+      ;;
+    5.5)
+     /bin/cp ioncube/ioncube_loader_lin_5.5.so ${phpExtensionDir}
+     zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.5.so"
+     ;;
+    5.4)
+      /bin/cp ioncube/ioncube_loader_lin_5.4.so ${phpExtensionDir}
+      zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.4.so"
+      ;;
+    5.3)
+      /bin/cp ioncube/ioncube_loader_lin_5.3.so ${phpExtensionDir}
+      zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.3.so"
+      ;;
+    *)
+      echo "Error! Your PHP ${PHP_detail_version} does not support ionCube!"
+      exit 1
+      ;;
+  esac
+
+  echo "zend_extension=${zend_extension}" > ${php_install_dir}/etc/php.d/ext-0ioncube.ini
+  rm -rf ioncube
+  popd
 }
 }

+ 16 - 11
include/jdk-1.6.sh

@@ -9,14 +9,19 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install-JDK-1-6() {
 Install-JDK-1-6() {
-cd $oneinstack_dir/src
-
-[ "$OS" == 'CentOS' ] && [ -n "`rpm -qa | grep jdk`" ] && rpm -e `rpm -qa | grep jdk`
-
-chmod +x $JDK_FILE
-./$JDK_FILE
-
-if [ -d "$JDK_NAME" ];then
+  pushd ${oneinstack_dir}/src
+  
+  JDK_FILE="jdk-`echo $jdk_6_version | awk -F. '{print $2}'`u`echo $jdk_6_version | awk -F_ '{print $NF}'`-linux-$SYS_BIG_FLAG.bin"
+  JAVA_dir=/usr/java
+  JDK_NAME="jdk$jdk_6_version"
+  JDK_PATH=$JAVA_dir/$JDK_NAME
+  
+  [ "$OS" == 'CentOS' ] && [ -n "`rpm -qa | grep jdk`" ] && rpm -e `rpm -qa | grep jdk`
+  
+  chmod +x $JDK_FILE
+  ./$JDK_FILE
+  
+  if [ -d "$JDK_NAME" ]; then
     rm -rf $JAVA_dir; mkdir -p $JAVA_dir
     rm -rf $JAVA_dir; mkdir -p $JAVA_dir
     mv $JDK_NAME $JAVA_dir
     mv $JDK_NAME $JAVA_dir
     [ -z "`grep ^'export JAVA_HOME=' /etc/profile`" ] && { [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo  "export JAVA_HOME=$JDK_PATH" >> /etc/profile || sed -i "s@^export PATH=@export JAVA_HOME=$JDK_PATH\nexport PATH=@" /etc/profile; } || sed -i "s@^export JAVA_HOME=.*@export JAVA_HOME=$JDK_PATH@" /etc/profile
     [ -z "`grep ^'export JAVA_HOME=' /etc/profile`" ] && { [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo  "export JAVA_HOME=$JDK_PATH" >> /etc/profile || sed -i "s@^export PATH=@export JAVA_HOME=$JDK_PATH\nexport PATH=@" /etc/profile; } || sed -i "s@^export JAVA_HOME=.*@export JAVA_HOME=$JDK_PATH@" /etc/profile
@@ -25,10 +30,10 @@ if [ -d "$JDK_NAME" ];then
     [ -z "`grep ^'export PATH=' /etc/profile | grep '$JAVA_HOME/bin'`" ] && echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile
     [ -z "`grep ^'export PATH=' /etc/profile | grep '$JAVA_HOME/bin'`" ] && echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile
     . /etc/profile
     . /etc/profile
     echo "${CSUCCESS}$JDK_NAME installed successfully! ${CEND}"
     echo "${CSUCCESS}$JDK_NAME installed successfully! ${CEND}"
-else
+  else
     rm -rf $JAVA_dir
     rm -rf $JAVA_dir
     echo "${CFAILURE}JDK install failed, Please contact the author! ${CEND}"
     echo "${CFAILURE}JDK install failed, Please contact the author! ${CEND}"
     kill -9 $$
     kill -9 $$
-fi
-cd ..
+  fi
+popd
 }
 }

+ 14 - 14
include/jdk-1.7.sh

@@ -9,18 +9,18 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install-JDK-1-7() {
 Install-JDK-1-7() {
-cd $oneinstack_dir/src
+  pushd ${oneinstack_dir}/src
 
 
-JDK_FILE="jdk-`echo $jdk_7_version | awk -F. '{print $2}'`u`echo $jdk_7_version | awk -F_ '{print $NF}'`-linux-$SYS_BIG_FLAG.tar.gz"
-JAVA_dir=/usr/java
-JDK_NAME="jdk$jdk_7_version"
-JDK_PATH=$JAVA_dir/$JDK_NAME
-
-[ "$OS" == 'CentOS' ] && [ -n "`rpm -qa | grep jdk`" ] && rpm -e `rpm -qa | grep jdk`
-
-tar xzf $JDK_FILE
-
-if [ -d "$JDK_NAME" ];then
+  JDK_FILE="jdk-`echo $jdk_7_version | awk -F. '{print $2}'`u`echo $jdk_7_version | awk -F_ '{print $NF}'`-linux-$SYS_BIG_FLAG.tar.gz"
+  JAVA_dir=/usr/java
+  JDK_NAME="jdk$jdk_7_version"
+  JDK_PATH=$JAVA_dir/$JDK_NAME
+  
+  [ "$OS" == 'CentOS' ] && [ -n "`rpm -qa | grep jdk`" ] && rpm -e `rpm -qa | grep jdk`
+  
+  tar xzf $JDK_FILE
+  
+  if [ -d "$JDK_NAME" ]; then
     rm -rf $JAVA_dir; mkdir -p $JAVA_dir
     rm -rf $JAVA_dir; mkdir -p $JAVA_dir
     mv $JDK_NAME $JAVA_dir
     mv $JDK_NAME $JAVA_dir
     [ -z "`grep ^'export JAVA_HOME=' /etc/profile`" ] && { [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo  "export JAVA_HOME=$JDK_PATH" >> /etc/profile || sed -i "s@^export PATH=@export JAVA_HOME=$JDK_PATH\nexport PATH=@" /etc/profile; } || sed -i "s@^export JAVA_HOME=.*@export JAVA_HOME=$JDK_PATH@" /etc/profile
     [ -z "`grep ^'export JAVA_HOME=' /etc/profile`" ] && { [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo  "export JAVA_HOME=$JDK_PATH" >> /etc/profile || sed -i "s@^export PATH=@export JAVA_HOME=$JDK_PATH\nexport PATH=@" /etc/profile; } || sed -i "s@^export JAVA_HOME=.*@export JAVA_HOME=$JDK_PATH@" /etc/profile
@@ -29,10 +29,10 @@ if [ -d "$JDK_NAME" ];then
     [ -z "`grep ^'export PATH=' /etc/profile | grep '$JAVA_HOME/bin'`" ] && echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile
     [ -z "`grep ^'export PATH=' /etc/profile | grep '$JAVA_HOME/bin'`" ] && echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile
     . /etc/profile
     . /etc/profile
     echo "${CSUCCESS}$JDK_NAME installed successfully! ${CEND}"
     echo "${CSUCCESS}$JDK_NAME installed successfully! ${CEND}"
-else
+  else
     rm -rf $JAVA_dir
     rm -rf $JAVA_dir
     echo "${CFAILURE}JDK install failed, Please contact the author! ${CEND}"
     echo "${CFAILURE}JDK install failed, Please contact the author! ${CEND}"
     kill -9 $$
     kill -9 $$
-fi
-cd ..
+  fi
+  popd
 }
 }

+ 15 - 15
include/jdk-1.8.sh

@@ -9,18 +9,18 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install-JDK-1-8() {
 Install-JDK-1-8() {
-cd $oneinstack_dir/src
-
-JDK_FILE="jdk-`echo $jdk_8_version | awk -F. '{print $2}'`u`echo $jdk_8_version | awk -F_ '{print $NF}'`-linux-$SYS_BIG_FLAG.tar.gz"
-JAVA_dir=/usr/java
-JDK_NAME="jdk$jdk_8_version"
-JDK_PATH=$JAVA_dir/$JDK_NAME
-
-[ "$OS" == 'CentOS' ] && [ -n "`rpm -qa | grep jdk`" ] && rpm -e `rpm -qa | grep jdk`
-
-tar xzf $JDK_FILE
-
-if [ -d "$JDK_NAME" ];then
+  pushd ${oneinstack_dir}/src
+  
+  JDK_FILE="jdk-`echo $jdk_8_version | awk -F. '{print $2}'`u`echo $jdk_8_version | awk -F_ '{print $NF}'`-linux-$SYS_BIG_FLAG.tar.gz"
+  JAVA_dir=/usr/java
+  JDK_NAME="jdk$jdk_8_version"
+  JDK_PATH=$JAVA_dir/$JDK_NAME
+  
+  [ "$OS" == 'CentOS' ] && [ -n "`rpm -qa | grep jdk`" ] && rpm -e `rpm -qa | grep jdk`
+  
+  tar xzf $JDK_FILE
+  
+  if [ -d "$JDK_NAME" ]; then
     rm -rf $JAVA_dir; mkdir -p $JAVA_dir
     rm -rf $JAVA_dir; mkdir -p $JAVA_dir
     mv $JDK_NAME $JAVA_dir
     mv $JDK_NAME $JAVA_dir
     [ -z "`grep ^'export JAVA_HOME=' /etc/profile`" ] && { [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo  "export JAVA_HOME=$JDK_PATH" >> /etc/profile || sed -i "s@^export PATH=@export JAVA_HOME=$JDK_PATH\nexport PATH=@" /etc/profile; } || sed -i "s@^export JAVA_HOME=.*@export JAVA_HOME=$JDK_PATH@" /etc/profile
     [ -z "`grep ^'export JAVA_HOME=' /etc/profile`" ] && { [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo  "export JAVA_HOME=$JDK_PATH" >> /etc/profile || sed -i "s@^export PATH=@export JAVA_HOME=$JDK_PATH\nexport PATH=@" /etc/profile; } || sed -i "s@^export JAVA_HOME=.*@export JAVA_HOME=$JDK_PATH@" /etc/profile
@@ -29,10 +29,10 @@ if [ -d "$JDK_NAME" ];then
     [ -z "`grep ^'export PATH=' /etc/profile | grep '$JAVA_HOME/bin'`" ] && echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile
     [ -z "`grep ^'export PATH=' /etc/profile | grep '$JAVA_HOME/bin'`" ] && echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile
     . /etc/profile
     . /etc/profile
     echo "${CSUCCESS}$JDK_NAME installed successfully! ${CEND}"
     echo "${CSUCCESS}$JDK_NAME installed successfully! ${CEND}"
-else
+  else
     rm -rf $JAVA_dir
     rm -rf $JAVA_dir
     echo "${CFAILURE}JDK install failed, Please contact the author! ${CEND}"
     echo "${CFAILURE}JDK install failed, Please contact the author! ${CEND}"
     kill -9 $$
     kill -9 $$
-fi
-cd ..
+  fi
+  popd
 }
 }

+ 12 - 12
include/jemalloc.sh

@@ -9,13 +9,14 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_jemalloc() {
 Install_jemalloc() {
-cd $oneinstack_dir/src
-tar xjf jemalloc-$jemalloc_version.tar.bz2
-cd jemalloc-$jemalloc_version
-LDFLAGS="${LDFLAGS} -lrt" ./configure
-make -j ${THREAD} && make install
-if [ -f "/usr/local/lib/libjemalloc.so" ];then
-    if [ "$OS_BIT" == '64' -a "$OS" == 'CentOS' ];then
+  pushd ${oneinstack_dir}/src
+  tar xjf jemalloc-$jemalloc_version.tar.bz2
+  pushd jemalloc-$jemalloc_version
+  LDFLAGS="${LDFLAGS} -lrt" ./configure
+  make -j ${THREAD} && make install
+  popd
+  if [ -f "/usr/local/lib/libjemalloc.so" ]; then
+    if [ "$OS_BIT" == '64' -a "$OS" == 'CentOS' ]; then
         ln -s /usr/local/lib/libjemalloc.so.2 /usr/lib64/libjemalloc.so.1
         ln -s /usr/local/lib/libjemalloc.so.2 /usr/lib64/libjemalloc.so.1
     else
     else
         ln -s /usr/local/lib/libjemalloc.so.2 /usr/lib/libjemalloc.so.1
         ln -s /usr/local/lib/libjemalloc.so.2 /usr/lib/libjemalloc.so.1
@@ -23,11 +24,10 @@ if [ -f "/usr/local/lib/libjemalloc.so" ];then
     echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
     echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
     ldconfig
     ldconfig
     echo "${CSUCCESS}jemalloc module installed successfully! ${CEND}"
     echo "${CSUCCESS}jemalloc module installed successfully! ${CEND}"
-    cd ..
-    rm -rf jemalloc-$jemalloc_version
-else
+    rm -rf jemalloc-${jemalloc_version}
+  else
     echo "${CFAILURE}jemalloc install failed, Please contact the author! ${CEND}"
     echo "${CFAILURE}jemalloc install failed, Please contact the author! ${CEND}"
     kill -9 $$
     kill -9 $$
-fi
-cd ..
+  fi
+  popd
 }
 }

+ 12 - 12
include/mariadb-10.0.sh

@@ -17,22 +17,22 @@ Install_MariaDB-10-0() {
   [ ! -d "${mariadb_install_dir}" ] && mkdir -p ${mariadb_install_dir}
   [ ! -d "${mariadb_install_dir}" ] && mkdir -p ${mariadb_install_dir}
   mkdir -p ${mariadb_data_dir};chown mysql.mysql -R ${mariadb_data_dir}
   mkdir -p ${mariadb_data_dir};chown mysql.mysql -R ${mariadb_data_dir}
 
 
-  if [ "${dbInstallMethods}" == "1" ];then
+  if [ "${dbInstallMethods}" == "1" ]; then
     tar zxf mariadb-${mariadb_10_0_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz
     tar zxf mariadb-${mariadb_10_0_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz
     mv mariadb-${mariadb_10_0_version}-*-${SYS_BIT_b}/* ${mariadb_install_dir}
     mv mariadb-${mariadb_10_0_version}-*-${SYS_BIT_b}/* ${mariadb_install_dir}
 
 
-    if [ "${je_tc_malloc}" == "1" ];then
+    if [ "${je_tc_malloc}" == "1" ]; then
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe
-    elif [ "${je_tc_malloc}" == "2" ];then
+    elif [ "${je_tc_malloc}" == "2" ]; then
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe
     fi
     fi
-  elif [ "${dbInstallMethods}" == "2" ];then
+  elif [ "${dbInstallMethods}" == "2" ]; then
     tar xvf mariadb-${mariadb_10_0_version}.tar.gz
     tar xvf mariadb-${mariadb_10_0_version}.tar.gz
     pushd mariadb-${mariadb_10_0_version}
     pushd mariadb-${mariadb_10_0_version}
 
 
-    if [ "${je_tc_malloc}" == "1" ];then
+    if [ "${je_tc_malloc}" == "1" ]; then
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
-    elif [ "${je_tc_malloc}" == "2" ];then
+    elif [ "${je_tc_malloc}" == "2" ]; then
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
     fi
     fi
 
 
@@ -56,11 +56,11 @@ Install_MariaDB-10-0() {
     popd
     popd
   fi
   fi
 
 
-  if [ -d "${mariadb_install_dir}/support-files" ];then
+  if [ -d "${mariadb_install_dir}/support-files" ]; then
     echo "${CSUCCESS}MariaDB installed successfully! ${CEND}"
     echo "${CSUCCESS}MariaDB installed successfully! ${CEND}"
-    if [ "${dbInstallMethods}" == "1" ];then
+    if [ "${dbInstallMethods}" == "1" ]; then
       rm -rf mariadb-${mariadb_10_0_version}-*-${SYS_BIT_b}
       rm -rf mariadb-${mariadb_10_0_version}-*-${SYS_BIT_b}
-    elif [ "${dbInstallMethods}" == "2" ];then
+    elif [ "${dbInstallMethods}" == "2" ]; then
       rm -rf mariadb-${mariadb_10_0_version}
       rm -rf mariadb-${mariadb_10_0_version}
     fi
     fi
   else
   else
@@ -177,7 +177,7 @@ write_buffer = 4M
 EOF
 EOF
 
 
   sed -i "s@max_connections.*@max_connections = $((${Mem}/2))@" /etc/my.cnf
   sed -i "s@max_connections.*@max_connections = $((${Mem}/2))@" /etc/my.cnf
-  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ];then
+  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
@@ -185,7 +185,7 @@ EOF
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
-  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ];then
+  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
@@ -193,7 +193,7 @@ EOF
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
-  elif [ ${Mem} -gt 3500 ];then
+  elif [ ${Mem} -gt 3500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf

+ 12 - 12
include/mariadb-10.1.sh

@@ -17,22 +17,22 @@ Install_MariaDB-10-1() {
   [ ! -d "${mariadb_install_dir}" ] && mkdir -p ${mariadb_install_dir}
   [ ! -d "${mariadb_install_dir}" ] && mkdir -p ${mariadb_install_dir}
   mkdir -p ${mariadb_data_dir};chown mysql.mysql -R ${mariadb_data_dir}
   mkdir -p ${mariadb_data_dir};chown mysql.mysql -R ${mariadb_data_dir}
 
 
-  if [ "${dbInstallMethods}" == "1" ];then
+  if [ "${dbInstallMethods}" == "1" ]; then
     tar zxf mariadb-${mariadb_10_1_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz
     tar zxf mariadb-${mariadb_10_1_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz
     mv mariadb-${mariadb_10_1_version}-*-${SYS_BIT_b}/* ${mariadb_install_dir}
     mv mariadb-${mariadb_10_1_version}-*-${SYS_BIT_b}/* ${mariadb_install_dir}
 
 
-    if [ "${je_tc_malloc}" == "1" ];then
+    if [ "${je_tc_malloc}" == "1" ]; then
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe
-    elif [ "${je_tc_malloc}" == "2" ];then
+    elif [ "${je_tc_malloc}" == "2" ]; then
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe
     fi
     fi
-  elif [ "${dbInstallMethods}" == "2" ];then
+  elif [ "${dbInstallMethods}" == "2" ]; then
     tar xvf mariadb-${mariadb_10_1_version}.tar.gz
     tar xvf mariadb-${mariadb_10_1_version}.tar.gz
     pushd mariadb-${mariadb_10_1_version}
     pushd mariadb-${mariadb_10_1_version}
 
 
-    if [ "${je_tc_malloc}" == "1" ];then
+    if [ "${je_tc_malloc}" == "1" ]; then
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
-    elif [ "${je_tc_malloc}" == "2" ];then
+    elif [ "${je_tc_malloc}" == "2" ]; then
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
     fi
     fi
 
 
@@ -56,11 +56,11 @@ Install_MariaDB-10-1() {
     popd
     popd
   fi
   fi
 
 
-  if [ -d "${mariadb_install_dir}/support-files" ];then
+  if [ -d "${mariadb_install_dir}/support-files" ]; then
     echo "${CSUCCESS}MariaDB installed successfully! ${CEND}"
     echo "${CSUCCESS}MariaDB installed successfully! ${CEND}"
-    if [ "${dbInstallMethods}" == "1" ];then
+    if [ "${dbInstallMethods}" == "1" ]; then
       rm -rf mariadb-${mariadb_10_1_version}-*-${SYS_BIT_b}
       rm -rf mariadb-${mariadb_10_1_version}-*-${SYS_BIT_b}
-    elif [ "${dbInstallMethods}" == "2" ];then
+    elif [ "${dbInstallMethods}" == "2" ]; then
       rm -rf mariadb-${mariadb_10_1_version}
       rm -rf mariadb-${mariadb_10_1_version}
     fi
     fi
   else
   else
@@ -177,7 +177,7 @@ write_buffer = 4M
 EOF
 EOF
 
 
   sed -i "s@max_connections.*@max_connections = $((${Mem}/2))@" /etc/my.cnf
   sed -i "s@max_connections.*@max_connections = $((${Mem}/2))@" /etc/my.cnf
-  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ];then
+  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
@@ -185,7 +185,7 @@ EOF
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
-  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ];then
+  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
@@ -193,7 +193,7 @@ EOF
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
-  elif [ ${Mem} -gt 3500 ];then
+  elif [ ${Mem} -gt 3500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf

+ 13 - 13
include/mariadb-5.5.sh

@@ -17,26 +17,26 @@ Install_MariaDB-5-5() {
   [ ! -d "${mariadb_install_dir}" ] && mkdir -p ${mariadb_install_dir}
   [ ! -d "${mariadb_install_dir}" ] && mkdir -p ${mariadb_install_dir}
   mkdir -p ${mariadb_data_dir};chown mysql.mysql -R ${mariadb_data_dir}
   mkdir -p ${mariadb_data_dir};chown mysql.mysql -R ${mariadb_data_dir}
 
 
-  if [ "${dbInstallMethods}" == "1" ];then
+  if [ "${dbInstallMethods}" == "1" ]; then
     tar zxf mariadb-${mariadb_5_5_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz
     tar zxf mariadb-${mariadb_5_5_version}-${GLIBC_FLAG}-${SYS_BIT_b}.tar.gz
     mv mariadb-${mariadb_5_5_version}-*-${SYS_BIT_b}/* ${mariadb_install_dir}
     mv mariadb-${mariadb_5_5_version}-*-${SYS_BIT_b}/* ${mariadb_install_dir}
 
 
-    if [ "${je_tc_malloc}" == "1" ];then
+    if [ "${je_tc_malloc}" == "1" ]; then
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe
-    elif [ "${je_tc_malloc}" == "2" ];then
+    elif [ "${je_tc_malloc}" == "2" ]; then
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' ${mariadb_install_dir}/bin/mysqld_safe
     fi
     fi
-  elif [ "${dbInstallMethods}" == "2" ];then
+  elif [ "${dbInstallMethods}" == "2" ]; then
     tar xvf mariadb-${mariadb_5_5_version}.tar.gz
     tar xvf mariadb-${mariadb_5_5_version}.tar.gz
     pushd mariadb-${mariadb_5_5_version}
     pushd mariadb-${mariadb_5_5_version}
 
 
-    if [ "${je_tc_malloc}" == "1" ];then
+    if [ "${je_tc_malloc}" == "1" ]; then
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
-    elif [ "${je_tc_malloc}" == "2" ];then
+    elif [ "${je_tc_malloc}" == "2" ]; then
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
     fi
     fi
     
     
-    if [ "${armPlatform}" == "y" ];then
+    if [ "${armPlatform}" == "y" ]; then
       patch -p1 < ../mysql-5.5-fix-arm-client_plugin.patch
       patch -p1 < ../mysql-5.5-fix-arm-client_plugin.patch
     fi
     fi
 
 
@@ -61,11 +61,11 @@ Install_MariaDB-5-5() {
     popd
     popd
   fi
   fi
 
 
-  if [ -d "${mariadb_install_dir}/support-files" ];then
+  if [ -d "${mariadb_install_dir}/support-files" ]; then
     echo "${CSUCCESS}MariaDB installed successfully! ${CEND}"
     echo "${CSUCCESS}MariaDB installed successfully! ${CEND}"
-    if [ "${dbInstallMethods}" == "1" ];then
+    if [ "${dbInstallMethods}" == "1" ]; then
       rm -rf mariadb-${mariadb_5_5_version}-*-${SYS_BIT_b}
       rm -rf mariadb-${mariadb_5_5_version}-*-${SYS_BIT_b}
-    elif [ "${dbInstallMethods}" == "2" ];then
+    elif [ "${dbInstallMethods}" == "2" ]; then
       rm -rf mariadb-${mariadb_5_5_version}
       rm -rf mariadb-${mariadb_5_5_version}
     fi
     fi
   else
   else
@@ -183,7 +183,7 @@ write_buffer = 4M
 EOF
 EOF
 
 
   sed -i "s@max_connections.*@max_connections = $((${Mem}/2))@" /etc/my.cnf
   sed -i "s@max_connections.*@max_connections = $((${Mem}/2))@" /etc/my.cnf
-  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ];then
+  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
@@ -191,7 +191,7 @@ EOF
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
-  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ];then
+  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
@@ -199,7 +199,7 @@ EOF
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
-  elif [ ${Mem} -gt 3500 ];then
+  elif [ ${Mem} -gt 3500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf

+ 83 - 92
include/memcached.sh

@@ -9,108 +9,99 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_memcached() {
 Install_memcached() {
-    pushd $oneinstack_dir/src
-    
-    # memcached server
-    id -u memcached >/dev/null 2>&1
-    [ $? -ne 0 ] && useradd -M -s /sbin/nologin memcached
-    
-    tar xzf memcached-$memcached_version.tar.gz
-    pushd memcached-$memcached_version
-    [ ! -d "$memcached_install_dir" ] && mkdir -p $memcached_install_dir
-    ./configure --prefix=$memcached_install_dir
-    make -j ${THREAD} && make install
-    if [ -d "$memcached_install_dir/include/memcached" ];then
-        echo "${CSUCCESS}memcached installed successfully! ${CEND}"
-        popd 
-        rm -rf memcached-$memcached_version
-        ln -s $memcached_install_dir/bin/memcached /usr/bin/memcached
-        [ "$OS" == 'CentOS' ] && { /bin/cp ../init.d/Memcached-init-CentOS /etc/init.d/memcached; chkconfig --add memcached; chkconfig memcached on; }
-        [[ $OS =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Memcached-init-Ubuntu /etc/init.d/memcached; update-rc.d memcached defaults; }
-        sed -i "s@/usr/local/memcached@$memcached_install_dir@g" /etc/init.d/memcached
-        [ -n "`grep 'CACHESIZE=' /etc/init.d/memcached`" ] && sed -i "s@^CACHESIZE=.*@CACHESIZE=`expr $Mem / 8`@" /etc/init.d/memcached
-        [ -n "`grep 'start_instance default 256;' /etc/init.d/memcached`" ] && sed -i "s@start_instance default 256;@start_instance default `expr $Mem / 8`;@" /etc/init.d/memcached
-        service memcached start
-    else
-        rm -rf $memcached_install_dir
-        echo "${CFAILURE}memcached install failed, Please contact the author! ${CEND}"
-        kill -9 $$
-    fi
-    popd
+  pushd ${oneinstack_dir}/src
+  # memcached server
+  id -u memcached >/dev/null 2>&1
+  [ $? -ne 0 ] && useradd -M -s /sbin/nologin memcached
+  tar xzf memcached-${memcached_version}.tar.gz
+  pushd memcached-${memcached_version}
+  [ ! -d "${memcached_install_dir}" ] && mkdir -p ${memcached_install_dir}
+  ./configure --prefix=${memcached_install_dir}
+  make -j ${THREAD} && make install
+  popd
+  if [ -d "${memcached_install_dir}/include/memcached" ]; then
+    echo "${CSUCCESS}memcached installed successfully! ${CEND}"
+    rm -rf memcached-${memcached_version}
+    ln -s ${memcached_install_dir}/bin/memcached /usr/bin/memcached
+    [ "$OS" == 'CentOS' ] && { /bin/cp ../init.d/Memcached-init-CentOS /etc/init.d/memcached; chkconfig --add memcached; chkconfig memcached on; }
+    [[ $OS =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Memcached-init-Ubuntu /etc/init.d/memcached; update-rc.d memcached defaults; }
+    sed -i "s@/usr/local/memcached@${memcached_install_dir}@g" /etc/init.d/memcached
+    [ -n "`grep 'CACHESIZE=' /etc/init.d/memcached`" ] && sed -i "s@^CACHESIZE=.*@CACHESIZE=`expr $Mem / 8`@" /etc/init.d/memcached
+    [ -n "`grep 'start_instance default 256;' /etc/init.d/memcached`" ] && sed -i "s@start_instance default 256;@start_instance default `expr $Mem / 8`;@" /etc/init.d/memcached
+    service memcached start
+    rm -rf memcached-${memcached_version}
+  else
+    rm -rf ${memcached_install_dir}
+    echo "${CFAILURE}memcached install failed, Please contact the author! ${CEND}"
+    kill -9 $$
+  fi
+  popd
 }
 }
 
 
 Install_php-memcache() {
 Install_php-memcache() {
-    pushd $oneinstack_dir/src
-    phpExtensionDir=`$php_install_dir/bin/php-config --extension-dir`
-    if [ -e "$php_install_dir/bin/phpize" ];then
-        # php memcache extension
-        if [ "`$php_install_dir/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}'`" == '7' ];then
-            #git clone https://github.com/websupport-sk/pecl-memcache.git
-            #cd pecl-memcache
-            tar xzf pecl-memcache-php7.tgz
-            pushd pecl-memcache-php7
-        else
-            tar xzf memcache-$memcache_pecl_version.tgz
-            pushd memcache-$memcache_pecl_version
-        fi
-        make clean
-        $php_install_dir/bin/phpize
-        ./configure --with-php-config=$php_install_dir/bin/php-config
-        make -j ${THREAD} && make install
-        if [ -f "${phpExtensionDir}/memcache.so" ];then
-            cat > $php_install_dir/etc/php.d/ext-memcache.ini << EOF
-extension=memcache.so
-EOF
-            [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
-            echo "${CSUCCESS}PHP memcache module installed successfully! ${CEND}"
-            popd
-            rm -rf memcache-$memcache_pecl_version
-        else
-            echo "${CFAILURE}PHP memcache module install failed, Please contact the author! ${CEND}"
-        fi
+  pushd ${oneinstack_dir}/src
+  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
+  if [ -e "${php_install_dir}/bin/phpize" ]; then
+    # php memcache extension
+    if [ "`${php_install_dir}/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}'`" == '7' ]; then
+      #git clone https://github.com/websupport-sk/pecl-memcache.git
+      tar xzf pecl-memcache-php7.tgz
+      pushd pecl-memcache-php7
+    else
+      tar xzf memcache-${memcache_pecl_version}.tgz
+      pushd memcache-${memcache_pecl_version}
     fi
     fi
+    ${php_install_dir}/bin/phpize
+    ./configure --with-php-config=${php_install_dir}/bin/php-config
+    make -j ${THREAD} && make install
     popd
     popd
+    if [ -f "${phpExtensionDir}/memcache.so" ]; then
+      echo 'extension=memcache.so' > ${php_install_dir}/etc/php.d/ext-memcache.ini
+      echo "${CSUCCESS}PHP memcache module installed successfully! ${CEND}"
+      rm -rf pecl-memcache-php7 memcache-${memcache_pecl_version}
+    else
+      echo "${CFAILURE}PHP memcache module install failed, Please contact the author! ${CEND}"
+    fi
+  fi
+  popd
 }
 }
 
 
 Install_php-memcached() {
 Install_php-memcached() {
-    pushd $oneinstack_dir/src
-    phpExtensionDir=`$php_install_dir/bin/php-config --extension-dir`
-    if [ -e "$php_install_dir/bin/phpize" ];then
-        # php memcached extension
-        tar xzf libmemcached-$libmemcached_version.tar.gz
-        pushd libmemcached-$libmemcached_version
-        [ "$OS" == 'CentOS' ] && yum -y install cyrus-sasl-devel
-        [[ $OS =~ ^Ubuntu$|^Debian$ ]] && sed -i "s@lthread -pthread -pthreads@lthread -lpthread -pthreads@" ./configure
-        ./configure --with-memcached=$memcached_install_dir
-        make -j ${THREAD} && make install
-        popd
-        rm -rf libmemcached-$libmemcached_version
-    
-        if [ "`$php_install_dir/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}'`" == '7' ];then
-            #git clone -b php7 https://github.com/php-memcached-dev/php-memcached.git
-            #cd php-memcached
-            tar xzf php-memcached-php7.tgz
-            pushd php-memcached-php7
-        else
-            tar xzf memcached-$memcached_pecl_version.tgz
-            pushd memcached-$memcached_pecl_version
-        fi
-        make clean
-        $php_install_dir/bin/phpize
-        ./configure --with-php-config=$php_install_dir/bin/php-config
-        make -j ${THREAD} && make install
-        if [ -f "${phpExtensionDir}/memcached.so" ];then
-            cat > $php_install_dir/etc/php.d/ext-memcached.ini << EOF
+  pushd ${oneinstack_dir}/src
+  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
+  if [ -e "${php_install_dir}/bin/phpize" ]; then
+    # php memcached extension
+    tar xzf libmemcached-$libmemcached_version.tar.gz
+    pushd libmemcached-$libmemcached_version
+    [ "$OS" == 'CentOS' ] && yum -y install cyrus-sasl-devel
+    [[ $OS =~ ^Ubuntu$|^Debian$ ]] && sed -i "s@lthread -pthread -pthreads@lthread -lpthread -pthreads@" ./configure
+    ./configure --with-memcached=${memcached_install_dir}
+    make -j ${THREAD} && make install
+    popd
+    rm -rf libmemcached-$libmemcached_version
+
+    if [ "`${php_install_dir}/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}'`" == '7' ]; then
+      #git clone -b php7 https://github.com/php-memcached-dev/php-memcached.git
+      tar xzf php-memcached-php7.tgz
+      pushd php-memcached-php7
+    else
+      tar xzf memcached-${memcached_pecl_version}.tgz
+      pushd memcached-${memcached_pecl_version}
+    fi
+    ${php_install_dir}/bin/phpize
+    ./configure --with-php-config=${php_install_dir}/bin/php-config
+    make -j ${THREAD} && make install
+    popd
+    if [ -f "${phpExtensionDir}/memcached.so" ]; then
+      cat > ${php_install_dir}/etc/php.d/ext-memcached.ini << EOF
 extension=memcached.so
 extension=memcached.so
 memcached.use_sasl=1
 memcached.use_sasl=1
 EOF
 EOF
-            echo "${CSUCCESS}PHP memcached module installed successfully! ${CEND}"
-            popd 
-            rm -rf memcached-$memcached_pecl_version
-            [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
-        else
-            echo "${CFAILURE}PHP memcached module install failed, Please contact the author! ${CEND}"
-        fi
+      echo "${CSUCCESS}PHP memcached module installed successfully! ${CEND}"
+      rm -rf php-memcached-php7 memcached-${memcached_pecl_version}
+    else
+      echo "${CFAILURE}PHP memcached module install failed, Please contact the author! ${CEND}"
     fi
     fi
-    popd
+  fi
+  popd
 }
 }

+ 34 - 37
include/memory.sh

@@ -11,47 +11,44 @@
 Mem=`free -m | awk '/Mem:/{print $2}'`
 Mem=`free -m | awk '/Mem:/{print $2}'`
 Swap=`free -m | awk '/Swap:/{print $2}'`
 Swap=`free -m | awk '/Swap:/{print $2}'`
 
 
-if [ $Mem -le 640 ];then
-    Mem_level=512M
-    Memory_limit=64
-elif [ $Mem -gt 640 -a $Mem -le 1280 ];then
-    Mem_level=1G
-    Memory_limit=128
-elif [ $Mem -gt 1280 -a $Mem -le 2500 ];then
-    Mem_level=2G
-    Memory_limit=192
-elif [ $Mem -gt 2500 -a $Mem -le 3500 ];then
-    Mem_level=3G
-    Memory_limit=256
-elif [ $Mem -gt 3500 -a $Mem -le 4500 ];then
-    Mem_level=4G
-    Memory_limit=320
-elif [ $Mem -gt 4500 -a $Mem -le 8000 ];then
-    Mem_level=6G
-    Memory_limit=384
-elif [ $Mem -gt 8000 ];then
-    Mem_level=8G
-    Memory_limit=448
+if [ $Mem -le 640 ]; then
+  Mem_level=512M
+  Memory_limit=64
+elif [ $Mem -gt 640 -a $Mem -le 1280 ]; then
+  Mem_level=1G
+  Memory_limit=128
+elif [ $Mem -gt 1280 -a $Mem -le 2500 ]; then
+  Mem_level=2G
+  Memory_limit=192
+elif [ $Mem -gt 2500 -a $Mem -le 3500 ]; then
+  Mem_level=3G
+  Memory_limit=256
+elif [ $Mem -gt 3500 -a $Mem -le 4500 ]; then
+  Mem_level=4G
+  Memory_limit=320
+elif [ $Mem -gt 4500 -a $Mem -le 8000 ]; then
+  Mem_level=6G
+  Memory_limit=384
+elif [ $Mem -gt 8000 ]; then
+  Mem_level=8G
+  Memory_limit=448
 fi
 fi
 
 
 Make-swapfile() {
 Make-swapfile() {
-    dd if=/dev/zero of=/swapfile count=$COUNT bs=1M
-    mkswap /swapfile
-    swapon /swapfile
-    chmod 600 /swapfile
-    [ -z "`grep swapfile /etc/fstab`" ] && cat >> /etc/fstab << EOF
-/swapfile    swap    swap    defaults    0 0
-EOF
-
+  dd if=/dev/zero of=/swapfile count=$COUNT bs=1M
+  mkswap /swapfile
+  swapon /swapfile
+  chmod 600 /swapfile
+  [ -z "`grep swapfile /etc/fstab`" ] && echo '/swapfile    swap    swap    defaults    0 0' >> /etc/fstab
 }
 }
 
 
 # add swapfile
 # add swapfile
-if [ "$Swap" == '0' ];then
-    if [ $Mem -le 1024 ];then
-        COUNT=1024
-        Make-swapfile
-    elif [ $Mem -gt 1024 -a $Mem -le 2048 ];then
-        COUNT=2048
-        Make-swapfile
-    fi
+if [ "$Swap" == '0' ]; then
+  if [ $Mem -le 1024 ]; then
+    COUNT=1024
+    Make-swapfile
+  elif [ $Mem -gt 1024 -a $Mem -le 2048 ]; then
+    COUNT=2048
+    Make-swapfile
+  fi
 fi
 fi

+ 12 - 12
include/mysql-5.5.sh

@@ -17,22 +17,22 @@ Install_MySQL-5-5() {
   [ ! -d "${mysql_install_dir}" ] && mkdir -p ${mysql_install_dir}
   [ ! -d "${mysql_install_dir}" ] && mkdir -p ${mysql_install_dir}
   mkdir -p ${mysql_data_dir};chown mysql.mysql -R ${mysql_data_dir}
   mkdir -p ${mysql_data_dir};chown mysql.mysql -R ${mysql_data_dir}
 
 
-  if [ "${dbInstallMethods}" == "1" ];then
+  if [ "${dbInstallMethods}" == "1" ]; then
     tar xvf mysql-${mysql_5_5_version}-linux2.6-${SYS_BIT_b}.tar.gz
     tar xvf mysql-${mysql_5_5_version}-linux2.6-${SYS_BIT_b}.tar.gz
     mv mysql-${mysql_5_5_version}-linux2.6-${SYS_BIT_b}/* ${mysql_install_dir}
     mv mysql-${mysql_5_5_version}-linux2.6-${SYS_BIT_b}/* ${mysql_install_dir}
 
 
-    if [ "${je_tc_malloc}" == "1" ];then
+    if [ "${je_tc_malloc}" == "1" ]; then
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mysql_install_dir}/bin/mysqld_safe
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mysql_install_dir}/bin/mysqld_safe
-    elif [ "${je_tc_malloc}" == "2" ];then
+    elif [ "${je_tc_malloc}" == "2" ]; then
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' ${mysql_install_dir}/bin/mysqld_safe
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' ${mysql_install_dir}/bin/mysqld_safe
     fi
     fi
-  elif [ "${dbInstallMethods}" == "2" ];then
+  elif [ "${dbInstallMethods}" == "2" ]; then
     tar xvf mysql-${mysql_5_5_version}.tar.gz
     tar xvf mysql-${mysql_5_5_version}.tar.gz
     pushd mysql-${mysql_5_5_version}
     pushd mysql-${mysql_5_5_version}
 
 
-    if [ "${je_tc_malloc}" == "1" ];then
+    if [ "${je_tc_malloc}" == "1" ]; then
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
-    elif [ "${je_tc_malloc}" == "2" ];then
+    elif [ "${je_tc_malloc}" == "2" ]; then
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
     fi
     fi
     
     
@@ -59,11 +59,11 @@ Install_MySQL-5-5() {
     popd
     popd
   fi
   fi
 
 
-  if [ -d "${mysql_install_dir}/support-files" ];then
+  if [ -d "${mysql_install_dir}/support-files" ]; then
     echo "${CSUCCESS}MySQL installed successfully! ${CEND}"
     echo "${CSUCCESS}MySQL installed successfully! ${CEND}"
-    if [ "${dbInstallMethods}" == "1" ];then
+    if [ "${dbInstallMethods}" == "1" ]; then
       rm -rf mysql-${mysql_5_5_version}-*-${SYS_BIT_b}
       rm -rf mysql-${mysql_5_5_version}-*-${SYS_BIT_b}
-    elif [ "${dbInstallMethods}" == "2" ];then
+    elif [ "${dbInstallMethods}" == "2" ]; then
       rm -rf mysql-${mysql_5_5_version}
       rm -rf mysql-${mysql_5_5_version}
     fi
     fi
   else
   else
@@ -184,7 +184,7 @@ write_buffer = 4M
 EOF
 EOF
 
 
   sed -i "s@max_connections.*@max_connections = $((${Mem}/2))@" /etc/my.cnf
   sed -i "s@max_connections.*@max_connections = $((${Mem}/2))@" /etc/my.cnf
-  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ];then
+  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
@@ -192,7 +192,7 @@ EOF
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
-  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ];then
+  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
@@ -200,7 +200,7 @@ EOF
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
-  elif [ ${Mem} -gt 3500 ];then
+  elif [ ${Mem} -gt 3500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf

+ 12 - 12
include/mysql-5.6.sh

@@ -17,22 +17,22 @@ Install_MySQL-5-6() {
   [ ! -d "${mysql_install_dir}" ] && mkdir -p ${mysql_install_dir}
   [ ! -d "${mysql_install_dir}" ] && mkdir -p ${mysql_install_dir}
   mkdir -p ${mysql_data_dir};chown mysql.mysql -R ${mysql_data_dir}
   mkdir -p ${mysql_data_dir};chown mysql.mysql -R ${mysql_data_dir}
 
 
-  if [ "${dbInstallMethods}" == "1" ];then
+  if [ "${dbInstallMethods}" == "1" ]; then
     tar xvf mysql-${mysql_5_6_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz
     tar xvf mysql-${mysql_5_6_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz
     mv mysql-${mysql_5_6_version}-linux-glibc2.5-${SYS_BIT_b}/* ${mysql_install_dir}
     mv mysql-${mysql_5_6_version}-linux-glibc2.5-${SYS_BIT_b}/* ${mysql_install_dir}
 
 
-    if [ "${je_tc_malloc}" == "1" ];then
+    if [ "${je_tc_malloc}" == "1" ]; then
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mysql_install_dir}/bin/mysqld_safe
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mysql_install_dir}/bin/mysqld_safe
-    elif [ "${je_tc_malloc}" == "2" ];then
+    elif [ "${je_tc_malloc}" == "2" ]; then
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' ${mysql_install_dir}/bin/mysqld_safe
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' ${mysql_install_dir}/bin/mysqld_safe
     fi
     fi
-  elif [ "${dbInstallMethods}" == "2" ];then
+  elif [ "${dbInstallMethods}" == "2" ]; then
     tar xvf mysql-${mysql_5_6_version}.tar.gz
     tar xvf mysql-${mysql_5_6_version}.tar.gz
     pushd mysql-${mysql_5_6_version}
     pushd mysql-${mysql_5_6_version}
 
 
-    if [ "${je_tc_malloc}" == "1" ];then
+    if [ "${je_tc_malloc}" == "1" ]; then
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
-    elif [ "${je_tc_malloc}" == "2" ];then
+    elif [ "${je_tc_malloc}" == "2" ]; then
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
     fi
     fi
 
 
@@ -56,11 +56,11 @@ Install_MySQL-5-6() {
     popd
     popd
   fi
   fi
 
 
-  if [ -d "${mysql_install_dir}/support-files" ];then
+  if [ -d "${mysql_install_dir}/support-files" ]; then
     echo "${CSUCCESS}MySQL installed successfully! ${CEND}"
     echo "${CSUCCESS}MySQL installed successfully! ${CEND}"
-    if [ "${dbInstallMethods}" == "1" ];then
+    if [ "${dbInstallMethods}" == "1" ]; then
       rm -rf mysql-${mysql_5_6_version}-*-${SYS_BIT_b}
       rm -rf mysql-${mysql_5_6_version}-*-${SYS_BIT_b}
-    elif [ "${dbInstallMethods}" == "2" ];then
+    elif [ "${dbInstallMethods}" == "2" ]; then
       rm -rf mysql-${mysql_5_6_version}
       rm -rf mysql-${mysql_5_6_version}
     fi
     fi
   else
   else
@@ -182,7 +182,7 @@ write_buffer = 4M
 EOF
 EOF
 
 
   sed -i "s@max_connections.*@max_connections = $((${Mem}/2))@" /etc/my.cnf
   sed -i "s@max_connections.*@max_connections = $((${Mem}/2))@" /etc/my.cnf
-  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ];then
+  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
@@ -190,7 +190,7 @@ EOF
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
-  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ];then
+  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
@@ -198,7 +198,7 @@ EOF
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
-  elif [ ${Mem} -gt 3500 ];then
+  elif [ ${Mem} -gt 3500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf

+ 12 - 12
include/mysql-5.7.sh

@@ -17,22 +17,22 @@ Install_MySQL-5-7() {
   [ ! -d "${mysql_install_dir}" ] && mkdir -p ${mysql_install_dir}
   [ ! -d "${mysql_install_dir}" ] && mkdir -p ${mysql_install_dir}
   mkdir -p ${mysql_data_dir};chown mysql.mysql -R ${mysql_data_dir}
   mkdir -p ${mysql_data_dir};chown mysql.mysql -R ${mysql_data_dir}
 
 
-  if [ "${dbInstallMethods}" == "1" ];then
+  if [ "${dbInstallMethods}" == "1" ]; then
     tar xvf mysql-${mysql_5_7_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz
     tar xvf mysql-${mysql_5_7_version}-linux-glibc2.5-${SYS_BIT_b}.tar.gz
     mv mysql-${mysql_5_7_version}-linux-glibc2.5-${SYS_BIT_b}/* ${mysql_install_dir}
     mv mysql-${mysql_5_7_version}-linux-glibc2.5-${SYS_BIT_b}/* ${mysql_install_dir}
 
 
-    if [ "${je_tc_malloc}" == "1" ];then
+    if [ "${je_tc_malloc}" == "1" ]; then
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mysql_install_dir}/bin/mysqld_safe
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${mysql_install_dir}/bin/mysqld_safe
-    elif [ "${je_tc_malloc}" == "2" ];then
+    elif [ "${je_tc_malloc}" == "2" ]; then
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' ${mysql_install_dir}/bin/mysqld_safe
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' ${mysql_install_dir}/bin/mysqld_safe
     fi
     fi
-  elif [ "${dbInstallMethods}" == "2" ];then
+  elif [ "${dbInstallMethods}" == "2" ]; then
     tar xvf mysql-${mysql_5_7_version}.tar.gz
     tar xvf mysql-${mysql_5_7_version}.tar.gz
     pushd mysql-${mysql_5_7_version}
     pushd mysql-${mysql_5_7_version}
 
 
-    if [ "${je_tc_malloc}" == "1" ];then
+    if [ "${je_tc_malloc}" == "1" ]; then
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
-    elif [ "${je_tc_malloc}" == "2" ];then
+    elif [ "${je_tc_malloc}" == "2" ]; then
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
     fi
     fi
 
 
@@ -56,11 +56,11 @@ Install_MySQL-5-7() {
     popd
     popd
   fi
   fi
 
 
-  if [ -d "${mysql_install_dir}/support-files" ];then
+  if [ -d "${mysql_install_dir}/support-files" ]; then
     echo "${CSUCCESS}MySQL installed successfully! ${CEND}"
     echo "${CSUCCESS}MySQL installed successfully! ${CEND}"
-    if [ "${dbInstallMethods}" == "1" ];then
+    if [ "${dbInstallMethods}" == "1" ]; then
       rm -rf mysql-${mysql_5_7_version}-*-${SYS_BIT_b}
       rm -rf mysql-${mysql_5_7_version}-*-${SYS_BIT_b}
-    elif [ "${dbInstallMethods}" == "2" ];then
+    elif [ "${dbInstallMethods}" == "2" ]; then
       rm -rf mysql-${mysql_5_7_version}
       rm -rf mysql-${mysql_5_7_version}
     fi
     fi
   else
   else
@@ -183,7 +183,7 @@ write_buffer = 4M
 EOF
 EOF
 
 
   sed -i "s@max_connections.*@max_connections = $((${Mem}/2))@" /etc/my.cnf
   sed -i "s@max_connections.*@max_connections = $((${Mem}/2))@" /etc/my.cnf
-  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ];then
+  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
@@ -191,7 +191,7 @@ EOF
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
-  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ];then
+  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
@@ -199,7 +199,7 @@ EOF
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
-  elif [ ${Mem} -gt 3500 ];then
+  elif [ ${Mem} -gt 3500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf

+ 54 - 55
include/nginx.sh

@@ -9,64 +9,63 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_Nginx() {
 Install_Nginx() {
-cd $oneinstack_dir/src
-
-id -u $run_user >/dev/null 2>&1
-[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
-
-tar xzf pcre-$pcre_version.tar.gz
-tar xzf nginx-$nginx_version.tar.gz
-tar xzf openssl-$openssl_version.tar.gz
-cd nginx-$nginx_version
-# Modify Nginx version
-#sed -i 's@#define NGINX_VERSION.*$@#define NGINX_VERSION      "1.2"@' src/core/nginx.h
-#sed -i 's@#define NGINX_VER.*NGINX_VERSION$@#define NGINX_VER          "Linuxeye/" NGINX_VERSION@' src/core/nginx.h
-#sed -i 's@Server: nginx@Server: linuxeye@' src/http/ngx_http_header_filter_module.c
-
-# close debug
-sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc
-
-if [ "$je_tc_malloc" == '1' ];then
+  pushd ${oneinstack_dir}/src
+  
+  id -u $run_user >/dev/null 2>&1
+  [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
+  
+  tar xzf pcre-$pcre_version.tar.gz
+  tar xzf nginx-$nginx_version.tar.gz
+  tar xzf openssl-$openssl_version.tar.gz
+  pushd nginx-$nginx_version
+  # Modify Nginx version
+  #sed -i 's@#define NGINX_VERSION.*$@#define NGINX_VERSION      "1.2"@' src/core/nginx.h
+  #sed -i 's@#define NGINX_VER.*NGINX_VERSION$@#define NGINX_VER          "Linuxeye/" NGINX_VERSION@' src/core/nginx.h
+  #sed -i 's@Server: nginx@Server: linuxeye@' src/http/ngx_http_header_filter_module.c
+  
+  # close debug
+  sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc
+  
+  if [ "$je_tc_malloc" == '1' ]; then
     malloc_module="--with-ld-opt='-ljemalloc'"
     malloc_module="--with-ld-opt='-ljemalloc'"
-elif [ "$je_tc_malloc" == '2' ];then
+  elif [ "$je_tc_malloc" == '2' ]; then
     malloc_module='--with-google_perftools_module'
     malloc_module='--with-google_perftools_module'
     mkdir /tmp/tcmalloc
     mkdir /tmp/tcmalloc
     chown -R ${run_user}.$run_user /tmp/tcmalloc
     chown -R ${run_user}.$run_user /tmp/tcmalloc
-fi
+  fi
 
 
-[ ! -d "$nginx_install_dir" ] && mkdir -p $nginx_install_dir
-./configure --prefix=$nginx_install_dir --user=$run_user --group=$run_user --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-openssl=../openssl-$openssl_version --with-pcre=../pcre-$pcre_version --with-pcre-jit $malloc_module
-make -j ${THREAD} && make install
-if [ -e "$nginx_install_dir/conf/nginx.conf" ];then
-    cd ..
+  [ ! -d "$nginx_install_dir" ] && mkdir -p $nginx_install_dir
+  ./configure --prefix=$nginx_install_dir --user=$run_user --group=$run_user --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-openssl=../openssl-$openssl_version --with-pcre=../pcre-$pcre_version --with-pcre-jit $malloc_module
+  make -j ${THREAD} && make install
+  if [ -e "$nginx_install_dir/conf/nginx.conf" ]; then
+    popd 
     rm -rf nginx-$nginx_version
     rm -rf nginx-$nginx_version
     echo "${CSUCCESS}Nginx installed successfully! ${CEND}"
     echo "${CSUCCESS}Nginx installed successfully! ${CEND}"
-else
+  else
     rm -rf $nginx_install_dir
     rm -rf $nginx_install_dir
     echo "${CFAILURE}Nginx install failed, Please Contact the author! ${CEND}"
     echo "${CFAILURE}Nginx install failed, Please Contact the author! ${CEND}"
     kill -9 $$
     kill -9 $$
-fi
+  fi
 
 
-[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$nginx_install_dir/sbin:\$PATH" >> /etc/profile
-[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $nginx_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$nginx_install_dir/sbin:\1@" /etc/profile
-. /etc/profile
+  [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$nginx_install_dir/sbin:\$PATH" >> /etc/profile
+  [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $nginx_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$nginx_install_dir/sbin:\1@" /etc/profile
+  . /etc/profile
+  
+  [ "$OS" == 'CentOS' ] && { /bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; }
+  [[ $OS =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx; update-rc.d nginx defaults; }
 
 
-[ "$OS" == 'CentOS' ] && { /bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; }
-[[ $OS =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx; update-rc.d nginx defaults; }
-cd ..
-
-sed -i "s@/usr/local/nginx@$nginx_install_dir@g" /etc/init.d/nginx
-
-mv $nginx_install_dir/conf/nginx.conf{,_bk}
-if [[ $Apache_version =~ ^[1-2]$ ]];then
-    /bin/cp config/nginx_apache.conf $nginx_install_dir/conf/nginx.conf
-elif [[ $Tomcat_version =~ ^[1-2]$ ]] && [ ! -e "$php_install_dir/bin/php" ];then
-    /bin/cp config/nginx_tomcat.conf $nginx_install_dir/conf/nginx.conf
-else
-    /bin/cp config/nginx.conf $nginx_install_dir/conf/nginx.conf
+  sed -i "s@/usr/local/nginx@$nginx_install_dir@g" /etc/init.d/nginx
+  
+  mv $nginx_install_dir/conf/nginx.conf{,_bk}
+  if [[ $Apache_version =~ ^[1-2]$ ]]; then
+    /bin/cp ../config/nginx_apache.conf $nginx_install_dir/conf/nginx.conf
+  elif [[ $Tomcat_version =~ ^[1-2]$ ]] && [ ! -e "$php_install_dir/bin/php" ]; then
+    /bin/cp ../config/nginx_tomcat.conf $nginx_install_dir/conf/nginx.conf
+  else
+    /bin/cp ../config/nginx.conf $nginx_install_dir/conf/nginx.conf
     [ "$PHP_yn" == 'y' ] && [ -z "`grep '/php-fpm_status' $nginx_install_dir/conf/nginx.conf`" ] &&  sed -i "s@index index.html index.php;@index index.html index.php;\n    location ~ /php-fpm_status {\n        #fastcgi_pass remote_php_ip:9000;\n        fastcgi_pass unix:/dev/shm/php-cgi.sock;\n        fastcgi_index index.php;\n        include fastcgi.conf;\n        allow 127.0.0.1;\n        deny all;\n        }@" $nginx_install_dir/conf/nginx.conf
     [ "$PHP_yn" == 'y' ] && [ -z "`grep '/php-fpm_status' $nginx_install_dir/conf/nginx.conf`" ] &&  sed -i "s@index index.html index.php;@index index.html index.php;\n    location ~ /php-fpm_status {\n        #fastcgi_pass remote_php_ip:9000;\n        fastcgi_pass unix:/dev/shm/php-cgi.sock;\n        fastcgi_index index.php;\n        include fastcgi.conf;\n        allow 127.0.0.1;\n        deny all;\n        }@" $nginx_install_dir/conf/nginx.conf
-fi
-cat > $nginx_install_dir/conf/proxy.conf << EOF
+  fi
+  cat > $nginx_install_dir/conf/proxy.conf << EOF
 proxy_connect_timeout 300s;
 proxy_connect_timeout 300s;
 proxy_send_timeout 900;
 proxy_send_timeout 900;
 proxy_read_timeout 900;
 proxy_read_timeout 900;
@@ -82,13 +81,13 @@ proxy_set_header Host \$host;
 proxy_set_header X-Real-IP \$remote_addr;
 proxy_set_header X-Real-IP \$remote_addr;
 proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
 proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
 EOF
 EOF
-sed -i "s@/data/wwwroot/default@$wwwroot_dir/default@" $nginx_install_dir/conf/nginx.conf
-sed -i "s@/data/wwwlogs@$wwwlogs_dir@g" $nginx_install_dir/conf/nginx.conf
-sed -i "s@^user www www@user $run_user $run_user@" $nginx_install_dir/conf/nginx.conf
-[ "$je_tc_malloc" == '2' ] && sed -i 's@^pid\(.*\)@pid\1\ngoogle_perftools_profiles /tmp/tcmalloc;@' $nginx_install_dir/conf/nginx.conf
-
-# logrotate nginx log
-cat > /etc/logrotate.d/nginx << EOF
+  sed -i "s@/data/wwwroot/default@$wwwroot_dir/default@" $nginx_install_dir/conf/nginx.conf
+  sed -i "s@/data/wwwlogs@$wwwlogs_dir@g" $nginx_install_dir/conf/nginx.conf
+  sed -i "s@^user www www@user $run_user $run_user@" $nginx_install_dir/conf/nginx.conf
+  [ "$je_tc_malloc" == '2' ] && sed -i 's@^pid\(.*\)@pid\1\ngoogle_perftools_profiles /tmp/tcmalloc;@' $nginx_install_dir/conf/nginx.conf
+  
+  # logrotate nginx log
+  cat > /etc/logrotate.d/nginx << EOF
 $wwwlogs_dir/*nginx.log {
 $wwwlogs_dir/*nginx.log {
 daily
 daily
 rotate 5
 rotate 5
@@ -102,7 +101,7 @@ postrotate
 endscript
 endscript
 }
 }
 EOF
 EOF
-
-ldconfig
-service nginx start
+  popd
+  ldconfig
+  service nginx start
 }
 }

+ 52 - 53
include/openresty.sh

@@ -9,61 +9,60 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_OpenResty() {
 Install_OpenResty() {
-cd $oneinstack_dir/src
-
-id -u $run_user >/dev/null 2>&1
-[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
-
-tar xzf pcre-$pcre_version.tar.gz
-tar xzf openresty-$openresty_version.tar.gz
-tar xzf openssl-$openssl_version.tar.gz
-cd openresty-$openresty_version
-
-# close debug
-openresty_version_tmp=${openresty_version%.*}
-sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' bundle/nginx-$openresty_version_tmp/auto/cc/gcc # close debug
-
-if [ "$je_tc_malloc" == '1' ];then
+  pushd ${oneinstack_dir}/src
+  
+  id -u $run_user >/dev/null 2>&1
+  [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
+  
+  tar xzf pcre-$pcre_version.tar.gz
+  tar xzf openresty-$openresty_version.tar.gz
+  tar xzf openssl-$openssl_version.tar.gz
+  pushd openresty-$openresty_version
+  
+  # close debug
+  openresty_version_tmp=${openresty_version%.*}
+  sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' bundle/nginx-$openresty_version_tmp/auto/cc/gcc # close debug
+  
+  if [ "$je_tc_malloc" == '1' ]; then
     malloc_module="--with-ld-opt='-ljemalloc'"
     malloc_module="--with-ld-opt='-ljemalloc'"
-elif [ "$je_tc_malloc" == '2' ];then
+  elif [ "$je_tc_malloc" == '2' ]; then
     malloc_module='--with-google_perftools_module'
     malloc_module='--with-google_perftools_module'
     mkdir /tmp/tcmalloc
     mkdir /tmp/tcmalloc
     chown -R ${run_user}.$run_user /tmp/tcmalloc
     chown -R ${run_user}.$run_user /tmp/tcmalloc
-fi
+  fi
 
 
-[ ! -d "$openresty_install_dir" ] && mkdir -p $openresty_install_dir
-./configure --prefix=$openresty_install_dir --user=$run_user --group=$run_user --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-openssl=../openssl-$openssl_version --with-pcre=../pcre-$pcre_version --with-pcre-jit $malloc_module
-make -j ${THREAD} && make install
-if [ -e "$openresty_install_dir/nginx/conf/nginx.conf" ];then
-    cd ..
+  [ ! -d "$openresty_install_dir" ] && mkdir -p $openresty_install_dir
+  ./configure --prefix=$openresty_install_dir --user=$run_user --group=$run_user --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-openssl=../openssl-$openssl_version --with-pcre=../pcre-$pcre_version --with-pcre-jit $malloc_module
+  make -j ${THREAD} && make install
+  if [ -e "$openresty_install_dir/nginx/conf/nginx.conf" ]; then
+    popd
     rm -rf openresty-$openresty_version
     rm -rf openresty-$openresty_version
     echo "${CSUCCESS}OpenResty installed successfully! ${CEND}"
     echo "${CSUCCESS}OpenResty installed successfully! ${CEND}"
-else
+  else
     rm -rf $openresty_install_dir
     rm -rf $openresty_install_dir
     echo "${CFAILURE}OpenResty install failed, Please Contact the author! ${CEND}"
     echo "${CFAILURE}OpenResty install failed, Please Contact the author! ${CEND}"
     kill -9 $$
     kill -9 $$
-fi
-
-[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$openresty_install_dir/nginx/sbin:\$PATH" >> /etc/profile
-[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $openresty_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$openresty_install_dir/nginx/sbin:\1@" /etc/profile
-. /etc/profile
+  fi
 
 
-[ "$OS" == 'CentOS' ] && { /bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; }
-[[ $OS =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx; update-rc.d nginx defaults; }
-cd ..
-
-sed -i "s@/usr/local/nginx@$openresty_install_dir/nginx@g" /etc/init.d/nginx
-
-mv $openresty_install_dir/nginx/conf/nginx.conf{,_bk}
-if [[ $Apache_version =~ ^[1-2]$ ]];then
-    /bin/cp config/nginx_apache.conf $openresty_install_dir/nginx/conf/nginx.conf
-elif [[ $Tomcat_version =~ ^[1-2]$ ]] && [ ! -e "$php_install_dir/bin/php" ];then
-    /bin/cp config/nginx_tomcat.conf $openresty_install_dir/nginx/conf/nginx.conf
-else
-    /bin/cp config/nginx.conf $openresty_install_dir/nginx/conf/nginx.conf
+  [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$openresty_install_dir/nginx/sbin:\$PATH" >> /etc/profile
+  [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $openresty_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$openresty_install_dir/nginx/sbin:\1@" /etc/profile
+  . /etc/profile
+  
+  [ "$OS" == 'CentOS' ] && { /bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; }
+  [[ $OS =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx; update-rc.d nginx defaults; }
+  
+  sed -i "s@/usr/local/nginx@$openresty_install_dir/nginx@g" /etc/init.d/nginx
+  
+  mv $openresty_install_dir/nginx/conf/nginx.conf{,_bk}
+  if [[ $Apache_version =~ ^[1-2]$ ]]; then
+    /bin/cp ../config/nginx_apache.conf $openresty_install_dir/nginx/conf/nginx.conf
+  elif [[ $Tomcat_version =~ ^[1-2]$ ]] && [ ! -e "$php_install_dir/bin/php" ]; then
+    /bin/cp ../config/nginx_tomcat.conf $openresty_install_dir/nginx/conf/nginx.conf
+  else
+    /bin/cp ../config/nginx.conf $openresty_install_dir/nginx/conf/nginx.conf
     [ "$PHP_yn" == 'y' ] && [ -z "`grep '/php-fpm_status' $openresty_install_dir/nginx/conf/nginx.conf`" ] &&  sed -i "s@index index.html index.php;@index index.html index.php;\n    location ~ /php-fpm_status {\n        #fastcgi_pass remote_php_ip:9000;\n        fastcgi_pass unix:/dev/shm/php-cgi.sock;\n        fastcgi_index index.php;\n        include fastcgi.conf;\n        allow 127.0.0.1;\n        deny all;\n        }@" $openresty_install_dir/nginx/conf/nginx.conf
     [ "$PHP_yn" == 'y' ] && [ -z "`grep '/php-fpm_status' $openresty_install_dir/nginx/conf/nginx.conf`" ] &&  sed -i "s@index index.html index.php;@index index.html index.php;\n    location ~ /php-fpm_status {\n        #fastcgi_pass remote_php_ip:9000;\n        fastcgi_pass unix:/dev/shm/php-cgi.sock;\n        fastcgi_index index.php;\n        include fastcgi.conf;\n        allow 127.0.0.1;\n        deny all;\n        }@" $openresty_install_dir/nginx/conf/nginx.conf
-fi
-cat > $openresty_install_dir/nginx/conf/proxy.conf << EOF
+  fi
+  cat > $openresty_install_dir/nginx/conf/proxy.conf << EOF
 proxy_connect_timeout 300s;
 proxy_connect_timeout 300s;
 proxy_send_timeout 900;
 proxy_send_timeout 900;
 proxy_read_timeout 900;
 proxy_read_timeout 900;
@@ -79,13 +78,13 @@ proxy_set_header Host \$host;
 proxy_set_header X-Real-IP \$remote_addr;
 proxy_set_header X-Real-IP \$remote_addr;
 proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
 proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
 EOF
 EOF
-sed -i "s@/data/wwwroot/default@$wwwroot_dir/default@" $openresty_install_dir/nginx/conf/nginx.conf
-sed -i "s@/data/wwwlogs@$wwwlogs_dir@g" $openresty_install_dir/nginx/conf/nginx.conf
-sed -i "s@^user www www@user $run_user $run_user@" $openresty_install_dir/nginx/conf/nginx.conf
-[ "$je_tc_malloc" == '2' ] && sed -i 's@^pid\(.*\)@pid\1\ngoogle_perftools_profiles /tmp/tcmalloc;@' $openresty_install_dir/nginx/conf/nginx.conf
-
-# logrotate nginx log
-cat > /etc/logrotate.d/nginx << EOF
+  sed -i "s@/data/wwwroot/default@$wwwroot_dir/default@" $openresty_install_dir/nginx/conf/nginx.conf
+  sed -i "s@/data/wwwlogs@$wwwlogs_dir@g" $openresty_install_dir/nginx/conf/nginx.conf
+  sed -i "s@^user www www@user $run_user $run_user@" $openresty_install_dir/nginx/conf/nginx.conf
+  [ "$je_tc_malloc" == '2' ] && sed -i 's@^pid\(.*\)@pid\1\ngoogle_perftools_profiles /tmp/tcmalloc;@' $openresty_install_dir/nginx/conf/nginx.conf
+  
+  # logrotate nginx log
+  cat > /etc/logrotate.d/nginx << EOF
 $wwwlogs_dir/*nginx.log {
 $wwwlogs_dir/*nginx.log {
 daily
 daily
 rotate 5
 rotate 5
@@ -99,7 +98,7 @@ postrotate
 endscript
 endscript
 }
 }
 EOF
 EOF
-
-ldconfig
-service nginx start
+  popd
+  ldconfig
+  service nginx start
 }
 }

+ 13 - 13
include/percona-5.5.sh

@@ -17,27 +17,27 @@ Install_Percona-5-5() {
   [ ! -d "${percona_install_dir}" ] && mkdir -p ${percona_install_dir}
   [ ! -d "${percona_install_dir}" ] && mkdir -p ${percona_install_dir}
   mkdir -p ${percona_data_dir};chown mysql.mysql -R ${percona_data_dir}
   mkdir -p ${percona_data_dir};chown mysql.mysql -R ${percona_data_dir}
 
 
-  if [ "${dbInstallMethods}" == "1" ];then
+  if [ "${dbInstallMethods}" == "1" ]; then
     perconaVerStr1=$(echo ${percona_5_5_version} | sed "s@-@-rel@")
     perconaVerStr1=$(echo ${percona_5_5_version} | sed "s@-@-rel@")
     tar xvf Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz
     tar xvf Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz
     mv Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}/* ${percona_install_dir}
     mv Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}/* ${percona_install_dir}
 
 
-    if [ "${je_tc_malloc}" == "1" ];then
+    if [ "${je_tc_malloc}" == "1" ]; then
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${percona_install_dir}/bin/mysqld_safe
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${percona_install_dir}/bin/mysqld_safe
-    elif [ "${je_tc_malloc}" == "2" ];then
+    elif [ "${je_tc_malloc}" == "2" ]; then
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' ${percona_install_dir}/bin/mysqld_safe
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' ${percona_install_dir}/bin/mysqld_safe
     fi
     fi
-  elif [ "${dbInstallMethods}" == "2" ];then
+  elif [ "${dbInstallMethods}" == "2" ]; then
     tar xvf percona-server-${percona_5_5_version}.tar.gz
     tar xvf percona-server-${percona_5_5_version}.tar.gz
     pushd percona-server-${percona_5_5_version}
     pushd percona-server-${percona_5_5_version}
 
 
-    if [ "${je_tc_malloc}" == "1" ];then
+    if [ "${je_tc_malloc}" == "1" ]; then
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
-    elif [ "${je_tc_malloc}" == "2" ];then
+    elif [ "${je_tc_malloc}" == "2" ]; then
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
     fi
     fi
 
 
-    if [ "${armPlatform}" == "y" ];then
+    if [ "${armPlatform}" == "y" ]; then
       patch -p1 < ../mysql-5.5-fix-arm-client_plugin.patch
       patch -p1 < ../mysql-5.5-fix-arm-client_plugin.patch
     fi
     fi
 
 
@@ -62,11 +62,11 @@ Install_Percona-5-5() {
     popd
     popd
   fi
   fi
 
 
-  if [ -d "${percona_install_dir}/support-files" ];then
+  if [ -d "${percona_install_dir}/support-files" ]; then
     echo "${CSUCCESS}Percona installed successfully! ${CEND}"
     echo "${CSUCCESS}Percona installed successfully! ${CEND}"
-    if [ "${dbInstallMethods}" == "1" ];then
+    if [ "${dbInstallMethods}" == "1" ]; then
       rm -rf Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}
       rm -rf Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}
-    elif [ "${dbInstallMethods}" == "2" ];then
+    elif [ "${dbInstallMethods}" == "2" ]; then
     rm -rf percona-server-${percona_5_5_version}
     rm -rf percona-server-${percona_5_5_version}
     fi
     fi
   else
   else
@@ -187,7 +187,7 @@ write_buffer = 4M
 EOF
 EOF
 
 
   sed -i "s@max_connections.*@max_connections = $((${Mem}/2))@" /etc/my.cnf
   sed -i "s@max_connections.*@max_connections = $((${Mem}/2))@" /etc/my.cnf
-  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ];then
+  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
@@ -195,7 +195,7 @@ EOF
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
-  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ];then
+  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
@@ -203,7 +203,7 @@ EOF
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
-  elif [ ${Mem} -gt 3500 ];then
+  elif [ ${Mem} -gt 3500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf

+ 12 - 12
include/percona-5.6.sh

@@ -17,23 +17,23 @@ Install_Percona-5-6() {
   [ ! -d "${percona_install_dir}" ] && mkdir -p ${percona_install_dir}
   [ ! -d "${percona_install_dir}" ] && mkdir -p ${percona_install_dir}
   mkdir -p ${percona_data_dir};chown mysql.mysql -R ${percona_data_dir}
   mkdir -p ${percona_data_dir};chown mysql.mysql -R ${percona_data_dir}
 
 
-  if [ "${dbInstallMethods}" == "1" ];then
+  if [ "${dbInstallMethods}" == "1" ]; then
     perconaVerStr1=$(echo ${percona_5_6_version} | sed "s@-@-rel@")
     perconaVerStr1=$(echo ${percona_5_6_version} | sed "s@-@-rel@")
     tar xvf Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz
     tar xvf Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz
     mv Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}/* ${percona_install_dir}
     mv Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}/* ${percona_install_dir}
 
 
-    if [ "${je_tc_malloc}" == "1" ];then
+    if [ "${je_tc_malloc}" == "1" ]; then
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${percona_install_dir}/bin/mysqld_safe
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${percona_install_dir}/bin/mysqld_safe
-    elif [ "${je_tc_malloc}" == "2" ];then
+    elif [ "${je_tc_malloc}" == "2" ]; then
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' ${percona_install_dir}/bin/mysqld_safe
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' ${percona_install_dir}/bin/mysqld_safe
     fi
     fi
-  elif [ "${dbInstallMethods}" == "2" ];then
+  elif [ "${dbInstallMethods}" == "2" ]; then
     tar xvf percona-server-${percona_5_6_version}.tar.gz
     tar xvf percona-server-${percona_5_6_version}.tar.gz
     pushd percona-server-${percona_5_6_version}
     pushd percona-server-${percona_5_6_version}
 
 
-    if [ "${je_tc_malloc}" == "1" ];then
+    if [ "${je_tc_malloc}" == "1" ]; then
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
-    elif [ "${je_tc_malloc}" == "2" ];then
+    elif [ "${je_tc_malloc}" == "2" ]; then
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
     fi
     fi
 
 
@@ -58,11 +58,11 @@ Install_Percona-5-6() {
     popd
     popd
   fi
   fi
 
 
-  if [ -d "${percona_install_dir}/support-files" ];then
+  if [ -d "${percona_install_dir}/support-files" ]; then
     echo "${CSUCCESS}Percona installed successfully! ${CEND}"
     echo "${CSUCCESS}Percona installed successfully! ${CEND}"
-    if [ "${dbInstallMethods}" == "1" ];then
+    if [ "${dbInstallMethods}" == "1" ]; then
       rm -rf Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}
       rm -rf Percona-Server-${perconaVerStr1}-Linux.${SYS_BIT_b}.${sslLibVer}
-    elif [ "${dbInstallMethods}" == "2" ];then
+    elif [ "${dbInstallMethods}" == "2" ]; then
       rm -rf percona-server-${percona_5_6_version}
       rm -rf percona-server-${percona_5_6_version}
     fi
     fi
   else
   else
@@ -184,7 +184,7 @@ write_buffer = 4M
 EOF
 EOF
 
 
   sed -i "s@max_connections.*@max_connections = $((${Mem}/2))@" /etc/my.cnf
   sed -i "s@max_connections.*@max_connections = $((${Mem}/2))@" /etc/my.cnf
-  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ];then
+  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
@@ -192,7 +192,7 @@ EOF
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
-  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ];then
+  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
@@ -200,7 +200,7 @@ EOF
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
-  elif [ ${Mem} -gt 3500 ];then
+  elif [ ${Mem} -gt 3500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf

+ 12 - 12
include/percona-5.7.sh

@@ -17,22 +17,22 @@ Install_Percona-5-7() {
   [ ! -d "${percona_install_dir}" ] && mkdir -p ${percona_install_dir}
   [ ! -d "${percona_install_dir}" ] && mkdir -p ${percona_install_dir}
   mkdir -p ${percona_data_dir};chown mysql.mysql -R ${percona_data_dir}
   mkdir -p ${percona_data_dir};chown mysql.mysql -R ${percona_data_dir}
 
 
-  if [ "${dbInstallMethods}" == "1" ];then
+  if [ "${dbInstallMethods}" == "1" ]; then
     tar xvf Percona-Server-${percona_5_7_version}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz
     tar xvf Percona-Server-${percona_5_7_version}-Linux.${SYS_BIT_b}.${sslLibVer}.tar.gz
     mv Percona-Server-${percona_5_7_version}-Linux.${SYS_BIT_b}.${sslLibVer}/* ${percona_install_dir}
     mv Percona-Server-${percona_5_7_version}-Linux.${SYS_BIT_b}.${sslLibVer}/* ${percona_install_dir}
 
 
-    if [ "${je_tc_malloc}" == "1" ];then
+    if [ "${je_tc_malloc}" == "1" ]; then
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${percona_install_dir}/bin/mysqld_safe
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' ${percona_install_dir}/bin/mysqld_safe
-    elif [ "${je_tc_malloc}" == "2" ];then
+    elif [ "${je_tc_malloc}" == "2" ]; then
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' ${percona_install_dir}/bin/mysqld_safe
       sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' ${percona_install_dir}/bin/mysqld_safe
     fi
     fi
-  elif [ "${dbInstallMethods}" == "2" ];then
+  elif [ "${dbInstallMethods}" == "2" ]; then
     tar xvf percona-server-${percona_5_7_version}.tar.gz
     tar xvf percona-server-${percona_5_7_version}.tar.gz
     pushd percona-server-${percona_5_7_version}
     pushd percona-server-${percona_5_7_version}
 
 
-    if [ "${je_tc_malloc}" == "1" ];then
+    if [ "${je_tc_malloc}" == "1" ]; then
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"
-    elif [ "${je_tc_malloc}" == "2" ];then
+    elif [ "${je_tc_malloc}" == "2" ]; then
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
       EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"
     fi
     fi
 
 
@@ -58,11 +58,11 @@ Install_Percona-5-7() {
     popd
     popd
   fi
   fi
 
 
-  if [ -d "${percona_install_dir}/support-files" ];then
+  if [ -d "${percona_install_dir}/support-files" ]; then
     echo "${CSUCCESS}Percona installed successfully! ${CEND}"
     echo "${CSUCCESS}Percona installed successfully! ${CEND}"
-    if [ "${dbInstallMethods}" == "1" ];then
+    if [ "${dbInstallMethods}" == "1" ]; then
       rm -rf Percona-Server-${percona_5_7_version}-Linux.${SYS_BIT_b}.${sslLibVer}
       rm -rf Percona-Server-${percona_5_7_version}-Linux.${SYS_BIT_b}.${sslLibVer}
-    elif [ "${dbInstallMethods}" == "2" ];then
+    elif [ "${dbInstallMethods}" == "2" ]; then
       rm -rf percona-server-${percona_5_7_version}
       rm -rf percona-server-${percona_5_7_version}
     fi
     fi
   else
   else
@@ -184,7 +184,7 @@ write_buffer = 4M
 EOF
 EOF
 
 
   sed -i "s@max_connections.*@max_connections = $((${Mem}/2))@" /etc/my.cnf
   sed -i "s@max_connections.*@max_connections = $((${Mem}/2))@" /etc/my.cnf
-  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ];then
+  if [ ${Mem} -gt 1500 -a ${Mem} -le 2500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 16@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 16M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 16M@' /etc/my.cnf
@@ -192,7 +192,7 @@ EOF
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 128M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 32M@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 256@' /etc/my.cnf
-  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ];then
+  elif [ ${Mem} -gt 2500 -a ${Mem} -le 3500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 32@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 32M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 32M@' /etc/my.cnf
@@ -200,7 +200,7 @@ EOF
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
     sed -i 's@^innodb_buffer_pool_size.*@innodb_buffer_pool_size = 512M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
     sed -i 's@^tmp_table_size.*@tmp_table_size = 64M@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
     sed -i 's@^table_open_cache.*@table_open_cache = 512@' /etc/my.cnf
-  elif [ ${Mem} -gt 3500 ];then
+  elif [ ${Mem} -gt 3500 ]; then
     sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
     sed -i 's@^thread_cache_size.*@thread_cache_size = 64@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
     sed -i 's@^query_cache_size.*@query_cache_size = 64M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf
     sed -i 's@^myisam_sort_buffer_size.*@myisam_sort_buffer_size = 64M@' /etc/my.cnf

+ 156 - 156
include/php-5.3.sh

@@ -9,143 +9,143 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_PHP-5-3() {
 Install_PHP-5-3() {
-cd $oneinstack_dir/src
-
-tar xzf libiconv-$libiconv_version.tar.gz
-patch -d libiconv-$libiconv_version -p0 < libiconv-glibc-2.16.patch
-cd libiconv-$libiconv_version
-./configure --prefix=/usr/local
-make -j ${THREAD} && make install
-cd ..
-rm -rf libiconv-$libiconv_version
-
-# Problem building php-5.3 with openssl
-if [ "$Debian_version" == '8' -o "$Ubuntu_version" == '16' ];then
-    if [ ! -e '/usr/local/openssl/lib/libcrypto.a' ];then
-        tar xzf openssl-1.0.0s.tar.gz
-        cd openssl-1.0.0s
-        ./config --prefix=/usr/local/openssl -fPIC shared zlib
-        make -j ${THREAD} && make install
-        cd ..
-        rm -rf openssl-1.0.0s
+  pushd ${oneinstack_dir}/src
+  
+  tar xzf libiconv-$libiconv_version.tar.gz
+  patch -d libiconv-$libiconv_version -p0 < libiconv-glibc-2.16.patch
+  pushd libiconv-$libiconv_version
+  ./configure --prefix=/usr/local
+  make -j ${THREAD} && make install
+  popd
+  rm -rf libiconv-$libiconv_version
+  
+  # Problem building php-5.3 with openssl
+  if [ "$Debian_version" == '8' -o "$Ubuntu_version" == '16' ]; then
+    if [ ! -e '/usr/local/openssl/lib/libcrypto.a' ]; then
+      tar xzf openssl-1.0.0s.tar.gz
+      pushd openssl-1.0.0s
+      ./config --prefix=/usr/local/openssl -fPIC shared zlib
+      make -j ${THREAD} && make install
+      popd 
+      rm -rf openssl-1.0.0s
     fi
     fi
     OpenSSL_args='--with-openssl=/usr/local/openssl'
     OpenSSL_args='--with-openssl=/usr/local/openssl'
-else
+  else
     OpenSSL_args='--with-openssl'
     OpenSSL_args='--with-openssl'
-fi
-
-tar xzf curl-$curl_version.tar.gz
-cd curl-$curl_version
-if [ "$Debian_version" == '8' -o "$Ubuntu_version" == '16' ];then
+  fi
+  
+  tar xzf curl-$curl_version.tar.gz
+  pushd curl-$curl_version
+  if [ "$Debian_version" == '8' -o "$Ubuntu_version" == '16' ]; then
     LDFLAGS="-Wl,-rpath=/usr/local/openssl/lib" ./configure --prefix=/usr/local --with-ssl=/usr/local/openssl
     LDFLAGS="-Wl,-rpath=/usr/local/openssl/lib" ./configure --prefix=/usr/local --with-ssl=/usr/local/openssl
-else
+  else
     ./configure --prefix=/usr/local
     ./configure --prefix=/usr/local
-fi
-make -j ${THREAD} && make install
-cd ..
-rm -rf curl-$curl_version
-
-tar xzf libmcrypt-$libmcrypt_version.tar.gz
-cd libmcrypt-$libmcrypt_version
-./configure
-make -j ${THREAD} && make install
-ldconfig
-cd libltdl
-./configure --enable-ltdl-install
-make -j ${THREAD} && make install
-cd ../../
-rm -rf libmcrypt-$libmcrypt_version
-
-tar xzf mhash-$mhash_version.tar.gz
-cd mhash-$mhash_version
-./configure
-make -j ${THREAD} && make install
-cd ..
-rm -rf mhash-$mhash_version
-
-echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
-ldconfig
-[ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; }
-
-[ ! -e '/usr/include/freetype2/freetype' ] &&  ln -s /usr/include/freetype2 /usr/include/freetype2/freetype
-
-tar xzf mcrypt-$mcrypt_version.tar.gz
-cd mcrypt-$mcrypt_version
-ldconfig
-./configure
-make -j ${THREAD} && make install
-cd ..
-rm -rf mcrypt-$mcrypt_version
-
-id -u $run_user >/dev/null 2>&1
-[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
-
-tar xzf php-$php_3_version.tar.gz
-patch -d php-$php_3_version -p0 < fpm-race-condition.patch
-cd php-$php_3_version
-patch -p1 < ../php5.3patch
-patch -p1 < ../debian_patches_disable_SSLv2_for_openssl_1_0_0.patch
-make clean
-[ ! -d "$php_install_dir" ] && mkdir -p $php_install_dir
-if [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ];then
+  fi
+  make -j ${THREAD} && make install
+  popd
+  rm -rf curl-$curl_version
+  
+  tar xzf libmcrypt-$libmcrypt_version.tar.gz
+  pushd libmcrypt-$libmcrypt_version
+  ./configure
+  make -j ${THREAD} && make install
+  ldconfig
+  pushd libltdl
+  ./configure --enable-ltdl-install
+  make -j ${THREAD} && make install
+  popd;popd 
+  rm -rf libmcrypt-$libmcrypt_version
+  
+  tar xzf mhash-$mhash_version.tar.gz
+  pushd mhash-$mhash_version
+  ./configure
+  make -j ${THREAD} && make install
+  popd 
+  rm -rf mhash-$mhash_version
+  
+  echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
+  ldconfig
+  [ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; }
+  
+  [ ! -e '/usr/include/freetype2/freetype' ] &&  ln -s /usr/include/freetype2 /usr/include/freetype2/freetype
+  
+  tar xzf mcrypt-$mcrypt_version.tar.gz
+  pushd mcrypt-$mcrypt_version
+  ldconfig
+  ./configure
+  make -j ${THREAD} && make install
+  popd 
+  rm -rf mcrypt-$mcrypt_version
+  
+  id -u $run_user >/dev/null 2>&1
+  [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
+  
+  tar xzf php-$php_3_version.tar.gz
+  patch -d php-$php_3_version -p0 < fpm-race-condition.patch
+  pushd php-$php_3_version
+  patch -p1 < ../php5.3patch
+  patch -p1 < ../debian_patches_disable_SSLv2_for_openssl_1_0_0.patch
+  make clean
+  [ ! -d "$php_install_dir" ] && mkdir -p $php_install_dir
+  if [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ]; then
     ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
     ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
---with-config-file-scan-dir=$php_install_dir/etc/php.d \
---with-apxs2=$apache_install_dir/bin/apxs --disable-fileinfo \
---with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
---with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
---with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
---enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
---enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf $OpenSSL_args \
---with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
---with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
-else
+    --with-config-file-scan-dir=$php_install_dir/etc/php.d \
+    --with-apxs2=$apache_install_dir/bin/apxs --disable-fileinfo \
+    --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
+    --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
+    --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
+    --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
+    --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf $OpenSSL_args \
+    --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
+    --with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+  else
     ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
     ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
---with-config-file-scan-dir=$php_install_dir/etc/php.d \
---with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm --disable-fileinfo \
---with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
---with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
---with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
---enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
---enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf $OpenSSL_args \
---with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
---with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
-fi
-sed -i '/^BUILD_/ s/\$(CC)/\$(CXX)/g' Makefile
-make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD}
-make install
-
-if [ -e "$php_install_dir/bin/phpize" ];then
+    --with-config-file-scan-dir=$php_install_dir/etc/php.d \
+    --with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm --disable-fileinfo \
+    --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
+    --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
+    --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
+    --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
+    --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf $OpenSSL_args \
+    --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
+    --with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+  fi
+  sed -i '/^BUILD_/ s/\$(CC)/\$(CXX)/g' Makefile
+  make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD}
+  make install
+  
+  if [ -e "$php_install_dir/bin/phpize" ]; then
     echo "${CSUCCESS}PHP installed successfully! ${CEND}"
     echo "${CSUCCESS}PHP installed successfully! ${CEND}"
-else
+  else
     rm -rf $php_install_dir
     rm -rf $php_install_dir
     echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}"
     echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}"
     kill -9 $$
     kill -9 $$
-fi
-
-[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$php_install_dir/bin:\$PATH" >> /etc/profile
-[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $php_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$php_install_dir/bin:\1@" /etc/profile
-. /etc/profile
-
-# wget -c http://pear.php.net/go-pear.phar
-# $php_install_dir/bin/php go-pear.phar
-
-[ ! -e "$php_install_dir/etc/php.d" ] && mkdir -p $php_install_dir/etc/php.d
-/bin/cp php.ini-production $php_install_dir/etc/php.ini
-
-sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" $php_install_dir/etc/php.ini
-sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' $php_install_dir/etc/php.ini
-sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' $php_install_dir/etc/php.ini
-sed -i 's@^short_open_tag = Off@short_open_tag = On@' $php_install_dir/etc/php.ini
-sed -i 's@^expose_php = On@expose_php = Off@' $php_install_dir/etc/php.ini
-sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini
-sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini
-sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini
-sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini
-sed -i 's@^max_execution_time.*@max_execution_time = 5@' $php_install_dir/etc/php.ini
-sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini
-[ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini
-
-if [[ ! $Apache_version =~ ^[1-2]$ ]] && [ ! -e "$apache_install_dir/bin/apxs" ];then
+  fi
+  
+  [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$php_install_dir/bin:\$PATH" >> /etc/profile
+  [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $php_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$php_install_dir/bin:\1@" /etc/profile
+  . /etc/profile
+  
+  # wget -c http://pear.php.net/go-pear.phar
+  # $php_install_dir/bin/php go-pear.phar
+  
+  [ ! -e "$php_install_dir/etc/php.d" ] && mkdir -p $php_install_dir/etc/php.d
+  /bin/cp php.ini-production $php_install_dir/etc/php.ini
+  
+  sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" $php_install_dir/etc/php.ini
+  sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' $php_install_dir/etc/php.ini
+  sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' $php_install_dir/etc/php.ini
+  sed -i 's@^short_open_tag = Off@short_open_tag = On@' $php_install_dir/etc/php.ini
+  sed -i 's@^expose_php = On@expose_php = Off@' $php_install_dir/etc/php.ini
+  sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini
+  sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini
+  sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini
+  sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini
+  sed -i 's@^max_execution_time.*@max_execution_time = 5@' $php_install_dir/etc/php.ini
+  sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini
+  [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini
+  
+  if [[ ! $Apache_version =~ ^[1-2]$ ]] && [ ! -e "$apache_install_dir/bin/apxs" ]; then
     # php-fpm Init Script
     # php-fpm Init Script
     /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
     /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
     chmod +x /etc/init.d/php-fpm
     chmod +x /etc/init.d/php-fpm
@@ -210,40 +210,40 @@ EOF
 
 
     [ -d "/run/shm" -a ! -e "/dev/shm" ] && sed -i 's@/dev/shm@/run/shm@' $php_install_dir/etc/php-fpm.conf $oneinstack_dir/vhost.sh $oneinstack_dir/config/nginx.conf
     [ -d "/run/shm" -a ! -e "/dev/shm" ] && sed -i 's@/dev/shm@/run/shm@' $php_install_dir/etc/php-fpm.conf $oneinstack_dir/vhost.sh $oneinstack_dir/config/nginx.conf
 
 
-    if [ $Mem -le 3000 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/3/30))@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/3/40))@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
-    elif [ $Mem -gt 3000 -a $Mem -le 4500 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = 50@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = 30@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 20@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
-    elif [ $Mem -gt 4500 -a $Mem -le 6500 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = 60@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = 40@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 30@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 60@" $php_install_dir/etc/php-fpm.conf
-    elif [ $Mem -gt 6500 -a $Mem -le 8500 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = 70@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = 50@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 40@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 70@" $php_install_dir/etc/php-fpm.conf
-    elif [ $Mem -gt 8500 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = 80@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = 60@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 80@" $php_install_dir/etc/php-fpm.conf
+    if [ $Mem -le 3000 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/3/30))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/3/40))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 3000 -a $Mem -le 4500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 30@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 20@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 4500 -a $Mem -le 6500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 60@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 40@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 30@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 60@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 6500 -a $Mem -le 8500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 70@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 40@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 70@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 8500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 80@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 60@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 80@" $php_install_dir/etc/php-fpm.conf
     fi
     fi
 
 
     #[ "$Web_yn" == 'n' ] && sed -i "s@^listen =.*@listen = $IPADDR:9000@" $php_install_dir/etc/php-fpm.conf
     #[ "$Web_yn" == 'n' ] && sed -i "s@^listen =.*@listen = $IPADDR:9000@" $php_install_dir/etc/php-fpm.conf
     service php-fpm start
     service php-fpm start
 
 
-elif [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ];then
+  elif [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ]; then
     service httpd restart
     service httpd restart
-fi
-cd ..
-[ -e "$php_install_dir/bin/phpize" ] && rm -rf php-$php_3_version
-cd ..
+  fi
+  popd
+  [ -e "$php_install_dir/bin/phpize" ] && rm -rf php-$php_3_version
+  popd
 }
 }

+ 137 - 137
include/php-5.4.sh

@@ -9,119 +9,119 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_PHP-5-4() {
 Install_PHP-5-4() {
-cd $oneinstack_dir/src
-
-tar xzf libiconv-$libiconv_version.tar.gz
-patch -d libiconv-$libiconv_version -p0 < libiconv-glibc-2.16.patch
-cd libiconv-$libiconv_version
-./configure --prefix=/usr/local
-make -j ${THREAD} && make install
-cd ..
-rm -rf libiconv-$libiconv_version
-
-tar xzf curl-$curl_version.tar.gz
-cd curl-$curl_version
-./configure --prefix=/usr/local
-make -j ${THREAD} && make install
-cd ..
-rm -rf curl-$curl_version
-
-tar xzf libmcrypt-$libmcrypt_version.tar.gz
-cd libmcrypt-$libmcrypt_version
-./configure
-make -j ${THREAD} && make install
-ldconfig
-cd libltdl
-./configure --enable-ltdl-install
-make -j ${THREAD} && make install
-cd ../../
-rm -rf libmcrypt-$libmcrypt_version
-
-tar xzf mhash-$mhash_version.tar.gz
-cd mhash-$mhash_version
-./configure
-make -j ${THREAD} && make install
-cd ..
-rm -rf mhash-$mhash_version
-
-echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
-ldconfig
-[ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; }
-
-tar xzf mcrypt-$mcrypt_version.tar.gz
-cd mcrypt-$mcrypt_version
-ldconfig
-./configure
-make -j ${THREAD} && make install
-cd ..
-rm -rf mcrypt-$mcrypt_version
-
-id -u $run_user >/dev/null 2>&1
-[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
-
-tar xzf php-$php_4_version.tar.gz
-patch -d php-$php_4_version -p0 < fpm-race-condition.patch
-cd php-$php_4_version
-make clean
-[ ! -d "$php_install_dir" ] && mkdir -p $php_install_dir
-if [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ];then
+  pushd ${oneinstack_dir}/src
+  
+  tar xzf libiconv-$libiconv_version.tar.gz
+  patch -d libiconv-$libiconv_version -p0 < libiconv-glibc-2.16.patch
+  pushd libiconv-$libiconv_version
+  ./configure --prefix=/usr/local
+  make -j ${THREAD} && make install
+  popd
+  rm -rf libiconv-$libiconv_version
+  
+  tar xzf curl-$curl_version.tar.gz
+  pushd curl-$curl_version
+  ./configure --prefix=/usr/local
+  make -j ${THREAD} && make install
+  popd
+  rm -rf curl-$curl_version
+  
+  tar xzf libmcrypt-$libmcrypt_version.tar.gz
+  pushd libmcrypt-$libmcrypt_version
+  ./configure
+  make -j ${THREAD} && make install
+  ldconfig
+  pushd libltdl
+  ./configure --enable-ltdl-install
+  make -j ${THREAD} && make install
+  popd;popd
+  rm -rf libmcrypt-$libmcrypt_version
+  
+  tar xzf mhash-$mhash_version.tar.gz
+  pushd mhash-$mhash_version
+  ./configure
+  make -j ${THREAD} && make install
+  popd 
+  rm -rf mhash-$mhash_version
+  
+  echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
+  ldconfig
+  [ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; }
+  
+  tar xzf mcrypt-$mcrypt_version.tar.gz
+  pushd mcrypt-$mcrypt_version
+  ldconfig
+  ./configure
+  make -j ${THREAD} && make install
+  popd
+  rm -rf mcrypt-$mcrypt_version
+  
+  id -u $run_user >/dev/null 2>&1
+  [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
+  
+  tar xzf php-$php_4_version.tar.gz
+  patch -d php-$php_4_version -p0 < fpm-race-condition.patch
+  pushd php-$php_4_version
+  make clean
+  [ ! -d "$php_install_dir" ] && mkdir -p $php_install_dir
+  if [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ]; then
     ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
     ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
---with-config-file-scan-dir=$php_install_dir/etc/php.d \
---with-apxs2=$apache_install_dir/bin/apxs --disable-fileinfo \
---with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
---with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
---with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
---enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
---enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
---with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
---with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
-else
+    --with-config-file-scan-dir=$php_install_dir/etc/php.d \
+    --with-apxs2=$apache_install_dir/bin/apxs --disable-fileinfo \
+    --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
+    --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
+    --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
+    --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
+    --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
+    --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
+    --with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+  else
     ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
     ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
---with-config-file-scan-dir=$php_install_dir/etc/php.d \
---with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm --disable-fileinfo \
---with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
---with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
---with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
---enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
---enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
---with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
---with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
-fi
-make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD}
-make install
-
-if [ -e "$php_install_dir/bin/phpize" ];then
+    --with-config-file-scan-dir=$php_install_dir/etc/php.d \
+    --with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm --disable-fileinfo \
+    --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
+    --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
+    --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
+    --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
+    --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
+    --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
+    --with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+  fi
+  make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD}
+  make install
+  
+  if [ -e "$php_install_dir/bin/phpize" ]; then
     echo "${CSUCCESS}PHP installed successfully! ${CEND}"
     echo "${CSUCCESS}PHP installed successfully! ${CEND}"
-else
+  else
     rm -rf $php_install_dir
     rm -rf $php_install_dir
     echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}"
     echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}"
     kill -9 $$
     kill -9 $$
-fi
-
-[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$php_install_dir/bin:\$PATH" >> /etc/profile
-[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $php_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$php_install_dir/bin:\1@" /etc/profile
-. /etc/profile
-
-# wget -c http://pear.php.net/go-pear.phar
-# $php_install_dir/bin/php go-pear.phar
-
-[ ! -e "$php_install_dir/etc/php.d" ] && mkdir -p $php_install_dir/etc/php.d
-/bin/cp php.ini-production $php_install_dir/etc/php.ini
-
-sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" $php_install_dir/etc/php.ini
-sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' $php_install_dir/etc/php.ini
-sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' $php_install_dir/etc/php.ini
-sed -i 's@^short_open_tag = Off@short_open_tag = On@' $php_install_dir/etc/php.ini
-sed -i 's@^expose_php = On@expose_php = Off@' $php_install_dir/etc/php.ini
-sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini
-sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini
-sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini
-sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini
-sed -i 's@^max_execution_time.*@max_execution_time = 5@' $php_install_dir/etc/php.ini
-sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini
-[ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini
-
-if [[ ! $Apache_version =~ ^[1-2]$ ]] && [ ! -e "$apache_install_dir/bin/apxs" ];then
+  fi
+  
+  [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$php_install_dir/bin:\$PATH" >> /etc/profile
+  [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $php_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$php_install_dir/bin:\1@" /etc/profile
+  . /etc/profile
+  
+  # wget -c http://pear.php.net/go-pear.phar
+  # $php_install_dir/bin/php go-pear.phar
+  
+  [ ! -e "$php_install_dir/etc/php.d" ] && mkdir -p $php_install_dir/etc/php.d
+  /bin/cp php.ini-production $php_install_dir/etc/php.ini
+  
+  sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" $php_install_dir/etc/php.ini
+  sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' $php_install_dir/etc/php.ini
+  sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' $php_install_dir/etc/php.ini
+  sed -i 's@^short_open_tag = Off@short_open_tag = On@' $php_install_dir/etc/php.ini
+  sed -i 's@^expose_php = On@expose_php = Off@' $php_install_dir/etc/php.ini
+  sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini
+  sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini
+  sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini
+  sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini
+  sed -i 's@^max_execution_time.*@max_execution_time = 5@' $php_install_dir/etc/php.ini
+  sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini
+  [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini
+  
+  if [[ ! $Apache_version =~ ^[1-2]$ ]] && [ ! -e "$apache_install_dir/bin/apxs" ]; then
     # php-fpm Init Script
     # php-fpm Init Script
     /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
     /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
     chmod +x /etc/init.d/php-fpm
     chmod +x /etc/init.d/php-fpm
@@ -186,40 +186,40 @@ EOF
 
 
     [ -d "/run/shm" -a ! -e "/dev/shm" ] && sed -i 's@/dev/shm@/run/shm@' $php_install_dir/etc/php-fpm.conf $oneinstack_dir/vhost.sh $oneinstack_dir/config/nginx.conf
     [ -d "/run/shm" -a ! -e "/dev/shm" ] && sed -i 's@/dev/shm@/run/shm@' $php_install_dir/etc/php-fpm.conf $oneinstack_dir/vhost.sh $oneinstack_dir/config/nginx.conf
 
 
-    if [ $Mem -le 3000 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/3/30))@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/3/40))@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
-    elif [ $Mem -gt 3000 -a $Mem -le 4500 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = 50@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = 30@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 20@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
-    elif [ $Mem -gt 4500 -a $Mem -le 6500 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = 60@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = 40@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 30@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 60@" $php_install_dir/etc/php-fpm.conf
-    elif [ $Mem -gt 6500 -a $Mem -le 8500 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = 70@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = 50@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 40@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 70@" $php_install_dir/etc/php-fpm.conf
-    elif [ $Mem -gt 8500 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = 80@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = 60@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 80@" $php_install_dir/etc/php-fpm.conf
+    if [ $Mem -le 3000 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/3/30))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/3/40))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 3000 -a $Mem -le 4500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 30@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 20@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 4500 -a $Mem -le 6500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 60@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 40@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 30@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 60@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 6500 -a $Mem -le 8500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 70@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 40@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 70@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 8500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 80@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 60@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 80@" $php_install_dir/etc/php-fpm.conf
     fi
     fi
 
 
     #[ "$Web_yn" == 'n' ] && sed -i "s@^listen =.*@listen = $IPADDR:9000@" $php_install_dir/etc/php-fpm.conf
     #[ "$Web_yn" == 'n' ] && sed -i "s@^listen =.*@listen = $IPADDR:9000@" $php_install_dir/etc/php-fpm.conf
     service php-fpm start
     service php-fpm start
 
 
-elif [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ];then
+  elif [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ]; then
     service httpd restart
     service httpd restart
-fi
-cd ..
-[ -e "$php_install_dir/bin/phpize" ] && rm -rf php-$php_4_version
-cd ..
+  fi
+  popd
+  [ -e "$php_install_dir/bin/phpize" ] && rm -rf php-$php_4_version
+  popd
 }
 }

+ 137 - 138
include/php-5.5.sh

@@ -9,119 +9,118 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_PHP-5-5() {
 Install_PHP-5-5() {
-cd $oneinstack_dir/src
-
-tar xzf libiconv-$libiconv_version.tar.gz
-patch -d libiconv-$libiconv_version -p0 < libiconv-glibc-2.16.patch
-cd libiconv-$libiconv_version
-./configure --prefix=/usr/local
-make -j ${THREAD} && make install
-cd ..
-rm -rf libiconv-$libiconv_version
-
-tar xzf curl-$curl_version.tar.gz
-cd curl-$curl_version
-./configure --prefix=/usr/local
-make -j ${THREAD} && make install
-cd ..
-rm -rf curl-$curl_version
-
-tar xzf libmcrypt-$libmcrypt_version.tar.gz
-cd libmcrypt-$libmcrypt_version
-./configure
-make -j ${THREAD} && make install
-ldconfig
-cd libltdl
-./configure --enable-ltdl-install
-make -j ${THREAD} && make install
-cd ../../
-rm -rf libmcrypt-$libmcrypt_version
-
-tar xzf mhash-$mhash_version.tar.gz
-cd mhash-$mhash_version
-./configure
-make -j ${THREAD} && make install
-cd ..
-rm -rf mhash-$mhash_version
-
-echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
-ldconfig
-[ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; }
-
-tar xzf mcrypt-$mcrypt_version.tar.gz
-cd mcrypt-$mcrypt_version
-ldconfig
-./configure
-make -j ${THREAD} && make install
-cd ..
-rm -rf mcrypt-$mcrypt_version
-
-id -u $run_user >/dev/null 2>&1
-[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
-tar xzf php-$php_5_version.tar.gz
-patch -d php-$php_5_version -p0 < fpm-race-condition.patch
-cd php-$php_5_version
-make clean
-[ ! -d "$php_install_dir" ] && mkdir -p $php_install_dir
-[ "$PHP_cache" == '1' ] && PHP_cache_tmp='--enable-opcache' || PHP_cache_tmp='--disable-opcache'
-if [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ];then
+  pushd ${oneinstack_dir}/src
+  
+  tar xzf libiconv-$libiconv_version.tar.gz
+  patch -d libiconv-$libiconv_version -p0 < libiconv-glibc-2.16.patch
+  pushd libiconv-$libiconv_version
+  ./configure --prefix=/usr/local
+  make -j ${THREAD} && make install
+  popd
+  rm -rf libiconv-$libiconv_version
+  
+  tar xzf curl-$curl_version.tar.gz
+  pushd curl-$curl_version
+  ./configure --prefix=/usr/local
+  make -j ${THREAD} && make install
+  popd
+  rm -rf curl-$curl_version
+  
+  tar xzf libmcrypt-$libmcrypt_version.tar.gz
+  pushd libmcrypt-$libmcrypt_version
+  ./configure
+  make -j ${THREAD} && make install
+  ldconfig
+  pushd libltdl
+  ./configure --enable-ltdl-install
+  make -j ${THREAD} && make install
+  popd;popd
+  rm -rf libmcrypt-$libmcrypt_version
+  
+  tar xzf mhash-$mhash_version.tar.gz
+  pushd mhash-$mhash_version
+  ./configure
+  make -j ${THREAD} && make install
+  popd
+  rm -rf mhash-$mhash_version
+  
+  echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
+  ldconfig
+  [ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; }
+  
+  tar xzf mcrypt-$mcrypt_version.tar.gz
+  pushd mcrypt-$mcrypt_version
+  ldconfig
+  ./configure
+  make -j ${THREAD} && make install
+  popd
+  rm -rf mcrypt-$mcrypt_version
+  
+  id -u $run_user >/dev/null 2>&1
+  [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
+  tar xzf php-$php_5_version.tar.gz
+  patch -d php-$php_5_version -p0 < fpm-race-condition.patch
+  pushd php-$php_5_version
+  [ ! -d "$php_install_dir" ] && mkdir -p $php_install_dir
+  [ "$PHP_cache" == '1' ] && PHP_cache_tmp='--enable-opcache' || PHP_cache_tmp='--disable-opcache'
+  if [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ]; then
     ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
     ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
---with-config-file-scan-dir=$php_install_dir/etc/php.d \
---with-apxs2=$apache_install_dir/bin/apxs $PHP_cache_tmp --disable-fileinfo \
---with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
---with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
---with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
---enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
---enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
---with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
---with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
-else
+    --with-config-file-scan-dir=$php_install_dir/etc/php.d \
+    --with-apxs2=$apache_install_dir/bin/apxs $PHP_cache_tmp --disable-fileinfo \
+    --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
+    --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
+    --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
+    --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
+    --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
+    --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
+    --with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+  else
     ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
     ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
---with-config-file-scan-dir=$php_install_dir/etc/php.d \
---with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm $PHP_cache_tmp --disable-fileinfo \
---with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
---with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
---with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
---enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
---enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
---with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
---with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
-fi
-make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD}
-make install
-
-if [ -e "$php_install_dir/bin/phpize" ];then
+    --with-config-file-scan-dir=$php_install_dir/etc/php.d \
+    --with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm $PHP_cache_tmp --disable-fileinfo \
+    --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
+    --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
+    --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
+    --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
+    --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
+    --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
+    --with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+  fi
+  make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD}
+  make install
+  
+  if [ -e "$php_install_dir/bin/phpize" ]; then
     echo "${CSUCCESS}PHP installed successfully! ${CEND}"
     echo "${CSUCCESS}PHP installed successfully! ${CEND}"
-else
+  else
     rm -rf $php_install_dir
     rm -rf $php_install_dir
     echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}"
     echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}"
     kill -9 $$
     kill -9 $$
-fi
-
-[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$php_install_dir/bin:\$PATH" >> /etc/profile
-[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $php_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$php_install_dir/bin:\1@" /etc/profile
-. /etc/profile
-
-# wget -c http://pear.php.net/go-pear.phar
-# $php_install_dir/bin/php go-pear.phar
-
-[ ! -e "$php_install_dir/etc/php.d" ] && mkdir -p $php_install_dir/etc/php.d
-/bin/cp php.ini-production $php_install_dir/etc/php.ini
-
-sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" $php_install_dir/etc/php.ini
-sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' $php_install_dir/etc/php.ini
-sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' $php_install_dir/etc/php.ini
-sed -i 's@^short_open_tag = Off@short_open_tag = On@' $php_install_dir/etc/php.ini
-sed -i 's@^expose_php = On@expose_php = Off@' $php_install_dir/etc/php.ini
-sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini
-sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini
-sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini
-sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini
-sed -i 's@^max_execution_time.*@max_execution_time = 5@' $php_install_dir/etc/php.ini
-sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini
-[ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini
-
-[ "$PHP_cache" == '1' ] && cat > $php_install_dir/etc/php.d/ext-opcache.ini << EOF
+  fi
+  
+  [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$php_install_dir/bin:\$PATH" >> /etc/profile
+  [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $php_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$php_install_dir/bin:\1@" /etc/profile
+  . /etc/profile
+  
+  # wget -c http://pear.php.net/go-pear.phar
+  # $php_install_dir/bin/php go-pear.phar
+  
+  [ ! -e "$php_install_dir/etc/php.d" ] && mkdir -p $php_install_dir/etc/php.d
+  /bin/cp php.ini-production $php_install_dir/etc/php.ini
+  
+  sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" $php_install_dir/etc/php.ini
+  sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' $php_install_dir/etc/php.ini
+  sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' $php_install_dir/etc/php.ini
+  sed -i 's@^short_open_tag = Off@short_open_tag = On@' $php_install_dir/etc/php.ini
+  sed -i 's@^expose_php = On@expose_php = Off@' $php_install_dir/etc/php.ini
+  sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini
+  sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini
+  sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini
+  sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini
+  sed -i 's@^max_execution_time.*@max_execution_time = 5@' $php_install_dir/etc/php.ini
+  sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini
+  [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini
+  
+  [ "$PHP_cache" == '1' ] && cat > $php_install_dir/etc/php.d/ext-opcache.ini << EOF
 [opcache]
 [opcache]
 zend_extension=opcache.so
 zend_extension=opcache.so
 opcache.enable=1
 opcache.enable=1
@@ -135,7 +134,7 @@ opcache.enable_cli=1
 ;opcache.optimization_level=0
 ;opcache.optimization_level=0
 EOF
 EOF
 
 
-if [[ ! $Apache_version =~ ^[1-2]$ ]] && [ ! -e "$apache_install_dir/bin/apxs" ];then
+  if [[ ! $Apache_version =~ ^[1-2]$ ]] && [ ! -e "$apache_install_dir/bin/apxs" ]; then
     # php-fpm Init Script
     # php-fpm Init Script
     /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
     /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
     chmod +x /etc/init.d/php-fpm
     chmod +x /etc/init.d/php-fpm
@@ -200,40 +199,40 @@ EOF
 
 
     [ -d "/run/shm" -a ! -e "/dev/shm" ] && sed -i 's@/dev/shm@/run/shm@' $php_install_dir/etc/php-fpm.conf $oneinstack_dir/vhost.sh $oneinstack_dir/config/nginx.conf
     [ -d "/run/shm" -a ! -e "/dev/shm" ] && sed -i 's@/dev/shm@/run/shm@' $php_install_dir/etc/php-fpm.conf $oneinstack_dir/vhost.sh $oneinstack_dir/config/nginx.conf
 
 
-    if [ $Mem -le 3000 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/3/30))@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/3/40))@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
-    elif [ $Mem -gt 3000 -a $Mem -le 4500 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = 50@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = 30@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 20@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
-    elif [ $Mem -gt 4500 -a $Mem -le 6500 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = 60@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = 40@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 30@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 60@" $php_install_dir/etc/php-fpm.conf
-    elif [ $Mem -gt 6500 -a $Mem -le 8500 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = 70@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = 50@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 40@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 70@" $php_install_dir/etc/php-fpm.conf
-    elif [ $Mem -gt 8500 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = 80@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = 60@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 80@" $php_install_dir/etc/php-fpm.conf
+    if [ $Mem -le 3000 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/3/30))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/3/40))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 3000 -a $Mem -le 4500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 30@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 20@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 4500 -a $Mem -le 6500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 60@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 40@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 30@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 60@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 6500 -a $Mem -le 8500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 70@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 40@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 70@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 8500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 80@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 60@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 80@" $php_install_dir/etc/php-fpm.conf
     fi
     fi
 
 
     #[ "$Web_yn" == 'n' ] && sed -i "s@^listen =.*@listen = $IPADDR:9000@" $php_install_dir/etc/php-fpm.conf
     #[ "$Web_yn" == 'n' ] && sed -i "s@^listen =.*@listen = $IPADDR:9000@" $php_install_dir/etc/php-fpm.conf
     service php-fpm start
     service php-fpm start
 
 
-elif [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ];then
+  elif [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ]; then
     service httpd restart
     service httpd restart
-fi
-cd ..
-[ -e "$php_install_dir/bin/phpize" ] && rm -rf php-$php_5_version
-cd ..
+  fi
+  popd
+  [ -e "$php_install_dir/bin/phpize" ] && rm -rf php-$php_5_version
+  popd
 }
 }

+ 138 - 138
include/php-5.6.sh

@@ -9,119 +9,119 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_PHP-5-6() {
 Install_PHP-5-6() {
-cd $oneinstack_dir/src
-
-tar xzf libiconv-$libiconv_version.tar.gz
-patch -d libiconv-$libiconv_version -p0 < libiconv-glibc-2.16.patch
-cd libiconv-$libiconv_version
-./configure --prefix=/usr/local
-make -j ${THREAD} && make install
-cd ..
-rm -rf libiconv-$libiconv_version
-
-tar xzf curl-$curl_version.tar.gz
-cd curl-$curl_version
-./configure --prefix=/usr/local
-make -j ${THREAD} && make install
-cd ..
-rm -rf curl-$curl_version
-
-tar xzf libmcrypt-$libmcrypt_version.tar.gz
-cd libmcrypt-$libmcrypt_version
-./configure
-make -j ${THREAD} && make install
-ldconfig
-cd libltdl
-./configure --enable-ltdl-install
-make -j ${THREAD} && make install
-cd ../../
-rm -rf libmcrypt-$libmcrypt_version
-
-tar xzf mhash-$mhash_version.tar.gz
-cd mhash-$mhash_version
-./configure
-make -j ${THREAD} && make install
-cd ..
-rm -rf mhash-$mhash_version
-
-echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
-ldconfig
-[ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; }
-
-tar xzf mcrypt-$mcrypt_version.tar.gz
-cd mcrypt-$mcrypt_version
-ldconfig
-./configure
-make -j ${THREAD} && make install
-cd ..
-rm -rf mcrypt-$mcrypt_version
-
-id -u $run_user >/dev/null 2>&1
-[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
-
-tar xzf php-$php_6_version.tar.gz
-cd php-$php_6_version
-make clean
-[ ! -d "$php_install_dir" ] && mkdir -p $php_install_dir
-[ "$PHP_cache" == '1' ] && PHP_cache_tmp='--enable-opcache' || PHP_cache_tmp='--disable-opcache'
-if [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ];then
+  pushd ${oneinstack_dir}/src
+  
+  tar xzf libiconv-$libiconv_version.tar.gz
+  patch -d libiconv-$libiconv_version -p0 < libiconv-glibc-2.16.patch
+  pushd libiconv-$libiconv_version
+  ./configure --prefix=/usr/local
+  make -j ${THREAD} && make install
+  popd
+  rm -rf libiconv-$libiconv_version
+  
+  tar xzf curl-$curl_version.tar.gz
+  pushd curl-$curl_version
+  ./configure --prefix=/usr/local
+  make -j ${THREAD} && make install
+  popd
+  rm -rf curl-$curl_version
+  
+  tar xzf libmcrypt-$libmcrypt_version.tar.gz
+  pushd libmcrypt-$libmcrypt_version
+  ./configure
+  make -j ${THREAD} && make install
+  ldconfig
+  pushd libltdl
+  ./configure --enable-ltdl-install
+  make -j ${THREAD} && make install
+  popd;popd
+  rm -rf libmcrypt-$libmcrypt_version
+  
+  tar xzf mhash-$mhash_version.tar.gz
+  pushd mhash-$mhash_version
+  ./configure
+  make -j ${THREAD} && make install
+  popd
+  rm -rf mhash-$mhash_version
+  
+  echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
+  ldconfig
+  [ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; }
+  
+  tar xzf mcrypt-$mcrypt_version.tar.gz
+  pushd mcrypt-$mcrypt_version
+  ldconfig
+  ./configure
+  make -j ${THREAD} && make install
+  popd
+  rm -rf mcrypt-$mcrypt_version
+  
+  id -u $run_user >/dev/null 2>&1
+  [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
+  
+  tar xzf php-$php_6_version.tar.gz
+  pushd php-$php_6_version
+  make clean
+  [ ! -d "$php_install_dir" ] && mkdir -p $php_install_dir
+  [ "$PHP_cache" == '1' ] && PHP_cache_tmp='--enable-opcache' || PHP_cache_tmp='--disable-opcache'
+  if [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ]; then
     ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
     ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
---with-config-file-scan-dir=$php_install_dir/etc/php.d \
---with-apxs2=$apache_install_dir/bin/apxs $PHP_cache_tmp --disable-fileinfo \
---with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
---with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
---with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
---enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
---enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
---with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
---with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
-else
+    --with-config-file-scan-dir=$php_install_dir/etc/php.d \
+    --with-apxs2=$apache_install_dir/bin/apxs $PHP_cache_tmp --disable-fileinfo \
+    --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
+    --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
+    --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
+    --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
+    --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
+    --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
+    --with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+  else
     ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
     ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
---with-config-file-scan-dir=$php_install_dir/etc/php.d \
---with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm $PHP_cache_tmp --disable-fileinfo \
---with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
---with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
---with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
---enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
---enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
---with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
---with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
-fi
-make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD}
-make install
-
-if [ -e "$php_install_dir/bin/phpize" ];then
+    --with-config-file-scan-dir=$php_install_dir/etc/php.d \
+    --with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm $PHP_cache_tmp --disable-fileinfo \
+    --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
+    --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
+    --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
+    --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
+    --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
+    --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
+    --with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+  fi
+  make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD}
+  make install
+  
+  if [ -e "$php_install_dir/bin/phpize" ]; then
     echo "${CSUCCESS}PHP installed successfully! ${CEND}"
     echo "${CSUCCESS}PHP installed successfully! ${CEND}"
-else
+  else
     rm -rf $php_install_dir
     rm -rf $php_install_dir
     echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}"
     echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}"
     kill -9 $$
     kill -9 $$
-fi
-
-[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$php_install_dir/bin:\$PATH" >> /etc/profile
-[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $php_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$php_install_dir/bin:\1@" /etc/profile
-. /etc/profile
-
-# wget -c http://pear.php.net/go-pear.phar
-# $php_install_dir/bin/php go-pear.phar
-
-[ ! -e "$php_install_dir/etc/php.d" ] && mkdir -p $php_install_dir/etc/php.d
-/bin/cp php.ini-production $php_install_dir/etc/php.ini
-
-sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" $php_install_dir/etc/php.ini
-sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' $php_install_dir/etc/php.ini
-sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' $php_install_dir/etc/php.ini
-sed -i 's@^short_open_tag = Off@short_open_tag = On@' $php_install_dir/etc/php.ini
-sed -i 's@^expose_php = On@expose_php = Off@' $php_install_dir/etc/php.ini
-sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini
-sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini
-sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini
-sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini
-sed -i 's@^max_execution_time.*@max_execution_time = 5@' $php_install_dir/etc/php.ini
-sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini
-[ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini
-
-[ "$PHP_cache" == '1' ] && cat > $php_install_dir/etc/php.d/ext-opcache.ini << EOF
+  fi
+
+  [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$php_install_dir/bin:\$PATH" >> /etc/profile
+  [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $php_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$php_install_dir/bin:\1@" /etc/profile
+  . /etc/profile
+  
+  # wget -c http://pear.php.net/go-pear.phar
+  # $php_install_dir/bin/php go-pear.phar
+  
+  [ ! -e "$php_install_dir/etc/php.d" ] && mkdir -p $php_install_dir/etc/php.d
+  /bin/cp php.ini-production $php_install_dir/etc/php.ini
+  
+  sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" $php_install_dir/etc/php.ini
+  sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' $php_install_dir/etc/php.ini
+  sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' $php_install_dir/etc/php.ini
+  sed -i 's@^short_open_tag = Off@short_open_tag = On@' $php_install_dir/etc/php.ini
+  sed -i 's@^expose_php = On@expose_php = Off@' $php_install_dir/etc/php.ini
+  sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini
+  sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini
+  sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini
+  sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini
+  sed -i 's@^max_execution_time.*@max_execution_time = 5@' $php_install_dir/etc/php.ini
+  sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini
+  [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini
+  
+  [ "$PHP_cache" == '1' ] && cat > $php_install_dir/etc/php.d/ext-opcache.ini << EOF
 [opcache]
 [opcache]
 zend_extension=opcache.so
 zend_extension=opcache.so
 opcache.enable=1
 opcache.enable=1
@@ -135,7 +135,7 @@ opcache.enable_cli=1
 ;opcache.optimization_level=0
 ;opcache.optimization_level=0
 EOF
 EOF
 
 
-if [[ ! $Apache_version =~ ^[1-2]$ ]] && [ ! -e "$apache_install_dir/bin/apxs" ];then
+  if [[ ! $Apache_version =~ ^[1-2]$ ]] && [ ! -e "$apache_install_dir/bin/apxs" ]; then
     # php-fpm Init Script
     # php-fpm Init Script
     /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
     /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
     chmod +x /etc/init.d/php-fpm
     chmod +x /etc/init.d/php-fpm
@@ -200,40 +200,40 @@ EOF
 
 
     [ -d "/run/shm" -a ! -e "/dev/shm" ] && sed -i 's@/dev/shm@/run/shm@' $php_install_dir/etc/php-fpm.conf $oneinstack_dir/vhost.sh $oneinstack_dir/config/nginx.conf
     [ -d "/run/shm" -a ! -e "/dev/shm" ] && sed -i 's@/dev/shm@/run/shm@' $php_install_dir/etc/php-fpm.conf $oneinstack_dir/vhost.sh $oneinstack_dir/config/nginx.conf
 
 
-    if [ $Mem -le 3000 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/3/30))@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/3/40))@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
-    elif [ $Mem -gt 3000 -a $Mem -le 4500 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = 50@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = 30@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 20@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
-    elif [ $Mem -gt 4500 -a $Mem -le 6500 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = 60@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = 40@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 30@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 60@" $php_install_dir/etc/php-fpm.conf
-    elif [ $Mem -gt 6500 -a $Mem -le 8500 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = 70@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = 50@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 40@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 70@" $php_install_dir/etc/php-fpm.conf
-    elif [ $Mem -gt 8500 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = 80@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = 60@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 80@" $php_install_dir/etc/php-fpm.conf
+    if [ $Mem -le 3000 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/3/30))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/3/40))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 3000 -a $Mem -le 4500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 30@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 20@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 4500 -a $Mem -le 6500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 60@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 40@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 30@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 60@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 6500 -a $Mem -le 8500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 70@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 40@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 70@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 8500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 80@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 60@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 80@" $php_install_dir/etc/php-fpm.conf
     fi
     fi
 
 
     #[ "$Web_yn" == 'n' ] && sed -i "s@^listen =.*@listen = $IPADDR:9000@" $php_install_dir/etc/php-fpm.conf
     #[ "$Web_yn" == 'n' ] && sed -i "s@^listen =.*@listen = $IPADDR:9000@" $php_install_dir/etc/php-fpm.conf
     service php-fpm start
     service php-fpm start
 
 
-elif [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ];then
+  elif [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ]; then
     service httpd restart
     service httpd restart
-fi
-cd ..
-[ -e "$php_install_dir/bin/phpize" ] && rm -rf php-$php_6_version
-cd ..
+  fi
+  popd
+  [ -e "$php_install_dir/bin/phpize" ] && rm -rf php-$php_6_version
+  popd
 }
 }

+ 140 - 140
include/php-7.0.sh

@@ -9,121 +9,121 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_PHP-7-0() {
 Install_PHP-7-0() {
-cd $oneinstack_dir/src
-
-tar xzf libiconv-$libiconv_version.tar.gz
-patch -d libiconv-$libiconv_version -p0 < libiconv-glibc-2.16.patch
-cd libiconv-$libiconv_version
-./configure --prefix=/usr/local
-make -j ${THREAD} && make install
-cd ..
-rm -rf libiconv-$libiconv_version
-
-tar xzf curl-$curl_version.tar.gz
-cd curl-$curl_version
-./configure --prefix=/usr/local
-make -j ${THREAD} && make install
-cd ..
-rm -rf curl-$curl_version
-
-tar xzf libmcrypt-$libmcrypt_version.tar.gz
-cd libmcrypt-$libmcrypt_version
-./configure
-make -j ${THREAD} && make install
-ldconfig
-cd libltdl
-./configure --enable-ltdl-install
-make -j ${THREAD} && make install
-cd ../../
-rm -rf libmcrypt-$libmcrypt_version
-
-tar xzf mhash-$mhash_version.tar.gz
-cd mhash-$mhash_version
-./configure
-make -j ${THREAD} && make install
-cd ..
-rm -rf mhash-$mhash_version
-
-echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
-ldconfig
-[ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; }
-
-tar xzf mcrypt-$mcrypt_version.tar.gz
-cd mcrypt-$mcrypt_version
-ldconfig
-./configure
-make -j ${THREAD} && make install
-cd ..
-rm -rf mcrypt-$mcrypt_version
-
-id -u $run_user >/dev/null 2>&1
-[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
-
-tar xzf php-$php_7_version.tar.gz
-cd php-$php_7_version
-make clean
-./buildconf
-[ ! -d "$php_install_dir" ] && mkdir -p $php_install_dir
-[ "$PHP_cache" == '1' ] && PHP_cache_tmp='--enable-opcache' || PHP_cache_tmp='--disable-opcache'
-if [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ];then
+  pushd ${oneinstack_dir}/src
+  
+  tar xzf libiconv-$libiconv_version.tar.gz
+  patch -d libiconv-$libiconv_version -p0 < libiconv-glibc-2.16.patch
+  pushd libiconv-$libiconv_version
+  ./configure --prefix=/usr/local
+  make -j ${THREAD} && make install
+  popd
+  rm -rf libiconv-$libiconv_version
+  
+  tar xzf curl-$curl_version.tar.gz
+  pushd curl-$curl_version
+  ./configure --prefix=/usr/local
+  make -j ${THREAD} && make install
+  popd
+  rm -rf curl-$curl_version
+  
+  tar xzf libmcrypt-$libmcrypt_version.tar.gz
+  pushd libmcrypt-$libmcrypt_version
+  ./configure
+  make -j ${THREAD} && make install
+  ldconfig
+  pushd libltdl
+  ./configure --enable-ltdl-install
+  make -j ${THREAD} && make install
+  popd;popd
+  rm -rf libmcrypt-$libmcrypt_version
+  
+  tar xzf mhash-$mhash_version.tar.gz
+  pushd mhash-$mhash_version
+  ./configure
+  make -j ${THREAD} && make install
+  popd
+  rm -rf mhash-$mhash_version
+  
+  echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
+  ldconfig
+  [ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; }
+  
+  tar xzf mcrypt-$mcrypt_version.tar.gz
+  pushd mcrypt-$mcrypt_version
+  ldconfig
+  ./configure
+  make -j ${THREAD} && make install
+  popd
+  rm -rf mcrypt-$mcrypt_version
+  
+  id -u $run_user >/dev/null 2>&1
+  [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
+  
+  tar xzf php-$php_7_version.tar.gz
+  pushd php-$php_7_version
+  make clean
+  ./buildconf
+  [ ! -d "$php_install_dir" ] && mkdir -p $php_install_dir
+  [ "$PHP_cache" == '1' ] && PHP_cache_tmp='--enable-opcache' || PHP_cache_tmp='--disable-opcache'
+  if [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ]; then
     ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
     ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
---with-config-file-scan-dir=$php_install_dir/etc/php.d \
---with-apxs2=$apache_install_dir/bin/apxs $PHP_cache_tmp --disable-fileinfo \
---enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
---with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
---with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
---enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
---enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
---with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
---with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
-else
+    --with-config-file-scan-dir=$php_install_dir/etc/php.d \
+    --with-apxs2=$apache_install_dir/bin/apxs $PHP_cache_tmp --disable-fileinfo \
+    --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
+    --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
+    --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
+    --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
+    --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
+    --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
+    --with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+  else
     ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
     ./configure --prefix=$php_install_dir --with-config-file-path=$php_install_dir/etc \
---with-config-file-scan-dir=$php_install_dir/etc/php.d \
---with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm $PHP_cache_tmp --disable-fileinfo \
---enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
---with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
---with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
---enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
---enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
---with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
---with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
-fi
-make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD}
-make install
-
-if [ -e "$php_install_dir/bin/phpize" ];then
+    --with-config-file-scan-dir=$php_install_dir/etc/php.d \
+    --with-fpm-user=$run_user --with-fpm-group=$run_user --enable-fpm $PHP_cache_tmp --disable-fileinfo \
+    --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd \
+    --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib \
+    --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-exif \
+    --enable-sysvsem --enable-inline-optimization --with-curl=/usr/local --enable-mbregex \
+    --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl \
+    --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-ftp --enable-intl --with-xsl \
+    --with-gettext --enable-zip --enable-soap --disable-ipv6 --disable-debug
+  fi
+  make ZEND_EXTRA_LIBS='-liconv' -j ${THREAD}
+  make install
+  
+  if [ -e "$php_install_dir/bin/phpize" ]; then
     echo "${CSUCCESS}PHP installed successfully! ${CEND}"
     echo "${CSUCCESS}PHP installed successfully! ${CEND}"
-else
+  else
     rm -rf $php_install_dir
     rm -rf $php_install_dir
     echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}"
     echo "${CFAILURE}PHP install failed, Please Contact the author! ${CEND}"
     kill -9 $$
     kill -9 $$
-fi
-
-[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$php_install_dir/bin:\$PATH" >> /etc/profile
-[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $php_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$php_install_dir/bin:\1@" /etc/profile
-. /etc/profile
-
-# wget -c http://pear.php.net/go-pear.phar
-# $php_install_dir/bin/php go-pear.phar
-
-[ ! -e "$php_install_dir/etc/php.d" ] && mkdir -p $php_install_dir/etc/php.d
-/bin/cp php.ini-production $php_install_dir/etc/php.ini
-
-sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" $php_install_dir/etc/php.ini
-sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' $php_install_dir/etc/php.ini
-sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' $php_install_dir/etc/php.ini
-sed -i 's@^short_open_tag = Off@short_open_tag = On@' $php_install_dir/etc/php.ini
-sed -i 's@^expose_php = On@expose_php = Off@' $php_install_dir/etc/php.ini
-sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini
-sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini
-sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini
-sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini
-sed -i 's@^max_execution_time.*@max_execution_time = 600@' $php_install_dir/etc/php.ini
-sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' $php_install_dir/etc/php.ini
-sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini
-[ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini
-
-[ "$PHP_cache" == '1' ] && cat > $php_install_dir/etc/php.d/ext-opcache.ini << EOF
+  fi
+  
+  [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$php_install_dir/bin:\$PATH" >> /etc/profile
+  [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $php_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$php_install_dir/bin:\1@" /etc/profile
+  . /etc/profile
+  
+  # wget -c http://pear.php.net/go-pear.phar
+  # $php_install_dir/bin/php go-pear.phar
+  
+  [ ! -e "$php_install_dir/etc/php.d" ] && mkdir -p $php_install_dir/etc/php.d
+  /bin/cp php.ini-production $php_install_dir/etc/php.ini
+  
+  sed -i "s@^memory_limit.*@memory_limit = ${Memory_limit}M@" $php_install_dir/etc/php.ini
+  sed -i 's@^output_buffering =@output_buffering = On\noutput_buffering =@' $php_install_dir/etc/php.ini
+  sed -i 's@^;cgi.fix_pathinfo.*@cgi.fix_pathinfo=0@' $php_install_dir/etc/php.ini
+  sed -i 's@^short_open_tag = Off@short_open_tag = On@' $php_install_dir/etc/php.ini
+  sed -i 's@^expose_php = On@expose_php = Off@' $php_install_dir/etc/php.ini
+  sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini
+  sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini
+  sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini
+  sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini
+  sed -i 's@^max_execution_time.*@max_execution_time = 600@' $php_install_dir/etc/php.ini
+  sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' $php_install_dir/etc/php.ini
+  sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini
+  [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini
+  
+  [ "$PHP_cache" == '1' ] && cat > $php_install_dir/etc/php.d/ext-opcache.ini << EOF
 [opcache]
 [opcache]
 zend_extension=opcache.so
 zend_extension=opcache.so
 opcache.enable=1
 opcache.enable=1
@@ -141,7 +141,7 @@ opcache.consistency_checks=0
 ;opcache.optimization_level=0
 ;opcache.optimization_level=0
 EOF
 EOF
 
 
-if [[ ! $Apache_version =~ ^[1-2]$ ]] && [ ! -e "$apache_install_dir/bin/apxs" ];then
+  if [[ ! $Apache_version =~ ^[1-2]$ ]] && [ ! -e "$apache_install_dir/bin/apxs" ]; then
     # php-fpm Init Script
     # php-fpm Init Script
     /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
     /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
     chmod +x /etc/init.d/php-fpm
     chmod +x /etc/init.d/php-fpm
@@ -206,40 +206,40 @@ EOF
 
 
     [ -d "/run/shm" -a ! -e "/dev/shm" ] && sed -i 's@/dev/shm@/run/shm@' $php_install_dir/etc/php-fpm.conf $oneinstack_dir/vhost.sh $oneinstack_dir/config/nginx.conf
     [ -d "/run/shm" -a ! -e "/dev/shm" ] && sed -i 's@/dev/shm@/run/shm@' $php_install_dir/etc/php-fpm.conf $oneinstack_dir/vhost.sh $oneinstack_dir/config/nginx.conf
 
 
-    if [ $Mem -le 3000 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/3/30))@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/3/40))@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
-    elif [ $Mem -gt 3000 -a $Mem -le 4500 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = 50@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = 30@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 20@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
-    elif [ $Mem -gt 4500 -a $Mem -le 6500 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = 60@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = 40@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 30@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 60@" $php_install_dir/etc/php-fpm.conf
-    elif [ $Mem -gt 6500 -a $Mem -le 8500 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = 70@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = 50@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 40@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 70@" $php_install_dir/etc/php-fpm.conf
-    elif [ $Mem -gt 8500 ];then
-        sed -i "s@^pm.max_children.*@pm.max_children = 80@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.start_servers.*@pm.start_servers = 60@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
-        sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 80@" $php_install_dir/etc/php-fpm.conf
+    if [ $Mem -le 3000 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = $(($Mem/3/30))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = $(($Mem/3/40))@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = $(($Mem/3/20))@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 3000 -a $Mem -le 4500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 30@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 20@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 4500 -a $Mem -le 6500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 60@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 40@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 30@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 60@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 6500 -a $Mem -le 8500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 70@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 40@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 70@" $php_install_dir/etc/php-fpm.conf
+    elif [ $Mem -gt 8500 ]; then
+      sed -i "s@^pm.max_children.*@pm.max_children = 80@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.start_servers.*@pm.start_servers = 60@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.min_spare_servers.*@pm.min_spare_servers = 50@" $php_install_dir/etc/php-fpm.conf
+      sed -i "s@^pm.max_spare_servers.*@pm.max_spare_servers = 80@" $php_install_dir/etc/php-fpm.conf
     fi
     fi
 
 
     #[ "$Web_yn" == 'n' ] && sed -i "s@^listen =.*@listen = $IPADDR:9000@" $php_install_dir/etc/php-fpm.conf
     #[ "$Web_yn" == 'n' ] && sed -i "s@^listen =.*@listen = $IPADDR:9000@" $php_install_dir/etc/php-fpm.conf
     service php-fpm start
     service php-fpm start
 
 
-elif [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ];then
+  elif [[ $Apache_version =~ ^[1-2]$ ]] || [ -e "$apache_install_dir/bin/apxs" ]; then
     service httpd restart
     service httpd restart
-fi
-cd ..
-[ -e "$php_install_dir/bin/phpize" ] && rm -rf php-$php_7_version
-cd ..
+  fi
+  popd
+  [ -e "$php_install_dir/bin/phpize" ] && rm -rf php-$php_7_version
+  popd
 }
 }

+ 10 - 10
include/phpmyadmin.sh

@@ -9,14 +9,14 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_phpMyAdmin() {
 Install_phpMyAdmin() {
-    pushd $oneinstack_dir/src
-    tar xzf phpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz
-    /bin/mv phpMyAdmin-${phpMyAdmin_version}-all-languages $wwwroot_dir/default/phpMyAdmin
-    /bin/cp $wwwroot_dir/default/phpMyAdmin/{config.sample.inc.php,config.inc.php}
-    mkdir $wwwroot_dir/default/phpMyAdmin/{upload,save}
-    sed -i "s@UploadDir.*@UploadDir'\] = 'upload';@" $wwwroot_dir/default/phpMyAdmin/config.inc.php
-    sed -i "s@SaveDir.*@SaveDir'\] = 'save';@" $wwwroot_dir/default/phpMyAdmin/config.inc.php
-    sed -i "s@blowfish_secret.*;@blowfish_secret\'\] = \'`cat /dev/urandom | head -1 | md5sum | head -c 10`\';@" $wwwroot_dir/default/phpMyAdmin/config.inc.php
-    chown -R ${run_user}.$run_user $wwwroot_dir/default/phpMyAdmin
-    popd
+  pushd ${oneinstack_dir}/src
+  tar xzf phpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz
+  /bin/mv phpMyAdmin-${phpMyAdmin_version}-all-languages ${wwwroot_dir}/default/phpMyAdmin
+  /bin/cp ${wwwroot_dir}/default/phpMyAdmin/{config.sample.inc.php,config.inc.php}
+  mkdir ${wwwroot_dir}/default/phpMyAdmin/{upload,save}
+  sed -i "s@UploadDir.*@UploadDir'\] = 'upload';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php
+  sed -i "s@SaveDir.*@SaveDir'\] = 'save';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php
+  sed -i "s@blowfish_secret.*;@blowfish_secret\'\] = \'$(cat /dev/urandom | head -1 | base64 | head -c 45)\';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php
+  chown -R ${run_user}.$run_user ${wwwroot_dir}/default/phpMyAdmin
+  popd
 }
 }

+ 31 - 28
include/pureftpd.sh

@@ -9,53 +9,56 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_PureFTPd() {
 Install_PureFTPd() {
-cd $oneinstack_dir/src
-
-id -u $run_user >/dev/null 2>&1
-[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
-
-tar xzf pure-ftpd-$pureftpd_version.tar.gz
-cd pure-ftpd-$pureftpd_version
-[ ! -d "$pureftpd_install_dir" ] && mkdir -p $pureftpd_install_dir
-./configure --prefix=$pureftpd_install_dir CFLAGS=-O2 --with-puredb --with-quotas --with-cookie --with-virtualhosts --with-virtualchroot --with-diraliases --with-sysquotas --with-ratios --with-altlog --with-paranoidmsg --with-shadow --with-welcomemsg  --with-throttling --with-uploadscript --with-language=english --with-rfc2640
-make -j ${THREAD} && make install
-if [ -e "$pureftpd_install_dir/sbin/pure-ftpwho" ];then
+  pushd ${oneinstack_dir}/src
+  
+  id -u $run_user >/dev/null 2>&1
+  [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
+  
+  tar xzf pure-ftpd-$pureftpd_version.tar.gz
+  pushd pure-ftpd-$pureftpd_version
+  [ ! -d "$pureftpd_install_dir" ] && mkdir -p $pureftpd_install_dir
+  ./configure --prefix=$pureftpd_install_dir CFLAGS=-O2 --with-puredb --with-quotas --with-cookie --with-virtualhosts --with-virtualchroot --with-diraliases --with-sysquotas --with-ratios --with-altlog --with-paranoidmsg --with-shadow --with-welcomemsg  --with-throttling --with-uploadscript --with-language=english --with-rfc2640
+  make -j ${THREAD} && make install
+  if [ -e "$pureftpd_install_dir/sbin/pure-ftpwho" ]; then
     echo "${CSUCCESS}Pure-Ftp installed successfully! ${CEND}"
     echo "${CSUCCESS}Pure-Ftp installed successfully! ${CEND}"
     [ ! -e "$pureftpd_install_dir/etc" ] && mkdir $pureftpd_install_dir/etc
     [ ! -e "$pureftpd_install_dir/etc" ] && mkdir $pureftpd_install_dir/etc
     cp configuration-file/pure-config.pl $pureftpd_install_dir/sbin
     cp configuration-file/pure-config.pl $pureftpd_install_dir/sbin
     sed -i "s@/usr/local/pureftpd@$pureftpd_install_dir@" $pureftpd_install_dir/sbin/pure-config.pl
     sed -i "s@/usr/local/pureftpd@$pureftpd_install_dir@" $pureftpd_install_dir/sbin/pure-config.pl
     chmod +x $pureftpd_install_dir/sbin/pure-config.pl
     chmod +x $pureftpd_install_dir/sbin/pure-config.pl
-    cd ../../
-    /bin/cp init.d/Pureftpd-init /etc/init.d/pureftpd 
+    popd
+    /bin/cp ../init.d/Pureftpd-init /etc/init.d/pureftpd 
     sed -i "s@/usr/local/pureftpd@$pureftpd_install_dir@g" /etc/init.d/pureftpd
     sed -i "s@/usr/local/pureftpd@$pureftpd_install_dir@g" /etc/init.d/pureftpd
     chmod +x /etc/init.d/pureftpd
     chmod +x /etc/init.d/pureftpd
     [ "$OS" == 'CentOS' ] && { chkconfig --add pureftpd; chkconfig pureftpd on; }
     [ "$OS" == 'CentOS' ] && { chkconfig --add pureftpd; chkconfig pureftpd on; }
     [[ $OS =~ ^Ubuntu$|^Debian$ ]] && { sed -i 's@^. /etc/rc.d/init.d/functions@. /lib/lsb/init-functions@' /etc/init.d/pureftpd; update-rc.d pureftpd defaults; }
     [[ $OS =~ ^Ubuntu$|^Debian$ ]] && { sed -i 's@^. /etc/rc.d/init.d/functions@. /lib/lsb/init-functions@' /etc/init.d/pureftpd; update-rc.d pureftpd defaults; }
     [ "$Debian_version" == '7' ] && sed -i 's@/var/lock/subsys/@/var/lock/@g' /etc/init.d/pureftpd
     [ "$Debian_version" == '7' ] && sed -i 's@/var/lock/subsys/@/var/lock/@g' /etc/init.d/pureftpd
 
 
-    /bin/cp config/pure-ftpd.conf $pureftpd_install_dir/etc
+    /bin/cp ../config/pure-ftpd.conf $pureftpd_install_dir/etc
     sed -i "s@^PureDB.*@PureDB  $pureftpd_install_dir/etc/pureftpd.pdb@" $pureftpd_install_dir/etc/pure-ftpd.conf
     sed -i "s@^PureDB.*@PureDB  $pureftpd_install_dir/etc/pureftpd.pdb@" $pureftpd_install_dir/etc/pure-ftpd.conf
     sed -i "s@^LimitRecursion.*@LimitRecursion  65535 8@" $pureftpd_install_dir/etc/pure-ftpd.conf
     sed -i "s@^LimitRecursion.*@LimitRecursion  65535 8@" $pureftpd_install_dir/etc/pure-ftpd.conf
     ulimit -s unlimited
     ulimit -s unlimited
     service pureftpd start
     service pureftpd start
+    echo "${CSUCCESS}Pureftpd installed successfully! ${CEND}"
+    rm -rf pure-ftpd-$pureftpd_version
 
 
     # iptables Ftp
     # iptables Ftp
-    if [ "$OS" == 'CentOS' ];then
-        if [ -z "`grep '20000:30000' /etc/sysconfig/iptables`" ];then
-            iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
-            iptables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT
-            service iptables save
-        fi
-    elif [[ $OS =~ ^Ubuntu$|^Debian$ ]];then
-        if [ -z "`grep '20000:30000' /etc/iptables.up.rules`" ];then
-            iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
-            iptables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT
-            iptables-save > /etc/iptables.up.rules
-        fi
+    if [ "$OS" == 'CentOS' ]; then
+      if [ -z "`grep '20000:30000' /etc/sysconfig/iptables`" ]; then
+        iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
+        iptables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT
+        service iptables save
+      fi
+    elif [[ $OS =~ ^Ubuntu$|^Debian$ ]]; then
+      if [ -z "`grep '20000:30000' /etc/iptables.up.rules`" ]; then
+        iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
+        iptables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT
+        iptables-save > /etc/iptables.up.rules
+      fi
     fi
     fi
-else
+  else
     rm -rf $pureftpd_install_dir
     rm -rf $pureftpd_install_dir
     echo "${CFAILURE}Pure-Ftpd install failed, Please contact the author! ${CEND}"
     echo "${CFAILURE}Pure-Ftpd install failed, Please contact the author! ${CEND}"
     kill -9 $$
     kill -9 $$
-fi
+  fi
+  popd
 }
 }

+ 65 - 72
include/redis.sh

@@ -9,81 +9,74 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_redis-server() {
 Install_redis-server() {
-    pushd $oneinstack_dir/src
-    tar xzf redis-$redis_version.tar.gz
-    pushd redis-$redis_version
-    if [ "$OS_BIT" == '32' ];then
-        sed -i '1i\CFLAGS= -march=i686' src/Makefile
-        sed -i 's@^OPT=.*@OPT=-O2 -march=i686@' src/.make-settings
-    fi
-    
-    make -j ${THREAD}
-    
-    if [ -f "src/redis-server" ];then
-        mkdir -p $redis_install_dir/{bin,etc,var}
-        /bin/cp src/{redis-benchmark,redis-check-aof,redis-check-rdb,redis-cli,redis-sentinel,redis-server} $redis_install_dir/bin/
-        /bin/cp redis.conf $redis_install_dir/etc/
-        ln -s $redis_install_dir/bin/* /usr/local/bin/
-        sed -i 's@pidfile.*@pidfile /var/run/redis.pid@' $redis_install_dir/etc/redis.conf
-        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 installed successfully! ${CEND}"
-        popd
-        rm -rf redis-$redis_version
-        id -u redis >/dev/null 2>&1
-        [ $? -ne 0 ] && useradd -M -s /sbin/nologin redis
-        chown -R redis:redis $redis_install_dir/var
-        /bin/cp ../init.d/Redis-server-init /etc/init.d/redis-server
-        if [ "$OS" == 'CentOS' ];then
-            cc start-stop-daemon.c -o /sbin/start-stop-daemon
-            chkconfig --add redis-server
-            chkconfig redis-server on
-        elif [[ $OS =~ ^Ubuntu$|^Debian$ ]];then
-            update-rc.d redis-server defaults
-        fi
-        sed -i "s@/usr/local/redis@$redis_install_dir@g" /etc/init.d/redis-server
-        #[ -z "`grep 'vm.overcommit_memory' /etc/sysctl.conf`" ] && echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
-        #sysctl -p
-        service redis-server start
-    else
-        rm -rf $redis_install_dir
-        echo "${CFAILURE}Redis-server install failed, Please contact the author! ${CEND}"
-        kill -9 $$
-    fi
+  pushd ${oneinstack_dir}/src
+  tar xzf redis-${redis_version}.tar.gz
+  pushd redis-${redis_version}
+  if [ "$OS_BIT" == '32' ]; then
+    sed -i '1i\CFLAGS= -march=i686' src/Makefile
+    sed -i 's@^OPT=.*@OPT=-O2 -march=i686@' src/.make-settings
+  fi
+  make -j ${THREAD}
+  if [ -f "src/redis-server" ]; then
+    mkdir -p ${redis_install_dir}/{bin,etc,var}
+    /bin/cp src/{redis-benchmark,redis-check-aof,redis-check-rdb,redis-cli,redis-sentinel,redis-server} ${redis_install_dir}/bin/
+    /bin/cp redis.conf ${redis_install_dir}/etc/
+    ln -s ${redis_install_dir}/bin/* /usr/local/bin/
+    sed -i 's@pidfile.*@pidfile /var/run/redis.pid@' ${redis_install_dir}/etc/redis.conf
+    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 installed successfully! ${CEND}"
     popd
     popd
+    rm -rf redis-${redis_version}
+    id -u redis >/dev/null 2>&1
+    [ $? -ne 0 ] && useradd -M -s /sbin/nologin redis
+    chown -R redis:redis ${redis_install_dir}/var
+    /bin/cp ../init.d/Redis-server-init /etc/init.d/redis-server
+    if [ "$OS" == 'CentOS' ]; then
+      cc start-stop-daemon.c -o /sbin/start-stop-daemon
+      chkconfig --add redis-server
+      chkconfig redis-server on
+    elif [[ $OS =~ ^Ubuntu$|^Debian$ ]]; then
+      update-rc.d redis-server defaults
+    fi
+    sed -i "s@/usr/local/redis@${redis_install_dir}@g" /etc/init.d/redis-server
+    #[ -z "`grep 'vm.overcommit_memory' /etc/sysctl.conf`" ] && echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
+    #sysctl -p
+    service redis-server start
+  else
+    rm -rf ${redis_install_dir}
+    echo "${CFAILURE}Redis-server install failed, Please contact the author! ${CEND}"
+    kill -9 $$
+  fi
+  popd
 }
 }
 
 
 Install_php-redis() {
 Install_php-redis() {
-    pushd $oneinstack_dir/src
-    phpExtensionDir=`$php_install_dir/bin/php-config --extension-dir`
-    if [ -e "$php_install_dir/bin/phpize" ];then
-        if [ "`$php_install_dir/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}'`" == '7' ];then
-            tar xzf redis-${redis_pecl_for_php7_version}.tgz
-            popd redis-${redis_pecl_for_php7_version}
-        else
-            tar xzf redis-$redis_pecl_version.tgz
-            cd redis-$redis_pecl_version
-        fi
-        make clean
-        $php_install_dir/bin/phpize
-        ./configure --with-php-config=$php_install_dir/bin/php-config
-        make -j ${THREAD} && make install
-        if [ -f "${phpExtensionDir}/redis.so" ];then
-            cat > $php_install_dir/etc/php.d/ext-redis.ini << EOF
-[redis]
-extension=redis.so
-EOF
-            echo "${CSUCCESS}PHP Redis module installed successfully! ${CEND}"
-            popd
-            rm -rf redis-$redis_pecl_version
-            [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
-        else
-            echo "${CFAILURE}PHP Redis module install failed, Please contact the author! ${CEND}"
-        fi
+  pushd ${oneinstack_dir}/src
+  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
+  if [ -e "${php_install_dir}/bin/phpize" ]; then
+    if [ "`${php_install_dir}/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}'`" == '7' ]; then
+      tar xzf redis-${redis_pecl_for_php7_version}.tgz
+      pushd redis-${redis_pecl_for_php7_version}
+    else
+      tar xzf redis-$redis_pecl_version.tgz
+      pushd redis-$redis_pecl_version
     fi
     fi
-    popd
+    ${php_install_dir}/bin/phpize
+    ./configure --with-php-config=${php_install_dir}/bin/php-config
+    make -j ${THREAD} && make install
+    if [ -f "${phpExtensionDir}/redis.so" ]; then
+      echo 'extension=redis.so' > ${php_install_dir}/etc/php.d/ext-redis.ini
+      echo "${CSUCCESS}PHP Redis module installed successfully! ${CEND}"
+      popd
+      rm -rf redis-${redis_pecl_for_php7_version} redis-$redis_pecl_version
+    else
+      echo "${CFAILURE}PHP Redis module install failed, Please contact the author! ${CEND}"
+    fi
+  fi
+  popd
 }
 }

+ 10 - 12
include/tcmalloc.sh

@@ -9,22 +9,20 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_tcmalloc() {
 Install_tcmalloc() {
-cd $oneinstack_dir/src
-
-tar xzf gperftools-$tcmalloc_version.tar.gz
-cd gperftools-$tcmalloc_version
-./configure --enable-frame-pointers
-make -j ${THREAD} && make install
-
-if [ -f "/usr/local/lib/libtcmalloc.so" ];then
+  pushd ${oneinstack_dir}/src
+  tar xzf gperftools-$tcmalloc_version.tar.gz
+  pushd gperftools-$tcmalloc_version
+  ./configure --enable-frame-pointers
+  make -j ${THREAD} && make install
+  popd
+  if [ -f "/usr/local/lib/libtcmalloc.so" ]; then
     echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
     echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
     ldconfig
     ldconfig
     echo "${CSUCCESS}tcmalloc module installed successfully! ${CEND}"
     echo "${CSUCCESS}tcmalloc module installed successfully! ${CEND}"
-    cd ..
     rm -rf gperftools-$tcmalloc_version
     rm -rf gperftools-$tcmalloc_version
-else
+  else
     echo "${CFAILURE}tcmalloc module install failed, Please contact the author! ${CEND}"
     echo "${CFAILURE}tcmalloc module install failed, Please contact the author! ${CEND}"
     kill -9 $$
     kill -9 $$
-fi
-cd ..
+  fi
+  popd
 }
 }

+ 57 - 58
include/tengine.sh

@@ -9,62 +9,61 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_Tengine() {
 Install_Tengine() {
-cd $oneinstack_dir/src
-
-id -u $run_user >/dev/null 2>&1
-[ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
-
-tar xzf pcre-$pcre_version.tar.gz
-tar xzf tengine-$tengine_version.tar.gz
-tar xzf openssl-$openssl_version.tar.gz
-cd tengine-$tengine_version
-# Modify Tengine version
-#sed -i 's@TENGINE "/" TENGINE_VERSION@"Tengine/unknown"@' src/core/nginx.h
-
-# close debug
-sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc
-
-if [ "$je_tc_malloc" == '1' ];then
+  pushd ${oneinstack_dir}/src
+  
+  id -u $run_user >/dev/null 2>&1
+  [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user
+  
+  tar xzf pcre-$pcre_version.tar.gz
+  tar xzf tengine-$tengine_version.tar.gz
+  tar xzf openssl-$openssl_version.tar.gz
+  pushd tengine-$tengine_version
+  # Modify Tengine version
+  #sed -i 's@TENGINE "/" TENGINE_VERSION@"Tengine/unknown"@' src/core/nginx.h
+  
+  # close debug
+  sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc
+  
+  if [ "$je_tc_malloc" == '1' ]; then
     malloc_module='--with-jemalloc'
     malloc_module='--with-jemalloc'
-elif [ "$je_tc_malloc" == '2' ];then
+  elif [ "$je_tc_malloc" == '2' ]; then
     malloc_module='--with-google_perftools_module'
     malloc_module='--with-google_perftools_module'
     mkdir /tmp/tcmalloc
     mkdir /tmp/tcmalloc
     chown -R ${run_user}.$run_user /tmp/tcmalloc
     chown -R ${run_user}.$run_user /tmp/tcmalloc
-fi
+  fi
 
 
-[ ! -d "$tengine_install_dir" ] && mkdir -p $tengine_install_dir
-./configure --prefix=$tengine_install_dir --user=$run_user --group=$run_user --with-http_stub_status_module --with-http_spdy_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_concat_module=shared --with-http_sysguard_module=shared --with-openssl=../openssl-$openssl_version --with-pcre=../pcre-$pcre_version --with-pcre-jit $malloc_module
-make -j ${THREAD} && make install
-if [ -e "$tengine_install_dir/conf/nginx.conf" ];then
-    cd ..
+  [ ! -d "$tengine_install_dir" ] && mkdir -p $tengine_install_dir
+  ./configure --prefix=$tengine_install_dir --user=$run_user --group=$run_user --with-http_stub_status_module --with-http_spdy_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_concat_module=shared --with-http_sysguard_module=shared --with-openssl=../openssl-$openssl_version --with-pcre=../pcre-$pcre_version --with-pcre-jit $malloc_module
+  make -j ${THREAD} && make install
+  if [ -e "$tengine_install_dir/conf/nginx.conf" ]; then
+    popd
     rm -rf tengine-$tengine_version
     rm -rf tengine-$tengine_version
     echo "${CSUCCESS}Tengine installed successfully! ${CEND}"
     echo "${CSUCCESS}Tengine installed successfully! ${CEND}"
-else
+  else
     rm -rf $tengine_install_dir
     rm -rf $tengine_install_dir
     echo "${CFAILURE}Tengine install failed, Please Contact the author! ${CEND}"
     echo "${CFAILURE}Tengine install failed, Please Contact the author! ${CEND}"
     kill -9 $$
     kill -9 $$
-fi
-
-[ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$tengine_install_dir/sbin:\$PATH" >> /etc/profile
-[ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $tengine_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$tengine_install_dir/sbin:\1@" /etc/profile
-. /etc/profile
+  fi
 
 
-[ "$OS" == 'CentOS' ] && { /bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; }
-[[ $OS =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx; update-rc.d nginx defaults; }
-cd ..
-
-sed -i "s@/usr/local/nginx@$tengine_install_dir@g" /etc/init.d/nginx
-
-mv $tengine_install_dir/conf/nginx.conf{,_bk}
-if [[ $Apache_version =~ ^[1-2]$ ]];then
-    /bin/cp config/nginx_apache.conf $tengine_install_dir/conf/nginx.conf
-elif [[ $Tomcat_version =~ ^[1-2]$ ]] && [ ! -e "$php_install_dir/bin/php" ];then
-    /bin/cp config/nginx_tomcat.conf $tengine_install_dir/conf/nginx.conf
-else
-    /bin/cp config/nginx.conf $tengine_install_dir/conf/nginx.conf
+  [ -z "`grep ^'export PATH=' /etc/profile`" ] && echo "export PATH=$tengine_install_dir/sbin:\$PATH" >> /etc/profile
+  [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $tengine_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$tengine_install_dir/sbin:\1@" /etc/profile
+  . /etc/profile
+  
+  [ "$OS" == 'CentOS' ] && { /bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; }
+  [[ $OS =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx; update-rc.d nginx defaults; }
+  
+  sed -i "s@/usr/local/nginx@$tengine_install_dir@g" /etc/init.d/nginx
+  
+  mv $tengine_install_dir/conf/nginx.conf{,_bk}
+  if [[ $Apache_version =~ ^[1-2]$ ]]; then
+    /bin/cp ../config/nginx_apache.conf $tengine_install_dir/conf/nginx.conf
+  elif [[ $Tomcat_version =~ ^[1-2]$ ]] && [ ! -e "$php_install_dir/bin/php" ]; then
+    /bin/cp ../config/nginx_tomcat.conf $tengine_install_dir/conf/nginx.conf
+  else
+    /bin/cp ../config/nginx.conf $tengine_install_dir/conf/nginx.conf
     [ "$PHP_yn" == 'y' ] && [ -z "`grep '/php-fpm_status' $tengine_install_dir/conf/nginx.conf`" ] &&  sed -i "s@index index.html index.php;@index index.html index.php;\n    location ~ /php-fpm_status {\n        #fastcgi_pass remote_php_ip:9000;\n        fastcgi_pass unix:/dev/shm/php-cgi.sock;\n        fastcgi_index index.php;\n        include fastcgi.conf;\n        allow 127.0.0.1;\n        deny all;\n        }@" $tengine_install_dir/conf/nginx.conf
     [ "$PHP_yn" == 'y' ] && [ -z "`grep '/php-fpm_status' $tengine_install_dir/conf/nginx.conf`" ] &&  sed -i "s@index index.html index.php;@index index.html index.php;\n    location ~ /php-fpm_status {\n        #fastcgi_pass remote_php_ip:9000;\n        fastcgi_pass unix:/dev/shm/php-cgi.sock;\n        fastcgi_index index.php;\n        include fastcgi.conf;\n        allow 127.0.0.1;\n        deny all;\n        }@" $tengine_install_dir/conf/nginx.conf
-fi
-cat > $tengine_install_dir/conf/proxy.conf << EOF
+  fi
+  cat > $tengine_install_dir/conf/proxy.conf << EOF
 proxy_connect_timeout 300s;
 proxy_connect_timeout 300s;
 proxy_send_timeout 900;
 proxy_send_timeout 900;
 proxy_read_timeout 900;
 proxy_read_timeout 900;
@@ -80,17 +79,17 @@ proxy_set_header Host \$host;
 proxy_set_header X-Real-IP \$remote_addr;
 proxy_set_header X-Real-IP \$remote_addr;
 proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
 proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
 EOF
 EOF
-sed -i "s@/data/wwwroot/default@$wwwroot_dir/default@" $tengine_install_dir/conf/nginx.conf
-sed -i "s@/data/wwwlogs@$wwwlogs_dir@g" $tengine_install_dir/conf/nginx.conf
-sed -i "s@^user www www@user $run_user $run_user@" $tengine_install_dir/conf/nginx.conf
-[ "$je_tc_malloc" == '2' ] && sed -i 's@^pid\(.*\)@pid\1\ngoogle_perftools_profiles /tmp/tcmalloc;@' $tengine_install_dir/conf/nginx.conf
-uname -r | awk -F'.' '{if ($1$2>=39)S=0;else S=1}{exit S}' && [ -z "`grep 'reuse_port on;' $tengine_install_dir/conf/nginx.conf`" ] && sed -i "s@worker_connections 51200;@worker_connections 51200;\n    reuse_port on;@" $tengine_install_dir/conf/nginx.conf
-
-# worker_cpu_affinity
-sed -i "s@^worker_processes.*@worker_processes auto;\nworker_cpu_affinity auto;\ndso {\n\tload ngx_http_concat_module.so;\n\tload ngx_http_sysguard_module.so;\n}@" $tengine_install_dir/conf/nginx.conf
-
-# logrotate nginx log
-cat > /etc/logrotate.d/nginx << EOF
+  sed -i "s@/data/wwwroot/default@$wwwroot_dir/default@" $tengine_install_dir/conf/nginx.conf
+  sed -i "s@/data/wwwlogs@$wwwlogs_dir@g" $tengine_install_dir/conf/nginx.conf
+  sed -i "s@^user www www@user $run_user $run_user@" $tengine_install_dir/conf/nginx.conf
+  [ "$je_tc_malloc" == '2' ] && sed -i 's@^pid\(.*\)@pid\1\ngoogle_perftools_profiles /tmp/tcmalloc;@' $tengine_install_dir/conf/nginx.conf
+  uname -r | awk -F'.' '{if ($1$2>=39)S=0;else S=1}{exit S}' && [ -z "`grep 'reuse_port on;' $tengine_install_dir/conf/nginx.conf`" ] && sed -i "s@worker_connections 51200;@worker_connections 51200;\n    reuse_port on;@" $tengine_install_dir/conf/nginx.conf
+  
+  # worker_cpu_affinity
+  sed -i "s@^worker_processes.*@worker_processes auto;\nworker_cpu_affinity auto;\ndso {\n\tload ngx_http_concat_module.so;\n\tload ngx_http_sysguard_module.so;\n}@" $tengine_install_dir/conf/nginx.conf
+  
+  # logrotate nginx log
+  cat > /etc/logrotate.d/nginx << EOF
 $wwwlogs_dir/*nginx.log {
 $wwwlogs_dir/*nginx.log {
 daily
 daily
 rotate 5
 rotate 5
@@ -104,7 +103,7 @@ postrotate
 endscript
 endscript
 }
 }
 EOF
 EOF
-
-ldconfig
-service nginx start
+  popd
+  ldconfig
+  service nginx start
 }
 }

+ 53 - 53
include/tomcat-6.sh

@@ -9,18 +9,18 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_tomcat-6() {
 Install_tomcat-6() {
-cd $oneinstack_dir/src
-. /etc/profile
-
-id -u $run_user >/dev/null 2>&1
-[ $? -ne 0 ] && useradd -M -s /bin/bash $run_user || { [ -z "`grep ^$run_user /etc/passwd | grep '/bin/bash'`" ] && usermod -s /bin/bash $run_user; }
-
-tar xzf apache-tomcat-$tomcat_6_version.tar.gz
-[ ! -d "$tomcat_install_dir" ] && mkdir -p $tomcat_install_dir
-/bin/cp -R apache-tomcat-$tomcat_6_version/* $tomcat_install_dir
-rm -rf $tomcat_install_dir/webapps/{docs,examples,host-manager,manager,ROOT/*}
-
-if [ -e "$tomcat_install_dir/conf/server.xml" ];then
+  cd ${oneinstack_dir}/src
+  . /etc/profile
+  
+  id -u $run_user >/dev/null 2>&1
+  [ $? -ne 0 ] && useradd -M -s /bin/bash $run_user || { [ -z "`grep ^$run_user /etc/passwd | grep '/bin/bash'`" ] && usermod -s /bin/bash $run_user; }
+  
+  tar xzf apache-tomcat-$tomcat_6_version.tar.gz
+  [ ! -d "$tomcat_install_dir" ] && mkdir -p $tomcat_install_dir
+  /bin/cp -R apache-tomcat-$tomcat_6_version/* $tomcat_install_dir
+  rm -rf $tomcat_install_dir/webapps/{docs,examples,host-manager,manager,ROOT/*}
+  
+  if [ -e "$tomcat_install_dir/conf/server.xml" ]; then
     /bin/cp catalina-jmx-remote.jar $tomcat_install_dir/lib
     /bin/cp catalina-jmx-remote.jar $tomcat_install_dir/lib
     cd $tomcat_install_dir/lib
     cd $tomcat_install_dir/lib
     [ ! -d "$tomcat_install_dir/lib/catalina" ] &&  mkdir $tomcat_install_dir/lib/catalina
     [ ! -d "$tomcat_install_dir/lib/catalina" ] &&  mkdir $tomcat_install_dir/lib/catalina
@@ -39,9 +39,9 @@ if [ -e "$tomcat_install_dir/conf/server.xml" ];then
     rm -rf /usr/local/apr
     rm -rf /usr/local/apr
     ./configure --with-apr=/usr/bin/apr-1-config
     ./configure --with-apr=/usr/bin/apr-1-config
     make -j ${THREAD} && make install
     make -j ${THREAD} && make install
-    if [ -d "/usr/local/apr/lib" ];then
-        [ $Mem -le 768 ] && Xms_Mem=`expr $Mem / 3` || Xms_Mem=256
-        cat > $tomcat_install_dir/bin/setenv.sh << EOF
+    if [ -d "/usr/local/apr/lib" ]; then
+      [ $Mem -le 768 ] && Xms_Mem=`expr $Mem / 3` || Xms_Mem=256
+      cat > $tomcat_install_dir/bin/setenv.sh << EOF
 JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms${Xms_Mem}m -Xmx`expr $Mem / 2`m -Dfile.encoding=UTF-8'
 JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms${Xms_Mem}m -Xmx`expr $Mem / 2`m -Dfile.encoding=UTF-8'
 CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"
 CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"
 # -Djava.rmi.server.hostname=$IPADDR
 # -Djava.rmi.server.hostname=$IPADDR
@@ -49,37 +49,37 @@ CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"
 # -Dcom.sun.management.jmxremote.access.file=\$CATALINA_BASE/conf/jmxremote.access
 # -Dcom.sun.management.jmxremote.access.file=\$CATALINA_BASE/conf/jmxremote.access
 # -Dcom.sun.management.jmxremote.ssl=false"
 # -Dcom.sun.management.jmxremote.ssl=false"
 EOF
 EOF
-        cd ../../../;rm -rf tomcat-native-*
-        chmod +x $tomcat_install_dir/bin/*.sh
-        /bin/mv $tomcat_install_dir/conf/server.xml{,_bk}
-        cd $oneinstack_dir/src
-        /bin/cp ../config/server.xml $tomcat_install_dir/conf
-        sed -i "s@/usr/local/tomcat@$tomcat_install_dir@g" $tomcat_install_dir/conf/server.xml
-        sed -i /ThreadLocalLeakPreventionListener/d $tomcat_install_dir/conf/server.xml
-        if [ ! -e "$nginx_install_dir/sbin/nginx" -a ! -e "$tengine_install_dir/sbin/nginx" -a ! -e "$apache_install_dir/conf/httpd.conf" ];then
-            if [ "$OS" == 'CentOS' ];then
-                if [ -z "`grep -w '8080' /etc/sysconfig/iptables`" ];then
-                    iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-                    service iptables save
-                fi
-            elif [[ $OS =~ ^Ubuntu$|^Debian$ ]];then
-                if [ -z "`grep -w '8080' /etc/iptables.up.rules`" ];then
-                    iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-                    iptables-save > /etc/iptables.up.rules
-                fi
-            fi
+      cd ../../../;rm -rf tomcat-native-*
+      chmod +x $tomcat_install_dir/bin/*.sh
+      /bin/mv $tomcat_install_dir/conf/server.xml{,_bk}
+      cd ${oneinstack_dir}/src
+      /bin/cp ../config/server.xml $tomcat_install_dir/conf
+      sed -i "s@/usr/local/tomcat@$tomcat_install_dir@g" $tomcat_install_dir/conf/server.xml
+      sed -i /ThreadLocalLeakPreventionListener/d $tomcat_install_dir/conf/server.xml
+      if [ ! -e "$nginx_install_dir/sbin/nginx" -a ! -e "$tengine_install_dir/sbin/nginx" -a ! -e "$apache_install_dir/conf/httpd.conf" ]; then
+        if [ "$OS" == 'CentOS' ]; then
+          if [ -z "`grep -w '8080' /etc/sysconfig/iptables`" ]; then
+            iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
+            service iptables save
+          fi
+        elif [[ $OS =~ ^Ubuntu$|^Debian$ ]]; then
+          if [ -z "`grep -w '8080' /etc/iptables.up.rules`" ]; then
+            iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
+            iptables-save > /etc/iptables.up.rules
+          fi
         fi
         fi
+      fi
 
 
-        [ ! -d "$tomcat_install_dir/conf/vhost" ] && mkdir $tomcat_install_dir/conf/vhost
-        cat > $tomcat_install_dir/conf/vhost/localhost.xml << EOF
+      [ ! -d "$tomcat_install_dir/conf/vhost" ] && mkdir $tomcat_install_dir/conf/vhost
+      cat > $tomcat_install_dir/conf/vhost/localhost.xml << EOF
 <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
 <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
   <Context path="" docBase="$wwwroot_dir/default" debug="0" reloadable="false" crossContext="true"/>
   <Context path="" docBase="$wwwroot_dir/default" debug="0" reloadable="false" crossContext="true"/>
   <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
   <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
          prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
          prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
 </Host>
 </Host>
 EOF
 EOF
-        # logrotate tomcat catalina.out
-        cat > /etc/logrotate.d/tomcat << EOF
+      # logrotate tomcat catalina.out
+      cat > /etc/logrotate.d/tomcat << EOF
 $tomcat_install_dir/logs/catalina.out {
 $tomcat_install_dir/logs/catalina.out {
 daily
 daily
 rotate 5
 rotate 5
@@ -90,31 +90,31 @@ notifempty
 copytruncate
 copytruncate
 }
 }
 EOF
 EOF
-        [ -z "`grep '<user username="admin" password=' $tomcat_install_dir/conf/tomcat-users.xml`" ] && sed -i "s@^</tomcat-users>@<role rolename=\"admin-gui\"/>\n<role rolename=\"admin-script\"/>\n<role rolename=\"manager-gui\"/>\n<role rolename=\"manager-script\"/>\n<user username=\"admin\" password=\"`cat /dev/urandom | head -1 | md5sum | head -c 10`\" roles=\"admin-gui,admin-script,manager-gui,manager-script\"/>\n</tomcat-users>@" $tomcat_install_dir/conf/tomcat-users.xml
-        cat > $tomcat_install_dir/conf/jmxremote.access << EOF
+      [ -z "`grep '<user username="admin" password=' $tomcat_install_dir/conf/tomcat-users.xml`" ] && sed -i "s@^</tomcat-users>@<role rolename=\"admin-gui\"/>\n<role rolename=\"admin-script\"/>\n<role rolename=\"manager-gui\"/>\n<role rolename=\"manager-script\"/>\n<user username=\"admin\" password=\"`cat /dev/urandom | head -1 | md5sum | head -c 10`\" roles=\"admin-gui,admin-script,manager-gui,manager-script\"/>\n</tomcat-users>@" $tomcat_install_dir/conf/tomcat-users.xml
+      cat > $tomcat_install_dir/conf/jmxremote.access << EOF
 monitorRole   readonly
 monitorRole   readonly
 controlRole   readwrite \
 controlRole   readwrite \
               create javax.management.monitor.*,javax.management.timer.* \
               create javax.management.monitor.*,javax.management.timer.* \
               unregister
               unregister
 EOF
 EOF
-        cat > $tomcat_install_dir/conf/jmxremote.password << EOF
+      cat > $tomcat_install_dir/conf/jmxremote.password << EOF
 monitorRole  `cat /dev/urandom | head -1 | md5sum | head -c 8`
 monitorRole  `cat /dev/urandom | head -1 | md5sum | head -c 8`
 # controlRole   R&D
 # controlRole   R&D
 EOF
 EOF
-        chown -R $run_user.$run_user $tomcat_install_dir
-        /bin/cp ../init.d/Tomcat-init /etc/init.d/tomcat
-        sed -i "s@JAVA_HOME=.*@JAVA_HOME=$JAVA_HOME@" /etc/init.d/tomcat
-        sed -i "s@^CATALINA_HOME=.*@CATALINA_HOME=$tomcat_install_dir@" /etc/init.d/tomcat
-        sed -i "s@^TOMCAT_USER=.*@TOMCAT_USER=$run_user@" /etc/init.d/tomcat
-        [ "$OS" == 'CentOS' ] && { chkconfig --add tomcat; chkconfig tomcat on; }
-        [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d tomcat defaults
-        echo "${CSUCCESS}Tomcat installed successfully! ${CEND}"
+      chown -R $run_user.$run_user $tomcat_install_dir
+      /bin/cp ../init.d/Tomcat-init /etc/init.d/tomcat
+      sed -i "s@JAVA_HOME=.*@JAVA_HOME=$JAVA_HOME@" /etc/init.d/tomcat
+      sed -i "s@^CATALINA_HOME=.*@CATALINA_HOME=$tomcat_install_dir@" /etc/init.d/tomcat
+      sed -i "s@^TOMCAT_USER=.*@TOMCAT_USER=$run_user@" /etc/init.d/tomcat
+      [ "$OS" == 'CentOS' ] && { chkconfig --add tomcat; chkconfig tomcat on; }
+      [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d tomcat defaults
+      echo "${CSUCCESS}Tomcat installed successfully! ${CEND}"
     fi
     fi
-else
+  else
     rm -rf $tomcat_install_dir
     rm -rf $tomcat_install_dir
     echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}"
     echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}"
     kill -9 $$
     kill -9 $$
-fi
-service tomcat start
-cd ..
+  fi
+  service tomcat start
+  cd ..
 }
 }

+ 52 - 52
include/tomcat-7.sh

@@ -9,18 +9,18 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_tomcat-7() {
 Install_tomcat-7() {
-cd $oneinstack_dir/src
-. /etc/profile
-
-id -u $run_user >/dev/null 2>&1
-[ $? -ne 0 ] && useradd -M -s /bin/bash $run_user || { [ -z "`grep ^$run_user /etc/passwd | grep '/bin/bash'`" ] && usermod -s /bin/bash $run_user; }
-
-tar xzf apache-tomcat-$tomcat_7_version.tar.gz
-[ ! -d "$tomcat_install_dir" ] && mkdir -p $tomcat_install_dir
-/bin/cp -R apache-tomcat-$tomcat_7_version/* $tomcat_install_dir
-rm -rf $tomcat_install_dir/webapps/{docs,examples,host-manager,manager,ROOT/*}
-
-if [ -e "$tomcat_install_dir/conf/server.xml" ];then
+  cd ${oneinstack_dir}/src
+  . /etc/profile
+  
+  id -u $run_user >/dev/null 2>&1
+  [ $? -ne 0 ] && useradd -M -s /bin/bash $run_user || { [ -z "`grep ^$run_user /etc/passwd | grep '/bin/bash'`" ] && usermod -s /bin/bash $run_user; }
+  
+  tar xzf apache-tomcat-$tomcat_7_version.tar.gz
+  [ ! -d "$tomcat_install_dir" ] && mkdir -p $tomcat_install_dir
+  /bin/cp -R apache-tomcat-$tomcat_7_version/* $tomcat_install_dir
+  rm -rf $tomcat_install_dir/webapps/{docs,examples,host-manager,manager,ROOT/*}
+  
+  if [ -e "$tomcat_install_dir/conf/server.xml" ]; then
     /bin/cp catalina-jmx-remote.jar $tomcat_install_dir/lib
     /bin/cp catalina-jmx-remote.jar $tomcat_install_dir/lib
     cd $tomcat_install_dir/lib
     cd $tomcat_install_dir/lib
     [ ! -d "$tomcat_install_dir/lib/catalina" ] &&  mkdir $tomcat_install_dir/lib/catalina
     [ ! -d "$tomcat_install_dir/lib/catalina" ] &&  mkdir $tomcat_install_dir/lib/catalina
@@ -39,9 +39,9 @@ if [ -e "$tomcat_install_dir/conf/server.xml" ];then
     rm -rf /usr/local/apr
     rm -rf /usr/local/apr
     ./configure --with-apr=/usr/bin/apr-1-config
     ./configure --with-apr=/usr/bin/apr-1-config
     make -j ${THREAD} && make install
     make -j ${THREAD} && make install
-    if [ -d "/usr/local/apr/lib" ];then
-        [ $Mem -le 768 ] && Xms_Mem=`expr $Mem / 3` || Xms_Mem=256
-        cat > $tomcat_install_dir/bin/setenv.sh << EOF
+    if [ -d "/usr/local/apr/lib" ]; then
+      [ $Mem -le 768 ] && Xms_Mem=`expr $Mem / 3` || Xms_Mem=256
+      cat > $tomcat_install_dir/bin/setenv.sh << EOF
 JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms${Xms_Mem}m -Xmx`expr $Mem / 2`m -Dfile.encoding=UTF-8'
 JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms${Xms_Mem}m -Xmx`expr $Mem / 2`m -Dfile.encoding=UTF-8'
 CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"
 CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"
 # -Djava.rmi.server.hostname=$IPADDR
 # -Djava.rmi.server.hostname=$IPADDR
@@ -49,37 +49,37 @@ CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"
 # -Dcom.sun.management.jmxremote.access.file=\$CATALINA_BASE/conf/jmxremote.access
 # -Dcom.sun.management.jmxremote.access.file=\$CATALINA_BASE/conf/jmxremote.access
 # -Dcom.sun.management.jmxremote.ssl=false"
 # -Dcom.sun.management.jmxremote.ssl=false"
 EOF
 EOF
-        cd ../../../;rm -rf tomcat-native-*
-        chmod +x $tomcat_install_dir/bin/*.sh
-        /bin/mv $tomcat_install_dir/conf/server.xml{,_bk}
-        cd $oneinstack_dir/src
-        /bin/cp ../config/server.xml $tomcat_install_dir/conf
-        sed -i "s@/usr/local/tomcat@$tomcat_install_dir@g" $tomcat_install_dir/conf/server.xml
+      cd ../../../;rm -rf tomcat-native-*
+      chmod +x $tomcat_install_dir/bin/*.sh
+      /bin/mv $tomcat_install_dir/conf/server.xml{,_bk}
+      cd ${oneinstack_dir}/src
+      /bin/cp ../config/server.xml $tomcat_install_dir/conf
+      sed -i "s@/usr/local/tomcat@$tomcat_install_dir@g" $tomcat_install_dir/conf/server.xml
 
 
-        if [ ! -e "$nginx_install_dir/sbin/nginx" -a ! -e "$tengine_install_dir/sbin/nginx" -a ! -e "$apache_install_dir/conf/httpd.conf" ];then
-            if [ "$OS" == 'CentOS' ];then
-                if [ -z "`grep -w '8080' /etc/sysconfig/iptables`" ];then
-                    iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-                    service iptables save
-                fi
-            elif [[ $OS =~ ^Ubuntu$|^Debian$ ]];then
-                if [ -z "`grep -w '8080' /etc/iptables.up.rules`" ];then
-                    iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-                    iptables-save > /etc/iptables.up.rules
-                fi
-            fi
+      if [ ! -e "$nginx_install_dir/sbin/nginx" -a ! -e "$tengine_install_dir/sbin/nginx" -a ! -e "$apache_install_dir/conf/httpd.conf" ]; then
+        if [ "$OS" == 'CentOS' ]; then
+          if [ -z "`grep -w '8080' /etc/sysconfig/iptables`" ]; then
+            iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
+            service iptables save
+          fi
+        elif [[ $OS =~ ^Ubuntu$|^Debian$ ]]; then
+          if [ -z "`grep -w '8080' /etc/iptables.up.rules`" ]; then
+            iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
+            iptables-save > /etc/iptables.up.rules
+          fi
         fi
         fi
+      fi
 
 
-        [ ! -d "$tomcat_install_dir/conf/vhost" ] && mkdir $tomcat_install_dir/conf/vhost
-        cat > $tomcat_install_dir/conf/vhost/localhost.xml << EOF
+      [ ! -d "$tomcat_install_dir/conf/vhost" ] && mkdir $tomcat_install_dir/conf/vhost
+      cat > $tomcat_install_dir/conf/vhost/localhost.xml << EOF
 <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
 <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
   <Context path="" docBase="$wwwroot_dir/default" debug="0" reloadable="false" crossContext="true"/>
   <Context path="" docBase="$wwwroot_dir/default" debug="0" reloadable="false" crossContext="true"/>
   <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
   <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
          prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
          prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
 </Host>
 </Host>
 EOF
 EOF
-        # logrotate tomcat catalina.out
-        cat > /etc/logrotate.d/tomcat << EOF
+      # logrotate tomcat catalina.out
+      cat > /etc/logrotate.d/tomcat << EOF
 $tomcat_install_dir/logs/catalina.out {
 $tomcat_install_dir/logs/catalina.out {
 daily
 daily
 rotate 5
 rotate 5
@@ -90,31 +90,31 @@ notifempty
 copytruncate
 copytruncate
 }
 }
 EOF
 EOF
-        [ -z "`grep '<user username="admin" password=' $tomcat_install_dir/conf/tomcat-users.xml`" ] && sed -i "s@^</tomcat-users>@<role rolename=\"admin-gui\"/>\n<role rolename=\"admin-script\"/>\n<role rolename=\"manager-gui\"/>\n<role rolename=\"manager-script\"/>\n<user username=\"admin\" password=\"`cat /dev/urandom | head -1 | md5sum | head -c 10`\" roles=\"admin-gui,admin-script,manager-gui,manager-script\"/>\n</tomcat-users>@" $tomcat_install_dir/conf/tomcat-users.xml
-        cat > $tomcat_install_dir/conf/jmxremote.access << EOF
+      [ -z "`grep '<user username="admin" password=' $tomcat_install_dir/conf/tomcat-users.xml`" ] && sed -i "s@^</tomcat-users>@<role rolename=\"admin-gui\"/>\n<role rolename=\"admin-script\"/>\n<role rolename=\"manager-gui\"/>\n<role rolename=\"manager-script\"/>\n<user username=\"admin\" password=\"`cat /dev/urandom | head -1 | md5sum | head -c 10`\" roles=\"admin-gui,admin-script,manager-gui,manager-script\"/>\n</tomcat-users>@" $tomcat_install_dir/conf/tomcat-users.xml
+      cat > $tomcat_install_dir/conf/jmxremote.access << EOF
 monitorRole   readonly
 monitorRole   readonly
 controlRole   readwrite \
 controlRole   readwrite \
               create javax.management.monitor.*,javax.management.timer.* \
               create javax.management.monitor.*,javax.management.timer.* \
               unregister
               unregister
 EOF
 EOF
-        cat > $tomcat_install_dir/conf/jmxremote.password << EOF
+      cat > $tomcat_install_dir/conf/jmxremote.password << EOF
 monitorRole  `cat /dev/urandom | head -1 | md5sum | head -c 8`
 monitorRole  `cat /dev/urandom | head -1 | md5sum | head -c 8`
 # controlRole   R&D
 # controlRole   R&D
 EOF
 EOF
-        chown -R $run_user.$run_user $tomcat_install_dir
-        /bin/cp ../init.d/Tomcat-init /etc/init.d/tomcat
-        sed -i "s@JAVA_HOME=.*@JAVA_HOME=$JAVA_HOME@" /etc/init.d/tomcat
-        sed -i "s@^CATALINA_HOME=.*@CATALINA_HOME=$tomcat_install_dir@" /etc/init.d/tomcat
-        sed -i "s@^TOMCAT_USER=.*@TOMCAT_USER=$run_user@" /etc/init.d/tomcat
-        [ "$OS" == 'CentOS' ] && { chkconfig --add tomcat; chkconfig tomcat on; }
-        [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d tomcat defaults
-        echo "${CSUCCESS}Tomcat installed successfully! ${CEND}"
+      chown -R $run_user.$run_user $tomcat_install_dir
+      /bin/cp ../init.d/Tomcat-init /etc/init.d/tomcat
+      sed -i "s@JAVA_HOME=.*@JAVA_HOME=$JAVA_HOME@" /etc/init.d/tomcat
+      sed -i "s@^CATALINA_HOME=.*@CATALINA_HOME=$tomcat_install_dir@" /etc/init.d/tomcat
+      sed -i "s@^TOMCAT_USER=.*@TOMCAT_USER=$run_user@" /etc/init.d/tomcat
+      [ "$OS" == 'CentOS' ] && { chkconfig --add tomcat; chkconfig tomcat on; }
+      [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d tomcat defaults
+      echo "${CSUCCESS}Tomcat installed successfully! ${CEND}"
     fi
     fi
-else
+  else
     rm -rf $tomcat_install_dir
     rm -rf $tomcat_install_dir
     echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}"
     echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}"
     kill -9 $$
     kill -9 $$
-fi
-service tomcat start
-cd ..
+  fi
+  service tomcat start
+  cd ..
 }
 }

+ 52 - 52
include/tomcat-8.sh

@@ -9,18 +9,18 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_tomcat-8() {
 Install_tomcat-8() {
-cd $oneinstack_dir/src
-. /etc/profile
-
-id -u $run_user >/dev/null 2>&1
-[ $? -ne 0 ] && useradd -M -s /bin/bash $run_user || { [ -z "`grep ^$run_user /etc/passwd | grep '/bin/bash'`" ] && usermod -s /bin/bash $run_user; }
-
-tar xzf apache-tomcat-$tomcat_8_version.tar.gz
-[ ! -d "$tomcat_install_dir" ] && mkdir -p $tomcat_install_dir
-/bin/cp -R apache-tomcat-$tomcat_8_version/* $tomcat_install_dir
-rm -rf $tomcat_install_dir/webapps/{docs,examples,host-manager,manager,ROOT/*}
-
-if [ -e "$tomcat_install_dir/conf/server.xml" ];then
+  cd ${oneinstack_dir}/src
+  . /etc/profile
+  
+  id -u $run_user >/dev/null 2>&1
+  [ $? -ne 0 ] && useradd -M -s /bin/bash $run_user || { [ -z "`grep ^$run_user /etc/passwd | grep '/bin/bash'`" ] && usermod -s /bin/bash $run_user; }
+  
+  tar xzf apache-tomcat-$tomcat_8_version.tar.gz
+  [ ! -d "$tomcat_install_dir" ] && mkdir -p $tomcat_install_dir
+  /bin/cp -R apache-tomcat-$tomcat_8_version/* $tomcat_install_dir
+  rm -rf $tomcat_install_dir/webapps/{docs,examples,host-manager,manager,ROOT/*}
+  
+  if [ -e "$tomcat_install_dir/conf/server.xml" ]; then
     /bin/cp catalina-jmx-remote.jar $tomcat_install_dir/lib
     /bin/cp catalina-jmx-remote.jar $tomcat_install_dir/lib
     cd $tomcat_install_dir/lib
     cd $tomcat_install_dir/lib
     [ ! -d "$tomcat_install_dir/lib/catalina" ] &&  mkdir $tomcat_install_dir/lib/catalina
     [ ! -d "$tomcat_install_dir/lib/catalina" ] &&  mkdir $tomcat_install_dir/lib/catalina
@@ -39,9 +39,9 @@ if [ -e "$tomcat_install_dir/conf/server.xml" ];then
     rm -rf /usr/local/apr
     rm -rf /usr/local/apr
     ./configure --with-apr=/usr/bin/apr-1-config
     ./configure --with-apr=/usr/bin/apr-1-config
     make -j ${THREAD} && make install
     make -j ${THREAD} && make install
-    if [ -d "/usr/local/apr/lib" ];then
-        [ $Mem -le 768 ] && Xms_Mem=`expr $Mem / 3` || Xms_Mem=256
-        cat > $tomcat_install_dir/bin/setenv.sh << EOF
+    if [ -d "/usr/local/apr/lib" ]; then
+      [ $Mem -le 768 ] && Xms_Mem=`expr $Mem / 3` || Xms_Mem=256
+      cat > $tomcat_install_dir/bin/setenv.sh << EOF
 JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms${Xms_Mem}m -Xmx`expr $Mem / 2`m -Dfile.encoding=UTF-8'
 JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms${Xms_Mem}m -Xmx`expr $Mem / 2`m -Dfile.encoding=UTF-8'
 CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"
 CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"
 # -Djava.rmi.server.hostname=$IPADDR
 # -Djava.rmi.server.hostname=$IPADDR
@@ -49,37 +49,37 @@ CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"
 # -Dcom.sun.management.jmxremote.access.file=\$CATALINA_BASE/conf/jmxremote.access
 # -Dcom.sun.management.jmxremote.access.file=\$CATALINA_BASE/conf/jmxremote.access
 # -Dcom.sun.management.jmxremote.ssl=false"
 # -Dcom.sun.management.jmxremote.ssl=false"
 EOF
 EOF
-        cd ../../../;rm -rf tomcat-native-*
-        chmod +x $tomcat_install_dir/bin/*.sh
-        /bin/mv $tomcat_install_dir/conf/server.xml{,_bk}
-        cd $oneinstack_dir/src
-        /bin/cp ../config/server.xml $tomcat_install_dir/conf
-        sed -i "s@/usr/local/tomcat@$tomcat_install_dir@g" $tomcat_install_dir/conf/server.xml
+      cd ../../../;rm -rf tomcat-native-*
+      chmod +x $tomcat_install_dir/bin/*.sh
+      /bin/mv $tomcat_install_dir/conf/server.xml{,_bk}
+      cd ${oneinstack_dir}/src
+      /bin/cp ../config/server.xml $tomcat_install_dir/conf
+      sed -i "s@/usr/local/tomcat@$tomcat_install_dir@g" $tomcat_install_dir/conf/server.xml
 
 
-        if [ ! -e "$nginx_install_dir/sbin/nginx" -a ! -e "$tengine_install_dir/sbin/nginx" -a ! -e "$apache_install_dir/conf/httpd.conf" ];then
-            if [ "$OS" == 'CentOS' ];then
-                if [ -z "`grep -w '8080' /etc/sysconfig/iptables`" ];then
-                    iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-                    service iptables save
-                fi
-            elif [[ $OS =~ ^Ubuntu$|^Debian$ ]];then
-                if [ -z "`grep -w '8080' /etc/iptables.up.rules`" ];then
-                    iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-                    iptables-save > /etc/iptables.up.rules
-                fi
-            fi
+      if [ ! -e "$nginx_install_dir/sbin/nginx" -a ! -e "$tengine_install_dir/sbin/nginx" -a ! -e "$apache_install_dir/conf/httpd.conf" ]; then
+        if [ "$OS" == 'CentOS' ]; then
+          if [ -z "`grep -w '8080' /etc/sysconfig/iptables`" ]; then
+            iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
+            service iptables save
+          fi
+        elif [[ $OS =~ ^Ubuntu$|^Debian$ ]]; then
+          if [ -z "`grep -w '8080' /etc/iptables.up.rules`" ]; then
+            iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
+            iptables-save > /etc/iptables.up.rules
+          fi
         fi
         fi
+      fi
 
 
-        [ ! -d "$tomcat_install_dir/conf/vhost" ] && mkdir $tomcat_install_dir/conf/vhost
-        cat > $tomcat_install_dir/conf/vhost/localhost.xml << EOF
+      [ ! -d "$tomcat_install_dir/conf/vhost" ] && mkdir $tomcat_install_dir/conf/vhost
+      cat > $tomcat_install_dir/conf/vhost/localhost.xml << EOF
 <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
 <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
   <Context path="" docBase="$wwwroot_dir/default" debug="0" reloadable="false" crossContext="true"/>
   <Context path="" docBase="$wwwroot_dir/default" debug="0" reloadable="false" crossContext="true"/>
   <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
   <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
          prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
          prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
 </Host>
 </Host>
 EOF
 EOF
-        # logrotate tomcat catalina.out
-        cat > /etc/logrotate.d/tomcat << EOF
+      # logrotate tomcat catalina.out
+      cat > /etc/logrotate.d/tomcat << EOF
 $tomcat_install_dir/logs/catalina.out {
 $tomcat_install_dir/logs/catalina.out {
 daily
 daily
 rotate 5
 rotate 5
@@ -90,31 +90,31 @@ notifempty
 copytruncate
 copytruncate
 }
 }
 EOF
 EOF
-        [ -z "`grep '<user username="admin" password=' $tomcat_install_dir/conf/tomcat-users.xml`" ] && sed -i "s@^</tomcat-users>@<role rolename=\"admin-gui\"/>\n<role rolename=\"admin-script\"/>\n<role rolename=\"manager-gui\"/>\n<role rolename=\"manager-script\"/>\n<user username=\"admin\" password=\"`cat /dev/urandom | head -1 | md5sum | head -c 10`\" roles=\"admin-gui,admin-script,manager-gui,manager-script\"/>\n</tomcat-users>@" $tomcat_install_dir/conf/tomcat-users.xml
-        cat > $tomcat_install_dir/conf/jmxremote.access << EOF
+      [ -z "`grep '<user username="admin" password=' $tomcat_install_dir/conf/tomcat-users.xml`" ] && sed -i "s@^</tomcat-users>@<role rolename=\"admin-gui\"/>\n<role rolename=\"admin-script\"/>\n<role rolename=\"manager-gui\"/>\n<role rolename=\"manager-script\"/>\n<user username=\"admin\" password=\"`cat /dev/urandom | head -1 | md5sum | head -c 10`\" roles=\"admin-gui,admin-script,manager-gui,manager-script\"/>\n</tomcat-users>@" $tomcat_install_dir/conf/tomcat-users.xml
+      cat > $tomcat_install_dir/conf/jmxremote.access << EOF
 monitorRole   readonly
 monitorRole   readonly
 controlRole   readwrite \
 controlRole   readwrite \
               create javax.management.monitor.*,javax.management.timer.* \
               create javax.management.monitor.*,javax.management.timer.* \
               unregister
               unregister
 EOF
 EOF
-        cat > $tomcat_install_dir/conf/jmxremote.password << EOF
+      cat > $tomcat_install_dir/conf/jmxremote.password << EOF
 monitorRole  `cat /dev/urandom | head -1 | md5sum | head -c 8`
 monitorRole  `cat /dev/urandom | head -1 | md5sum | head -c 8`
 # controlRole   R&D
 # controlRole   R&D
 EOF
 EOF
-        chown -R $run_user.$run_user $tomcat_install_dir
-        /bin/cp ../init.d/Tomcat-init /etc/init.d/tomcat
-        sed -i "s@JAVA_HOME=.*@JAVA_HOME=$JAVA_HOME@" /etc/init.d/tomcat
-        sed -i "s@^CATALINA_HOME=.*@CATALINA_HOME=$tomcat_install_dir@" /etc/init.d/tomcat
-        sed -i "s@^TOMCAT_USER=.*@TOMCAT_USER=$run_user@" /etc/init.d/tomcat
-        [ "$OS" == 'CentOS' ] && { chkconfig --add tomcat;chkconfig tomcat on; }
-        [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d tomcat defaults
-        echo "${CSUCCESS}Tomcat installed successfully! ${CEND}"
+      chown -R $run_user.$run_user $tomcat_install_dir
+      /bin/cp ../init.d/Tomcat-init /etc/init.d/tomcat
+      sed -i "s@JAVA_HOME=.*@JAVA_HOME=$JAVA_HOME@" /etc/init.d/tomcat
+      sed -i "s@^CATALINA_HOME=.*@CATALINA_HOME=$tomcat_install_dir@" /etc/init.d/tomcat
+      sed -i "s@^TOMCAT_USER=.*@TOMCAT_USER=$run_user@" /etc/init.d/tomcat
+      [ "$OS" == 'CentOS' ] && { chkconfig --add tomcat;chkconfig tomcat on; }
+      [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d tomcat defaults
+      echo "${CSUCCESS}Tomcat installed successfully! ${CEND}"
     fi
     fi
-else
+  else
     rm -rf $tomcat_install_dir
     rm -rf $tomcat_install_dir
     echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}"
     echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}"
     kill -9 $$
     kill -9 $$
-fi
-service tomcat start
-cd ..
+  fi
+  service tomcat start
+  cd ..
 }
 }

+ 155 - 155
include/upgrade_db.sh

@@ -9,182 +9,182 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Upgrade_DB() {
 Upgrade_DB() {
-cd $oneinstack_dir/src
-[ ! -e "$db_install_dir/bin/mysql" ] && echo "${CWARNING}MySQL/MariaDB/Percona is not installed on your system! ${CEND}" && exit 1
-OLD_DB_version_tmp=`$db_install_dir/bin/mysql -V | awk '{print $5}' | awk -F, '{print $1}'`
-DB_tmp=`echo $OLD_DB_version_tmp | awk -F'-' '{print $2}'`
-if [ "$DB_tmp" == 'MariaDB' ];then
+  pushd ${oneinstack_dir}/src > /dev/null
+  [ ! -e "$db_install_dir/bin/mysql" ] && echo "${CWARNING}MySQL/MariaDB/Percona is not installed on your system! ${CEND}" && exit 1
+  OLD_DB_version_tmp=`$db_install_dir/bin/mysql -V | awk '{print $5}' | awk -F, '{print $1}'`
+  DB_tmp=`echo $OLD_DB_version_tmp | awk -F'-' '{print $2}'`
+  if [ "$DB_tmp" == 'MariaDB' ]; then
     [ "$IPADDR_COUNTRY"x == "CN"x ] && DOWN_ADDR=https://mirrors.tuna.tsinghua.edu.cn/mariadb || DOWN_ADDR=https://downloads.mariadb.org/f
     [ "$IPADDR_COUNTRY"x == "CN"x ] && DOWN_ADDR=https://mirrors.tuna.tsinghua.edu.cn/mariadb || DOWN_ADDR=https://downloads.mariadb.org/f
     DB=MariaDB
     DB=MariaDB
     OLD_DB_version=`echo $OLD_DB_version_tmp | awk -F'-' '{print $1}'`
     OLD_DB_version=`echo $OLD_DB_version_tmp | awk -F'-' '{print $1}'`
-elif [ -n "$DB_tmp" -a "$DB_tmp" != 'MariaDB' ];then
+  elif [ -n "$DB_tmp" -a "$DB_tmp" != 'MariaDB' ]; then
     DB=Percona
     DB=Percona
     OLD_DB_version=$OLD_DB_version_tmp
     OLD_DB_version=$OLD_DB_version_tmp
-else
+  else
     [ "$IPADDR_COUNTRY"x == "CN"x ] && DOWN_ADDR=https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads || DOWN_ADDR=http://cdn.mysql.com/Downloads
     [ "$IPADDR_COUNTRY"x == "CN"x ] && DOWN_ADDR=https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads || DOWN_ADDR=http://cdn.mysql.com/Downloads
     DB=MySQL
     DB=MySQL
     OLD_DB_version=$OLD_DB_version_tmp
     OLD_DB_version=$OLD_DB_version_tmp
-fi
+  fi
 
 
-#backup
-while :; do
+  #backup
+  while :; do
     $db_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "quit" >/dev/null 2>&1
     $db_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "quit" >/dev/null 2>&1
-    if [ $? -eq 0 ];then
-        break
+    if [ $? -eq 0 ]; then
+      break
     else
     else
-        echo
-        read -p "Please input the root password of database: " NEW_dbrootpwd
-        $db_install_dir/bin/mysql -uroot -p${NEW_dbrootpwd} -e "quit" >/dev/null 2>&1
-        if [ $? -eq 0 ];then
-            dbrootpwd=$NEW_dbrootpwd
-            sed -i "s+^dbrootpwd.*+dbrootpwd='$dbrootpwd'+" ../options.conf
-            break
-        else
-            echo "${CFAILURE}$DB root password incorrect,Please enter again! ${CEND}"
-        fi
+      echo
+      read -p "Please input the root password of database: " NEW_dbrootpwd
+      $db_install_dir/bin/mysql -uroot -p${NEW_dbrootpwd} -e "quit" >/dev/null 2>&1
+      if [ $? -eq 0 ]; then
+        dbrootpwd=$NEW_dbrootpwd
+        sed -i "s+^dbrootpwd.*+dbrootpwd='$dbrootpwd'+" ../options.conf
+        break
+      else
+        echo "${CFAILURE}$DB root password incorrect,Please enter again! ${CEND}"
+      fi
     fi
     fi
-done
+  done
 
 
-echo
-echo "${CSUCCESS}Starting $DB backup${CEND}......"
-$db_install_dir/bin/mysqldump -uroot -p${dbrootpwd} --opt --all-databases > DB_all_backup_$(date +"%Y%m%d").sql
-[ -f "DB_all_backup_$(date +"%Y%m%d").sql" ] && echo "$DB backup success, Backup file: ${MSG}`pwd`/DB_all_backup_$(date +"%Y%m%d").sql${CEND}"
-
-#upgrade
-echo
-echo "Current $DB Version: ${CMSG}$OLD_DB_version${CEND}"
-[ -e /usr/local/lib/libjemalloc.so ] && { je_tc_malloc=1; EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"; }
-[ -e /usr/local/lib/libtcmalloc.so ] && { je_tc_malloc=2; EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"; }
-[ -e /usr/local/lib/libjemalloc.so -a -e /usr/local/lib/libtcmalloc.so ] && { je_tc_malloc=1; EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"; }
-
-while :; do echo
+  echo
+  echo "${CSUCCESS}Starting $DB backup${CEND}......"
+  $db_install_dir/bin/mysqldump -uroot -p${dbrootpwd} --opt --all-databases > DB_all_backup_$(date +"%Y%m%d").sql
+  [ -f "DB_all_backup_$(date +"%Y%m%d").sql" ] && echo "$DB backup success, Backup file: ${MSG}`pwd`/DB_all_backup_$(date +"%Y%m%d").sql${CEND}"
+  
+  #upgrade
+  echo
+  echo "Current $DB Version: ${CMSG}$OLD_DB_version${CEND}"
+  [ -e /usr/local/lib/libjemalloc.so ] && { je_tc_malloc=1; EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"; }
+  [ -e /usr/local/lib/libtcmalloc.so ] && { je_tc_malloc=2; EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ltcmalloc'"; }
+  [ -e /usr/local/lib/libjemalloc.so -a -e /usr/local/lib/libtcmalloc.so ] && { je_tc_malloc=1; EXE_LINKER="-DCMAKE_EXE_LINKER_FLAGS='-ljemalloc'"; }
+  
+  while :; do echo
     read -p "Please input upgrade $DB Version(example: $OLD_DB_version): " NEW_DB_version
     read -p "Please input upgrade $DB Version(example: $OLD_DB_version): " NEW_DB_version
-    if [ `echo $NEW_DB_version | awk -F. '{print $1"."$2}'` == `echo $OLD_DB_version | awk -F. '{print $1"."$2}'` ];then
-        if [ "$DB" == 'MariaDB' ];then
-            DB_name=mariadb-${NEW_DB_version}-${GLIBC_FLAG}-${SYS_BIT_b}
-            DB_URL=$DOWN_ADDR/mariadb-${NEW_DB_version}/bintar-${GLIBC_FLAG}-$SYS_BIT_a/$DB_name.tar.gz
-        elif [ "$DB" == 'Percona' ];then
-            DB_name=percona-server-$NEW_DB_version
-            DB_URL=http://www.percona.com/redir/downloads/Percona-Server-`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`/LATEST/source/tarball/$DB_name.tar.gz
-        elif [ "$DB" == 'MySQL' ];then
-            [ `echo $NEW_DB_version | awk -F. '{print $1"."$2}'` != '5.5' ] && DB_name=mysql-${NEW_DB_version}-linux-glibc2.5-${SYS_BIT_b} || DB_name=mysql-${NEW_DB_version}-linux2.6-${SYS_BIT_b}
-            DB_URL=$DOWN_ADDR/MySQL-`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`/$DB_name.tar.gz
-        fi
-            [ ! -e "$DB_name.tar.gz" ] && wget --no-check-certificate -c $DB_URL > /dev/null 2>&1
+    if [ `echo $NEW_DB_version | awk -F. '{print $1"."$2}'` == `echo $OLD_DB_version | awk -F. '{print $1"."$2}'` ]; then
+      if [ "$DB" == 'MariaDB' ]; then
+        DB_name=mariadb-${NEW_DB_version}-${GLIBC_FLAG}-${SYS_BIT_b}
+        DB_URL=$DOWN_ADDR/mariadb-${NEW_DB_version}/bintar-${GLIBC_FLAG}-$SYS_BIT_a/$DB_name.tar.gz
+      elif [ "$DB" == 'Percona' ]; then
+        DB_name=percona-server-$NEW_DB_version
+        DB_URL=http://www.percona.com/redir/downloads/Percona-Server-`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`/LATEST/source/tarball/$DB_name.tar.gz
+      elif [ "$DB" == 'MySQL' ]; then
+        [ `echo $NEW_DB_version | awk -F. '{print $1"."$2}'` != '5.5' ] && DB_name=mysql-${NEW_DB_version}-linux-glibc2.5-${SYS_BIT_b} || DB_name=mysql-${NEW_DB_version}-linux2.6-${SYS_BIT_b}
+        DB_URL=$DOWN_ADDR/MySQL-`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`/$DB_name.tar.gz
+      fi
+        [ ! -e "$DB_name.tar.gz" ] && wget --no-check-certificate -c $DB_URL > /dev/null 2>&1
 
 
-            if [ -e "$DB_name.tar.gz" ];then
-                echo "Download [${CMSG}$DB_name.tar.gz${CEND}] successfully! "
-            else
-                echo "${CWARNING}$DB version does not exist! ${CEND}"
-            fi
-            break
+        if [ -e "$DB_name.tar.gz" ]; then
+          echo "Download [${CMSG}$DB_name.tar.gz${CEND}] successfully! "
+        else
+          echo "${CWARNING}$DB version does not exist! ${CEND}"
+        fi
+        break
     else
     else
-            echo "${CWARNING}input error! ${CEND}Please only input '${CMSG}${OLD_DB_version%.*}.xx${CEND}'"
+      echo "${CWARNING}input error! ${CEND}Please only input '${CMSG}${OLD_DB_version%.*}.xx${CEND}'"
     fi
     fi
-done
+  done
 
 
-if [ -e "$DB_name.tar.gz" ];then
+  if [ -e "$DB_name.tar.gz" ]; then
     echo "[${CMSG}$DB_name.tar.gz${CEND}] found"
     echo "[${CMSG}$DB_name.tar.gz${CEND}] found"
     echo "Press Ctrl+c to cancel or Press any key to continue..."
     echo "Press Ctrl+c to cancel or Press any key to continue..."
     char=`get_char`
     char=`get_char`
-    if [ "$DB" == 'MariaDB' ];then
-        service mysqld stop
-        mv ${mariadb_install_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
-        mv ${mariadb_data_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
-        mkdir -p $mariadb_data_dir;chown mysql.mysql -R $mariadb_data_dir
-        tar xzf $DB_name.tar.gz
-        [ ! -d "$mariadb_install_dir" ] && mkdir -p $mariadb_install_dir
-        mv mariadb-${NEW_DB_version}-*-${SYS_BIT_b}/* $mariadb_install_dir
-        if [ "$je_tc_malloc" == '1' -a "`echo $OLD_DB_version_tmp | awk -F'.' '{print $1"."$2}'`" != '10.1' ];then
-            sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' $mariadb_install_dir/bin/mysqld_safe
-        elif [ "$je_tc_malloc" == '2' -a "`echo $OLD_DB_version_tmp | awk -F'.' '{print $1"."$2}'`" != '10.1' ];then
-            sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' $mariadb_install_dir/bin/mysqld_safe
-        fi
-        $mariadb_install_dir/scripts/mysql_install_db --user=mysql --basedir=$mariadb_install_dir --datadir=$mariadb_data_dir
-        chown mysql.mysql -R $mariadb_data_dir
-        service mysqld start
-        $mariadb_install_dir/bin/mysql < DB_all_backup_$(date +"%Y%m%d").sql
-        service mysqld restart
-        $mariadb_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" >/dev/null 2>&1
-        $mariadb_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" >/dev/null 2>&1
-        [ $? -eq 0 ] &&  echo "You have ${CMSG}successfully${CEND} upgrade from ${CMSG}$OLD_DB_version${CEND} to ${CMSG}$NEW_DB_version${CEND}"
-    elif [ "$DB" == 'Percona' ];then
-        tar zxf $DB_name.tar.gz
-        cd $DB_name
-        make clean
-        if [ "`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`" == '5.5' ];then
-            cmake . -DCMAKE_INSTALL_PREFIX=$percona_install_dir \
--DMYSQL_DATADIR=$percona_data_dir \
--DSYSCONFDIR=/etc \
--DWITH_INNOBASE_STORAGE_ENGINE=1 \
--DWITH_PARTITION_STORAGE_ENGINE=1 \
--DWITH_FEDERATED_STORAGE_ENGINE=1 \
--DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
--DWITH_MYISAM_STORAGE_ENGINE=1 \
--DWITH_ARCHIVE_STORAGE_ENGINE=1 \
--DWITH_READLINE=1 \
--DENABLE_DTRACE=0 \
--DENABLED_LOCAL_INFILE=1 \
--DDEFAULT_CHARSET=utf8mb4 \
--DDEFAULT_COLLATION=utf8mb4_general_ci \
-$EXE_LINKER
-        else
-            cmake . -DCMAKE_INSTALL_PREFIX=$percona_install_dir \
--DMYSQL_DATADIR=$percona_data_dir \
--DSYSCONFDIR=/etc \
--DWITH_INNOBASE_STORAGE_ENGINE=1 \
--DWITH_PARTITION_STORAGE_ENGINE=1 \
--DWITH_FEDERATED_STORAGE_ENGINE=1 \
--DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
--DWITH_MYISAM_STORAGE_ENGINE=1 \
--DWITH_ARCHIVE_STORAGE_ENGINE=1 \
--DENABLED_LOCAL_INFILE=1 \
--DENABLE_DTRACE=0 \
--DDEFAULT_CHARSET=utf8mb4 \
--DDEFAULT_COLLATION=utf8mb4_general_ci \
-$EXE_LINKER
-        fi
-        make -j ${THREAD}
-        service mysqld stop
-        mv ${percona_install_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
-        mv ${percona_data_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
-        [ ! -d "$percona_install_dir" ] && mkdir -p $percona_install_dir
-        mkdir -p $percona_data_dir;chown mysql.mysql -R $percona_data_dir
-        make install
-        cd ..
-        if [ "`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`" == '5.7' ];then
-            $percona_install_dir/bin/mysqld --initialize-insecure --user=mysql --basedir=$percona_install_dir --datadir=$percona_data_dir
-        else
-            $percona_install_dir/scripts/mysql_install_db --user=mysql --basedir=$percona_install_dir --datadir=$percona_data_dir
-        fi
-        chown mysql.mysql -R $percona_data_dir
-        service mysqld start
-        $percona_install_dir/bin/mysql < DB_all_backup_$(date +"%Y%m%d").sql
-        service mysqld restart
-        $percona_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" >/dev/null 2>&1
-        $percona_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" >/dev/null 2>&1
-        [ $? -eq 0 ] &&  echo "You have ${CMSG}successfully${CEND} upgrade from ${CMSG}$OLD_DB_version${CEND} to ${CMSG}$NEW_DB_version${CEND}"
-    elif [ "$DB" == 'MySQL' ];then
-        tar zxf $DB_name.tar.gz
-        service mysqld stop
-        mv ${mysql_install_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
-        mv ${mysql_data_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
-        [ ! -d "$mysql_install_dir" ] && mkdir -p $mysql_install_dir
-        mkdir -p $mysql_data_dir;chown mysql.mysql -R $mysql_data_dir
-        mv $DB_name/* $mysql_install_dir/
-        [ "$je_tc_malloc" == '1' ] && sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' $mysql_install_dir/bin/mysqld_safe
-        [ "$je_tc_malloc" == '2' ] && sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' $mysql_install_dir/bin/mysqld_safe
-        [ "`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`" != '5.7' ] && $mysql_install_dir/scripts/mysql_install_db --user=mysql --basedir=$mysql_install_dir --datadir=$mysql_data_dir
-        [ "`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`" == '5.7' ] && $mysql_install_dir/bin/mysqld --initialize-insecure --user=mysql --basedir=$mysql_install_dir --datadir=$mysql_data_dir
+    if [ "$DB" == 'MariaDB' ]; then
+      service mysqld stop
+      mv ${mariadb_install_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
+      mv ${mariadb_data_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
+      mkdir -p $mariadb_data_dir;chown mysql.mysql -R $mariadb_data_dir
+      tar xzf $DB_name.tar.gz
+      [ ! -d "$mariadb_install_dir" ] && mkdir -p $mariadb_install_dir
+      mv mariadb-${NEW_DB_version}-*-${SYS_BIT_b}/* $mariadb_install_dir
+      if [ "$je_tc_malloc" == '1' -a "`echo $OLD_DB_version_tmp | awk -F'.' '{print $1"."$2}'`" != '10.1' ]; then
+        sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' $mariadb_install_dir/bin/mysqld_safe
+      elif [ "$je_tc_malloc" == '2' -a "`echo $OLD_DB_version_tmp | awk -F'.' '{print $1"."$2}'`" != '10.1' ]; then
+        sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' $mariadb_install_dir/bin/mysqld_safe
+      fi
+      $mariadb_install_dir/scripts/mysql_install_db --user=mysql --basedir=$mariadb_install_dir --datadir=$mariadb_data_dir
+      chown mysql.mysql -R $mariadb_data_dir
+      service mysqld start
+      $mariadb_install_dir/bin/mysql < DB_all_backup_$(date +"%Y%m%d").sql
+      service mysqld restart
+      $mariadb_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" >/dev/null 2>&1
+      $mariadb_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" >/dev/null 2>&1
+      [ $? -eq 0 ] &&  echo "You have ${CMSG}successfully${CEND} upgrade from ${CMSG}$OLD_DB_version${CEND} to ${CMSG}$NEW_DB_version${CEND}"
+    elif [ "$DB" == 'Percona' ]; then
+      tar zxf $DB_name.tar.gz
+      pushd $DB_name
+      make clean
+      if [ "`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`" == '5.5' ]; then
+        cmake . -DCMAKE_INSTALL_PREFIX=$percona_install_dir \
+        -DMYSQL_DATADIR=$percona_data_dir \
+        -DSYSCONFDIR=/etc \
+        -DWITH_INNOBASE_STORAGE_ENGINE=1 \
+        -DWITH_PARTITION_STORAGE_ENGINE=1 \
+        -DWITH_FEDERATED_STORAGE_ENGINE=1 \
+        -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
+        -DWITH_MYISAM_STORAGE_ENGINE=1 \
+        -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
+        -DWITH_READLINE=1 \
+        -DENABLE_DTRACE=0 \
+        -DENABLED_LOCAL_INFILE=1 \
+        -DDEFAULT_CHARSET=utf8mb4 \
+        -DDEFAULT_COLLATION=utf8mb4_general_ci \
+        $EXE_LINKER
+      else
+        cmake . -DCMAKE_INSTALL_PREFIX=$percona_install_dir \
+        -DMYSQL_DATADIR=$percona_data_dir \
+        -DSYSCONFDIR=/etc \
+        -DWITH_INNOBASE_STORAGE_ENGINE=1 \
+        -DWITH_PARTITION_STORAGE_ENGINE=1 \
+        -DWITH_FEDERATED_STORAGE_ENGINE=1 \
+        -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
+        -DWITH_MYISAM_STORAGE_ENGINE=1 \
+        -DWITH_ARCHIVE_STORAGE_ENGINE=1 \
+        -DENABLED_LOCAL_INFILE=1 \
+        -DENABLE_DTRACE=0 \
+        -DDEFAULT_CHARSET=utf8mb4 \
+        -DDEFAULT_COLLATION=utf8mb4_general_ci \
+        $EXE_LINKER
+      fi
+      make -j ${THREAD}
+      service mysqld stop
+      mv ${percona_install_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
+      mv ${percona_data_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
+      [ ! -d "$percona_install_dir" ] && mkdir -p $percona_install_dir
+      mkdir -p $percona_data_dir;chown mysql.mysql -R $percona_data_dir
+      make install
+      popd 
+      if [ "`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`" == '5.7' ]; then
+        $percona_install_dir/bin/mysqld --initialize-insecure --user=mysql --basedir=$percona_install_dir --datadir=$percona_data_dir
+      else
+        $percona_install_dir/scripts/mysql_install_db --user=mysql --basedir=$percona_install_dir --datadir=$percona_data_dir
+      fi
+      chown mysql.mysql -R $percona_data_dir
+      service mysqld start
+      $percona_install_dir/bin/mysql < DB_all_backup_$(date +"%Y%m%d").sql
+      service mysqld restart
+      $percona_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" >/dev/null 2>&1
+      $percona_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" >/dev/null 2>&1
+      [ $? -eq 0 ] &&  echo "You have ${CMSG}successfully${CEND} upgrade from ${CMSG}$OLD_DB_version${CEND} to ${CMSG}$NEW_DB_version${CEND}"
+    elif [ "$DB" == 'MySQL' ]; then
+      tar zxf $DB_name.tar.gz
+      service mysqld stop
+      mv ${mysql_install_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
+      mv ${mysql_data_dir}{,_old_`date +"%Y%m%d_%H%M%S"`}
+      [ ! -d "$mysql_install_dir" ] && mkdir -p $mysql_install_dir
+      mkdir -p $mysql_data_dir;chown mysql.mysql -R $mysql_data_dir
+      mv $DB_name/* $mysql_install_dir/
+      [ "$je_tc_malloc" == '1' ] && sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libjemalloc.so@' $mysql_install_dir/bin/mysqld_safe
+      [ "$je_tc_malloc" == '2' ] && sed -i 's@executing mysqld_safe@executing mysqld_safe\nexport LD_PRELOAD=/usr/local/lib/libtcmalloc.so@' $mysql_install_dir/bin/mysqld_safe
+      [ "`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`" != '5.7' ] && $mysql_install_dir/scripts/mysql_install_db --user=mysql --basedir=$mysql_install_dir --datadir=$mysql_data_dir
+      [ "`echo $NEW_DB_version | awk -F. '{print $1"."$2}'`" == '5.7' ] && $mysql_install_dir/bin/mysqld --initialize-insecure --user=mysql --basedir=$mysql_install_dir --datadir=$mysql_data_dir
 
 
-        chown mysql.mysql -R $mysql_data_dir
-        [ -e "$mysql_install_dir/my.cnf" ] && rm -rf $mysql_install_dir/my.cnf
-        service mysqld start
-        $mysql_install_dir/bin/mysql < DB_all_backup_$(date +"%Y%m%d").sql
-        service mysqld restart
-        $mysql_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" >/dev/null 2>&1
-        $mysql_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" >/dev/null 2>&1
-        [ $? -eq 0 ] &&  echo "You have ${CMSG}successfully${CEND} upgrade from ${CMSG}$OLD_DB_version${CEND} to ${CMSG}$NEW_DB_version${CEND}"
+      chown mysql.mysql -R $mysql_data_dir
+      [ -e "$mysql_install_dir/my.cnf" ] && rm -rf $mysql_install_dir/my.cnf
+      service mysqld start
+      $mysql_install_dir/bin/mysql < DB_all_backup_$(date +"%Y%m%d").sql
+      service mysqld restart
+      $mysql_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "drop database test;" >/dev/null 2>&1
+      $mysql_install_dir/bin/mysql -uroot -p${dbrootpwd} -e "reset master;" >/dev/null 2>&1
+      [ $? -eq 0 ] &&  echo "You have ${CMSG}successfully${CEND} upgrade from ${CMSG}$OLD_DB_version${CEND} to ${CMSG}$NEW_DB_version${CEND}"
     fi
     fi
-fi
+  fi
 }
 }

+ 21 - 21
include/upgrade_php.sh

@@ -9,44 +9,44 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Upgrade_PHP() {
 Upgrade_PHP() {
-cd $oneinstack_dir/src
-[ ! -e "$php_install_dir" ] && echo "${CWARNING}PHP is not installed on your system! ${CEND}" && exit 1
-echo
-OLD_PHP_version=`$php_install_dir/bin/php -r 'echo PHP_VERSION;'`
-echo "Current PHP Version: ${CMSG}$OLD_PHP_version${CEND}"
-while :; do echo
+  pushd ${oneinstack_dir}/src > /dev/null
+  [ ! -e "$php_install_dir" ] && echo "${CWARNING}PHP is not installed on your system! ${CEND}" && exit 1
+  echo
+  OLD_PHP_version=`$php_install_dir/bin/php -r 'echo PHP_VERSION;'`
+  echo "Current PHP Version: ${CMSG}$OLD_PHP_version${CEND}"
+  while :; do echo
     read -p "Please input upgrade PHP Version: " NEW_PHP_version
     read -p "Please input upgrade PHP Version: " NEW_PHP_version
-    if [ "${NEW_PHP_version%.*}" == "${OLD_PHP_version%.*}" ];then
-        [ ! -e "php-$NEW_PHP_version.tar.gz" ] && wget --no-check-certificate -c http://www.php.net/distributions/php-$NEW_PHP_version.tar.gz > /dev/null 2>&1
-        if [ -e "php-$NEW_PHP_version.tar.gz" ];then
-            echo "Download [${CMSG}php-$NEW_PHP_version.tar.gz${CEND}] successfully! "
-        else
-            echo "${CWARNING}PHP version does not exist! ${CEND}"
-        fi
-        break
+    if [ "${NEW_PHP_version%.*}" == "${OLD_PHP_version%.*}" ]; then
+      [ ! -e "php-$NEW_PHP_version.tar.gz" ] && wget --no-check-certificate -c http://www.php.net/distributions/php-$NEW_PHP_version.tar.gz > /dev/null 2>&1
+      if [ -e "php-$NEW_PHP_version.tar.gz" ]; then
+        echo "Download [${CMSG}php-$NEW_PHP_version.tar.gz${CEND}] successfully! "
+      else
+        echo "${CWARNING}PHP version does not exist! ${CEND}"
+      fi
+      break
     else
     else
-        echo "${CWARNING}input error! ${CEND}Please only input '${CMSG}${OLD_PHP_version%.*}.xx${CEND}'"
+      echo "${CWARNING}input error! ${CEND}Please only input '${CMSG}${OLD_PHP_version%.*}.xx${CEND}'"
     fi
     fi
-done
+  done
 
 
-if [ -e "php-$NEW_PHP_version.tar.gz" ];then
+  if [ -e "php-$NEW_PHP_version.tar.gz" ]; then
     echo "[${CMSG}php-$NEW_PHP_version.tar.gz${CEND}] found"
     echo "[${CMSG}php-$NEW_PHP_version.tar.gz${CEND}] found"
     echo "Press Ctrl+c to cancel or Press any key to continue..."
     echo "Press Ctrl+c to cancel or Press any key to continue..."
     char=`get_char`
     char=`get_char`
     tar xzf php-$NEW_PHP_version.tar.gz
     tar xzf php-$NEW_PHP_version.tar.gz
     src_url=http://mirrors.linuxeye.com/oneinstack/src/fpm-race-condition.patch && Download_src
     src_url=http://mirrors.linuxeye.com/oneinstack/src/fpm-race-condition.patch && Download_src
     patch -d php-$NEW_PHP_version -p0 < fpm-race-condition.patch
     patch -d php-$NEW_PHP_version -p0 < fpm-race-condition.patch
-    cd php-$NEW_PHP_version
+    pushd php-$NEW_PHP_version
     make clean
     make clean
     $php_install_dir/bin/php -i |grep 'Configure Command' | awk -F'=>' '{print $2}' | bash
     $php_install_dir/bin/php -i |grep 'Configure Command' | awk -F'=>' '{print $2}' | bash
     make ZEND_EXTRA_LIBS='-liconv'
     make ZEND_EXTRA_LIBS='-liconv'
     echo "Stoping php-fpm..."
     echo "Stoping php-fpm..."
     service php-fpm stop
     service php-fpm stop
     make install
     make install
-    cd ..
+    popd > /dev/null
     echo "Starting php-fpm..."
     echo "Starting php-fpm..."
     service php-fpm start
     service php-fpm start
     echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_PHP_version${CEND} to ${CWARNING}$NEW_PHP_version${CEND}"
     echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_PHP_version${CEND} to ${CWARNING}$NEW_PHP_version${CEND}"
-fi
-cd ..
+  fi
+  popd > /dev/null
 }
 }

+ 26 - 26
include/upgrade_phpmyadmin.sh

@@ -9,40 +9,40 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Upgrade_phpMyAdmin() {
 Upgrade_phpMyAdmin() {
-cd $oneinstack_dir/src
-[ ! -e "$wwwroot_dir/default/phpMyAdmin" ] && echo "${CWARNING}phpMyAdmin is not installed on your system! ${CEND}" && exit 1
-OLD_phpMyAdmin_version=`grep Version $wwwroot_dir/default/phpMyAdmin/README | awk '{print $2}'`
-echo "Current phpMyAdmin Version: ${CMSG}$OLD_phpMyAdmin_version${CEND}"
+  pushd ${oneinstack_dir}/src > /dev/null
+  [ ! -e "${wwwroot_dir}/default/phpMyAdmin" ] && echo "${CWARNING}phpMyAdmin is not installed on your system! ${CEND}" && exit 1
+  OLD_phpMyAdmin_version=`grep Version ${wwwroot_dir}/default/phpMyAdmin/README | awk '{print $2}'`
+  echo "Current phpMyAdmin Version: ${CMSG}${OLD_phpMyAdmin_version}${CEND}"
 
 
-while :; do echo
+  while :; do echo
     read -p "Please input upgrade phpMyAdmin Version(example: 4.4.15): " NEW_phpMyAdmin_version
     read -p "Please input upgrade phpMyAdmin Version(example: 4.4.15): " NEW_phpMyAdmin_version
-    if [ "$NEW_phpMyAdmin_version" != "$OLD_phpMyAdmin_version" ];then
-        [ ! -e "phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz" ] && wget --no-check-certificate -c https://files.phpmyadmin.net/phpMyAdmin/$NEW_phpMyAdmin_version/phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz > /dev/null 2>&1
-        if [ -e "phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz" ];then
-            echo "Download [${CMSG}phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz${CEND}] successfully! "
-            break
-        else
-            echo "${CWARNING}phpMyAdmin version does not exist! ${CEND}"
-        fi
+    if [ "${NEW_phpMyAdmin_version}" != "${OLD_phpMyAdmin_version}" ]; then
+      [ ! -e "phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz" ] && wget --no-check-certificate -c https://files.phpmyadmin.net/phpMyAdmin/${NEW_phpMyAdmin_version}/phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz > /dev/null 2>&1
+      if [ -e "phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz" ]; then
+        echo "Download [${CMSG}phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz${CEND}] successfully! "
+        break
+      else
+        echo "${CWARNING}phpMyAdmin version does not exist! ${CEND}"
+      fi
     else
     else
-        echo "${CWARNING}input error! Upgrade phpMyAdmin version is the same as the old version${CEND}"
+      echo "${CWARNING}input error! Upgrade phpMyAdmin version is the same as the old version${CEND}"
     fi
     fi
-done
+  done
 
 
-if [ -e "phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz" ];then
+  if [ -e "phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz" ]; then
     echo "[${CMSG}phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz${CEND}] found"
     echo "[${CMSG}phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz${CEND}] found"
     echo "Press Ctrl+c to cancel or Press any key to continue..."
     echo "Press Ctrl+c to cancel or Press any key to continue..."
     char=`get_char`
     char=`get_char`
     tar xzf phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz
     tar xzf phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz
-    rm -rf $wwwroot_dir/default/phpMyAdmin
-    /bin/mv phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages $wwwroot_dir/default/phpMyAdmin
-    /bin/cp $wwwroot_dir/default/phpMyAdmin/{config.sample.inc.php,config.inc.php}
-    mkdir $wwwroot_dir/default/phpMyAdmin/{upload,save}
-    sed -i "s@UploadDir.*@UploadDir'\] = 'upload';@" $wwwroot_dir/default/phpMyAdmin/config.inc.php
-    sed -i "s@SaveDir.*@SaveDir'\] = 'save';@" $wwwroot_dir/default/phpMyAdmin/config.inc.php
-    sed -i "s@blowfish_secret.*;@blowfish_secret\'\] = \'`cat /dev/urandom | head -1 | md5sum | head -c 10`\';@" $wwwroot_dir/default/phpMyAdmin/config.inc.php
-    chown -R ${run_user}.$run_user $wwwroot_dir/default/phpMyAdmin
+    rm -rf ${wwwroot_dir}/default/phpMyAdmin
+    /bin/mv phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages ${wwwroot_dir}/default/phpMyAdmin
+    /bin/cp ${wwwroot_dir}/default/phpMyAdmin/{config.sample.inc.php,config.inc.php}
+    mkdir ${wwwroot_dir}/default/phpMyAdmin/{upload,save}
+    sed -i "s@UploadDir.*@UploadDir'\] = 'upload';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php
+    sed -i "s@SaveDir.*@SaveDir'\] = 'save';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php
+    sed -i "s@blowfish_secret.*;@blowfish_secret\'\] = \'$(cat /dev/urandom | head -1 | base64 | head -c 45)\';@" ${wwwroot_dir}/default/phpMyAdmin/config.inc.php
+    chown -R ${run_user}.$run_user ${wwwroot_dir}/default/phpMyAdmin
     echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_phpMyAdmin_version${CEND} to ${CWARNING}$NEW_phpMyAdmin_version${CEND}"
     echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_phpMyAdmin_version${CEND} to ${CWARNING}$NEW_phpMyAdmin_version${CEND}"
-fi
-cd ..
+  fi
+  popd
 }
 }

+ 30 - 30
include/upgrade_redis.sh

@@ -9,49 +9,49 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Upgrade_Redis() {
 Upgrade_Redis() {
-cd $oneinstack_dir/src
-[ ! -d "$redis_install_dir" ] && echo "${CWARNING}Redis is not installed on your system! ${CEND}" && exit 1
-OLD_Redis_version=`$redis_install_dir/bin/redis-cli --version | awk '{print $2}'`
-echo "Current Redis Version: ${CMSG}$OLD_Redis_version${CEND}"
-while :; do echo
+  pushd ${oneinstack_dir}/src > /dev/null
+  [ ! -d "$redis_install_dir" ] && echo "${CWARNING}Redis is not installed on your system! ${CEND}" && exit 1
+  OLD_Redis_version=`$redis_install_dir/bin/redis-cli --version | awk '{print $2}'`
+  echo "Current Redis Version: ${CMSG}$OLD_Redis_version${CEND}"
+  while :; do echo
     read -p "Please input upgrade Redis Version(example: 3.0.5): " NEW_Redis_version
     read -p "Please input upgrade Redis Version(example: 3.0.5): " NEW_Redis_version
-    if [ "$NEW_Redis_version" != "$OLD_Redis_version" ];then
-        [ ! -e "redis-$NEW_Redis_version.tar.gz" ] && wget --no-check-certificate -c http://download.redis.io/releases/redis-$NEW_Redis_version.tar.gz > /dev/null 2>&1
-        if [ -e "redis-$NEW_Redis_version.tar.gz" ];then
-            echo "Download [${CMSG}redis-$NEW_Redis_version.tar.gz${CEND}] successfully! "
-            break
-        else
-            echo "${CWARNING}Redis version does not exist! ${CEND}"
-        fi
+    if [ "$NEW_Redis_version" != "$OLD_Redis_version" ]; then
+      [ ! -e "redis-$NEW_Redis_version.tar.gz" ] && wget --no-check-certificate -c http://download.redis.io/releases/redis-$NEW_Redis_version.tar.gz > /dev/null 2>&1
+      if [ -e "redis-$NEW_Redis_version.tar.gz" ]; then
+        echo "Download [${CMSG}redis-$NEW_Redis_version.tar.gz${CEND}] successfully! "
+        break
+      else
+        echo "${CWARNING}Redis version does not exist! ${CEND}"
+      fi
     else
     else
-        echo "${CWARNING}input error! Upgrade Redis version is the same as the old version${CEND}"
+      echo "${CWARNING}input error! Upgrade Redis version is the same as the old version${CEND}"
     fi
     fi
-done
+  done
 
 
-if [ -e "redis-$NEW_Redis_version.tar.gz" ];then
+  if [ -e "redis-$NEW_Redis_version.tar.gz" ]; then
     echo "[${CMSG}redis-$NEW_Redis_version.tar.gz${CEND}] found"
     echo "[${CMSG}redis-$NEW_Redis_version.tar.gz${CEND}] found"
     echo "Press Ctrl+c to cancel or Press any key to continue..."
     echo "Press Ctrl+c to cancel or Press any key to continue..."
     char=`get_char`
     char=`get_char`
     tar xzf redis-$NEW_Redis_version.tar.gz
     tar xzf redis-$NEW_Redis_version.tar.gz
-    cd redis-$NEW_Redis_version
+    pushd redis-$NEW_Redis_version
     make clean
     make clean
-    if [ "$OS_BIT" == '32' ];then
-        sed -i '1i\CFLAGS= -march=i686' src/Makefile
-        sed -i 's@^OPT=.*@OPT=-O2 -march=i686@' src/.make-settings
+    if [ "$OS_BIT" == '32' ]; then
+      sed -i '1i\CFLAGS= -march=i686' src/Makefile
+      sed -i 's@^OPT=.*@OPT=-O2 -march=i686@' src/.make-settings
     fi
     fi
 
 
     make -j ${THREAD}
     make -j ${THREAD}
 
 
-    if [ -f "src/redis-server" ];then
-        echo "Restarting Redis..."
-        service redis-server stop
-        /bin/cp src/{redis-benchmark,redis-check-aof,redis-check-rdb,redis-cli,redis-sentinel,redis-server} $redis_install_dir/bin/
-        service redis-server start
-        echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_Redis_version${CEND} to ${CWARNING}$NEW_Redis_version${CEND}"
+    if [ -f "src/redis-server" ]; then
+      echo "Restarting Redis..."
+      service redis-server stop
+      /bin/cp src/{redis-benchmark,redis-check-aof,redis-check-rdb,redis-cli,redis-sentinel,redis-server} $redis_install_dir/bin/
+      service redis-server start
+      echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_Redis_version${CEND} to ${CWARNING}$NEW_Redis_version${CEND}"
     else
     else
-        echo "${CFAILURE}Upgrade Redis failed! ${CEND}"
+      echo "${CFAILURE}Upgrade Redis failed! ${CEND}"
     fi
     fi
-    cd ..
-fi
-cd ..
+    popd > /dev/null
+  fi
+  popd > /dev/null
 }
 }

+ 110 - 107
include/upgrade_web.sh

@@ -9,37 +9,37 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Upgrade_Nginx() {
 Upgrade_Nginx() {
-cd $oneinstack_dir/src
-[ ! -e "$nginx_install_dir/sbin/nginx" ] && echo "${CWARNING}Nginx is not installed on your system! ${CEND}" && exit 1
-OLD_Nginx_version_tmp=`$nginx_install_dir/sbin/nginx -v 2>&1`
-OLD_Nginx_version=${OLD_Nginx_version_tmp##*/}
-echo
-echo "Current Nginx Version: ${CMSG}$OLD_Nginx_version${CEND}"
-while :; do echo
+  pushd ${oneinstack_dir}/src > /dev/null
+  [ ! -e "$nginx_install_dir/sbin/nginx" ] && echo "${CWARNING}Nginx is not installed on your system! ${CEND}" && exit 1
+  OLD_Nginx_version_tmp=`$nginx_install_dir/sbin/nginx -v 2>&1`
+  OLD_Nginx_version=${OLD_Nginx_version_tmp##*/}
+  echo
+  echo "Current Nginx Version: ${CMSG}$OLD_Nginx_version${CEND}"
+  while :; do echo
     read -p "Please input upgrade Nginx Version(example: 1.9.15): " NEW_Nginx_version
     read -p "Please input upgrade Nginx Version(example: 1.9.15): " NEW_Nginx_version
-    if [ "$NEW_Nginx_version" != "$OLD_Nginx_version" ];then
-        [ ! -e "nginx-$NEW_Nginx_version.tar.gz" ] && wget --no-check-certificate -c http://nginx.org/download/nginx-$NEW_Nginx_version.tar.gz > /dev/null 2>&1
-        if [ -e "nginx-$NEW_Nginx_version.tar.gz" ];then
-            src_url=https://www.openssl.org/source/openssl-$openssl_version.tar.gz && Download_src
-            src_url=http://mirrors.linuxeye.com/oneinstack/src/pcre-$pcre_version.tar.gz && Download_src
-            tar xzf openssl-$openssl_version.tar.gz
-            tar xzf pcre-$pcre_version.tar.gz
-            echo "Download [${CMSG}nginx-$NEW_Nginx_version.tar.gz${CEND}] successfully! "
-            break
-        else
-            echo "${CWARNING}Nginx version does not exist! ${CEND}"
-        fi
+    if [ "$NEW_Nginx_version" != "$OLD_Nginx_version" ]; then
+      [ ! -e "nginx-$NEW_Nginx_version.tar.gz" ] && wget --no-check-certificate -c http://nginx.org/download/nginx-$NEW_Nginx_version.tar.gz > /dev/null 2>&1
+      if [ -e "nginx-$NEW_Nginx_version.tar.gz" ]; then
+        src_url=https://www.openssl.org/source/openssl-$openssl_version.tar.gz && Download_src
+        src_url=http://mirrors.linuxeye.com/oneinstack/src/pcre-$pcre_version.tar.gz && Download_src
+        tar xzf openssl-$openssl_version.tar.gz
+        tar xzf pcre-$pcre_version.tar.gz
+        echo "Download [${CMSG}nginx-$NEW_Nginx_version.tar.gz${CEND}] successfully! "
+        break
+      else
+        echo "${CWARNING}Nginx version does not exist! ${CEND}"
+      fi
     else
     else
-        echo "${CWARNING}input error! Upgrade Nginx version is the same as the old version${CEND}"
+      echo "${CWARNING}input error! Upgrade Nginx version is the same as the old version${CEND}"
     fi
     fi
-done
+  done
 
 
-if [ -e "nginx-$NEW_Nginx_version.tar.gz" ];then
+  if [ -e "nginx-$NEW_Nginx_version.tar.gz" ]; then
     echo "[${CMSG}nginx-$NEW_Nginx_version.tar.gz${CEND}] found"
     echo "[${CMSG}nginx-$NEW_Nginx_version.tar.gz${CEND}] found"
     echo "Press Ctrl+c to cancel or Press any key to continue..."
     echo "Press Ctrl+c to cancel or Press any key to continue..."
     char=`get_char`
     char=`get_char`
     tar xzf nginx-$NEW_Nginx_version.tar.gz
     tar xzf nginx-$NEW_Nginx_version.tar.gz
-    cd nginx-$NEW_Nginx_version
+    pushd nginx-$NEW_Nginx_version
     make clean
     make clean
     sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc # close debug
     sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc # close debug
     $nginx_install_dir/sbin/nginx -V &> $$
     $nginx_install_dir/sbin/nginx -V &> $$
@@ -47,53 +47,54 @@ if [ -e "nginx-$NEW_Nginx_version.tar.gz" ];then
     rm -rf $$
     rm -rf $$
     ./configure $nginx_configure_arguments
     ./configure $nginx_configure_arguments
     make -j ${THREAD}
     make -j ${THREAD}
-    if [ -f "objs/nginx" ];then
-        /bin/mv $nginx_install_dir/sbin/nginx{,`date +%m%d`}
-        /bin/cp objs/nginx $nginx_install_dir/sbin/nginx
-        kill -USR2 `cat /var/run/nginx.pid`
-        sleep 1
-        kill -QUIT `cat /var/run/nginx.pid.oldbin`
-        echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_Nginx_version${CEND} to ${CWARNING}$NEW_Nginx_version${CEND}"
+    if [ -f "objs/nginx" ]; then
+      /bin/mv $nginx_install_dir/sbin/nginx{,`date +%m%d`}
+      /bin/cp objs/nginx $nginx_install_dir/sbin/nginx
+      kill -USR2 `cat /var/run/nginx.pid`
+      sleep 1
+      kill -QUIT `cat /var/run/nginx.pid.oldbin`
+      popd > /dev/null
+      echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_Nginx_version${CEND} to ${CWARNING}$NEW_Nginx_version${CEND}"
+      rm -rf nginx-$NEW_Nginx_version
     else
     else
-        echo "${CFAILURE}Upgrade Nginx failed! ${CEND}"
+      echo "${CFAILURE}Upgrade Nginx failed! ${CEND}"
     fi
     fi
-    cd ..
-fi
-cd ..
+  fi
+  popd > /dev/null
 }
 }
 
 
 Upgrade_Tengine() {
 Upgrade_Tengine() {
-cd $oneinstack_dir/src
-[ ! -e "$tengine_install_dir/sbin/nginx" ] && echo "${CWARNING}Tengine is not installed on your system! ${CEND}" && exit 1
-OLD_Tengine_version_tmp=`$tengine_install_dir/sbin/nginx -v 2>&1`
-OLD_Tengine_version="`echo ${OLD_Tengine_version_tmp#*/} | awk '{print $1}'`"
-echo
-echo "Current Tengine Version: ${CMSG}$OLD_Tengine_version${CEND}"
-while :; do echo
+  pushd ${oneinstack_dir}/src
+  [ ! -e "$tengine_install_dir/sbin/nginx" ] && echo "${CWARNING}Tengine is not installed on your system! ${CEND}" && exit 1
+  OLD_Tengine_version_tmp=`$tengine_install_dir/sbin/nginx -v 2>&1`
+  OLD_Tengine_version="`echo ${OLD_Tengine_version_tmp#*/} | awk '{print $1}'`"
+  echo
+  echo "Current Tengine Version: ${CMSG}$OLD_Tengine_version${CEND}"
+  while :; do echo
     read -p "Please input upgrade Tengine Version(example: 2.1.15): " NEW_Tengine_version
     read -p "Please input upgrade Tengine Version(example: 2.1.15): " NEW_Tengine_version
-    if [ "$NEW_Tengine_version" != "$OLD_Tengine_version" ];then
-        [ ! -e "tengine-$NEW_Tengine_version.tar.gz" ] && wget --no-check-certificate -c http://tengine.taobao.org/download/tengine-$NEW_Tengine_version.tar.gz > /dev/null 2>&1
-        if [ -e "tengine-$NEW_Tengine_version.tar.gz" ];then
-            src_url=https://www.openssl.org/source/openssl-$openssl_version.tar.gz && Download_src
-            src_url=http://mirrors.linuxeye.com/oneinstack/src/pcre-$pcre_version.tar.gz && Download_src
-            tar xzf openssl-$openssl_version.tar.gz
-            tar xzf pcre-$pcre_version.tar.gz
-            echo "Download [${CMSG}tengine-$NEW_Tengine_version.tar.gz${CEND}] successfully! "
-            break
-        else
-            echo "${CWARNING}Tengine version does not exist! ${CEND}"
-        fi
+    if [ "$NEW_Tengine_version" != "$OLD_Tengine_version" ]; then
+      [ ! -e "tengine-$NEW_Tengine_version.tar.gz" ] && wget --no-check-certificate -c http://tengine.taobao.org/download/tengine-$NEW_Tengine_version.tar.gz > /dev/null 2>&1
+      if [ -e "tengine-$NEW_Tengine_version.tar.gz" ]; then
+        src_url=https://www.openssl.org/source/openssl-$openssl_version.tar.gz && Download_src
+        src_url=http://mirrors.linuxeye.com/oneinstack/src/pcre-$pcre_version.tar.gz && Download_src
+        tar xzf openssl-$openssl_version.tar.gz
+        tar xzf pcre-$pcre_version.tar.gz
+        echo "Download [${CMSG}tengine-$NEW_Tengine_version.tar.gz${CEND}] successfully! "
+        break
+      else
+        echo "${CWARNING}Tengine version does not exist! ${CEND}"
+      fi
     else
     else
-        echo "${CWARNING}input error! Upgrade Tengine version is the same as the old version${CEND}"
+      echo "${CWARNING}input error! Upgrade Tengine version is the same as the old version${CEND}"
     fi
     fi
-done
+  done
 
 
-if [ -e "tengine-$NEW_Tengine_version.tar.gz" ];then
+  if [ -e "tengine-$NEW_Tengine_version.tar.gz" ]; then
     echo "[${CMSG}tengine-$NEW_Tengine_version.tar.gz${CEND}] found"
     echo "[${CMSG}tengine-$NEW_Tengine_version.tar.gz${CEND}] found"
     echo "Press Ctrl+c to cancel or Press any key to continue..."
     echo "Press Ctrl+c to cancel or Press any key to continue..."
     char=`get_char`
     char=`get_char`
     tar xzf tengine-$NEW_Tengine_version.tar.gz
     tar xzf tengine-$NEW_Tengine_version.tar.gz
-    cd tengine-$NEW_Tengine_version
+    pushd tengine-$NEW_Tengine_version
     make clean
     make clean
     sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc # close debug
     sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' auto/cc/gcc # close debug
     $tengine_install_dir/sbin/nginx -V &> $$
     $tengine_install_dir/sbin/nginx -V &> $$
@@ -101,58 +102,59 @@ if [ -e "tengine-$NEW_Tengine_version.tar.gz" ];then
     rm -rf $$
     rm -rf $$
     ./configure $tengine_configure_arguments
     ./configure $tengine_configure_arguments
     make -j ${THREAD}
     make -j ${THREAD}
-    if [ -f "objs/nginx" ];then
-        /bin/mv $tengine_install_dir/sbin/nginx{,`date +%m%d`}
-        /bin/mv $tengine_install_dir/sbin/dso_tool{,`date +%m%d`}
-        /bin/mv $tengine_install_dir/modules{,`date +%m%d`}
-        /bin/cp objs/nginx $tengine_install_dir/sbin/nginx
-        /bin/cp objs/dso_tool $tengine_install_dir/sbin/dso_tool
-        chmod +x $tengine_install_dir/sbin/*
-        make install
-        kill -USR2 `cat /var/run/nginx.pid`
-        sleep 1
-        kill -QUIT `cat /var/run/nginx.pid.oldbin`
-        echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_Tengine_version${CEND} to ${CWARNING}$NEW_Tengine_version${CEND}"
+    if [ -f "objs/nginx" ]; then
+      /bin/mv $tengine_install_dir/sbin/nginx{,`date +%m%d`}
+      /bin/mv $tengine_install_dir/sbin/dso_tool{,`date +%m%d`}
+      /bin/mv $tengine_install_dir/modules{,`date +%m%d`}
+      /bin/cp objs/nginx $tengine_install_dir/sbin/nginx
+      /bin/cp objs/dso_tool $tengine_install_dir/sbin/dso_tool
+      chmod +x $tengine_install_dir/sbin/*
+      make install
+      kill -USR2 `cat /var/run/nginx.pid`
+      sleep 1
+      kill -QUIT `cat /var/run/nginx.pid.oldbin`
+      popd > /dev/null
+      echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_Tengine_version${CEND} to ${CWARNING}$NEW_Tengine_version${CEND}"
+      rm -rf tengine-$NEW_Tengine_version
     else
     else
-        echo "${CFAILURE}Upgrade Tengine failed! ${CEND}"
+      echo "${CFAILURE}Upgrade Tengine failed! ${CEND}"
     fi
     fi
-    cd ..
-fi
-cd ..
+  fi
+  popd > /dev/null
 }
 }
 
 
 Upgrade_OpenResty() {
 Upgrade_OpenResty() {
-cd $oneinstack_dir/src
-[ ! -e "$openresty_install_dir/nginx/sbin/nginx" ] && echo "${CWARNING}OpenResty is not installed on your system! ${CEND}" && exit 1
-OLD_OpenResty_version_tmp=`$openresty_install_dir/nginx/sbin/nginx -v 2>&1`
-OLD_OpenResty_version="`echo ${OLD_OpenResty_version_tmp#*/} | awk '{print $1}'`"
-echo
-echo "Current OpenResty Version: ${CMSG}$OLD_OpenResty_version${CEND}"
-while :; do echo
+  pushd ${oneinstack_dir}/src
+  [ ! -e "$openresty_install_dir/nginx/sbin/nginx" ] && echo "${CWARNING}OpenResty is not installed on your system! ${CEND}" && exit 1
+  OLD_OpenResty_version_tmp=`$openresty_install_dir/nginx/sbin/nginx -v 2>&1`
+  OLD_OpenResty_version="`echo ${OLD_OpenResty_version_tmp#*/} | awk '{print $1}'`"
+  echo
+  echo "Current OpenResty Version: ${CMSG}$OLD_OpenResty_version${CEND}"
+  while :; do echo
     read -p "Please input upgrade OpenResty Version(example: 1.9.7.19): " NEW_OpenResty_version
     read -p "Please input upgrade OpenResty Version(example: 1.9.7.19): " NEW_OpenResty_version
-    if [ "$NEW_OpenResty_version" != "$OLD_OpenResty_version" ];then
-        [ ! -e "openresty-$NEW_OpenResty_version.tar.gz" ] && wget --no-check-certificate -c https://openresty.org/download/openresty-$NEW_OpenResty_version.tar.gz > /dev/null 2>&1
-        if [ -e "openresty-$NEW_OpenResty_version.tar.gz" ];then
-            src_url=https://www.openssl.org/source/openssl-$openssl_version.tar.gz && Download_src
-            src_url=http://mirrors.linuxeye.com/oneinstack/src/pcre-$pcre_version.tar.gz && Download_src
-            tar xzf openssl-$openssl_version.tar.gz
-            tar xzf pcre-$pcre_version.tar.gz
-            echo "Download [${CMSG}openresty-$NEW_OpenResty_version.tar.gz${CEND}] successfully! "
-            break
-        else
-            echo "${CWARNING}OpenResty version does not exist! ${CEND}"
-        fi
+    if [ "$NEW_OpenResty_version" != "$OLD_OpenResty_version" ]; then
+      [ ! -e "openresty-$NEW_OpenResty_version.tar.gz" ] && wget --no-check-certificate -c https://openresty.org/download/openresty-$NEW_OpenResty_version.tar.gz > /dev/null 2>&1
+      if [ -e "openresty-$NEW_OpenResty_version.tar.gz" ]; then
+        src_url=https://www.openssl.org/source/openssl-$openssl_version.tar.gz && Download_src
+        src_url=http://mirrors.linuxeye.com/oneinstack/src/pcre-$pcre_version.tar.gz && Download_src
+        tar xzf openssl-$openssl_version.tar.gz
+        tar xzf pcre-$pcre_version.tar.gz
+        echo "Download [${CMSG}openresty-$NEW_OpenResty_version.tar.gz${CEND}] successfully! "
+        break
+      else
+        echo "${CWARNING}OpenResty version does not exist! ${CEND}"
+      fi
     else
     else
-        echo "${CWARNING}input error! Upgrade OpenResty version is the same as the old version${CEND}"
+      echo "${CWARNING}input error! Upgrade OpenResty version is the same as the old version${CEND}"
     fi
     fi
-done
+  done
 
 
-if [ -e "openresty-$NEW_OpenResty_version.tar.gz" ];then
+  if [ -e "openresty-$NEW_OpenResty_version.tar.gz" ]; then
     echo "[${CMSG}openresty-$NEW_OpenResty_version.tar.gz${CEND}] found"
     echo "[${CMSG}openresty-$NEW_OpenResty_version.tar.gz${CEND}] found"
     echo "Press Ctrl+c to cancel or Press any key to continue..."
     echo "Press Ctrl+c to cancel or Press any key to continue..."
     char=`get_char`
     char=`get_char`
     tar xzf openresty-$NEW_OpenResty_version.tar.gz
     tar xzf openresty-$NEW_OpenResty_version.tar.gz
-    cd openresty-$NEW_OpenResty_version
+    pushd openresty-$NEW_OpenResty_version
     make clean
     make clean
     openresty_version_tmp=${NEW_OpenResty_version%.*}
     openresty_version_tmp=${NEW_OpenResty_version%.*}
     sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' bundle/nginx-$openresty_version_tmp/auto/cc/gcc # close debug
     sed -i 's@CFLAGS="$CFLAGS -g"@#CFLAGS="$CFLAGS -g"@' bundle/nginx-$openresty_version_tmp/auto/cc/gcc # close debug
@@ -163,17 +165,18 @@ if [ -e "openresty-$NEW_OpenResty_version.tar.gz" ];then
     [ -n "`echo $openresty_configure_arguments | grep perftools`" ] && malloc_module='--with-google_perftools_module'
     [ -n "`echo $openresty_configure_arguments | grep perftools`" ] && malloc_module='--with-google_perftools_module'
     ./configure --prefix=$openresty_install_dir --user=$run_user --group=$run_user --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-openssl=../openssl-$openssl_version --with-pcre=../pcre-$pcre_version --with-pcre-jit $malloc_module
     ./configure --prefix=$openresty_install_dir --user=$run_user --group=$run_user --with-http_stub_status_module --with-http_v2_module --with-http_ssl_module --with-ipv6 --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-openssl=../openssl-$openssl_version --with-pcre=../pcre-$pcre_version --with-pcre-jit $malloc_module
     make -j ${THREAD}
     make -j ${THREAD}
-    if [ -f "build/nginx-$openresty_version_tmp/objs/nginx" ];then
-        /bin/mv $openresty_install_dir/nginx/sbin/nginx{,`date +%m%d`}
-        make install
-        kill -USR2 `cat /var/run/nginx.pid`
-        sleep 1
-        kill -QUIT `cat /var/run/nginx.pid.oldbin`
-        echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_OpenResty_version${CEND} to ${CWARNING}$NEW_OpenResty_version${CEND}"
+    if [ -f "build/nginx-$openresty_version_tmp/objs/nginx" ]; then
+      /bin/mv $openresty_install_dir/nginx/sbin/nginx{,`date +%m%d`}
+      make install
+      kill -USR2 `cat /var/run/nginx.pid`
+      sleep 1
+      kill -QUIT `cat /var/run/nginx.pid.oldbin`
+      popd > /dev/null
+      echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_OpenResty_version${CEND} to ${CWARNING}$NEW_OpenResty_version${CEND}"
+      rm -rf openresty-$NEW_OpenResty_version
     else
     else
-        echo "${CFAILURE}Upgrade OpenResty failed! ${CEND}"
+      echo "${CFAILURE}Upgrade OpenResty failed! ${CEND}"
     fi
     fi
-    cd ..
-fi
-cd ..
+  fi
+  popd > /dev/null 
 }
 }

+ 20 - 22
include/xcache.sh

@@ -9,20 +9,20 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_XCache() {
 Install_XCache() {
-    pushd $oneinstack_dir/src
-    phpExtensionDir=`$php_install_dir/bin/php-config --extension-dir`
-    tar xzf xcache-$xcache_version.tar.gz
-    pushd xcache-$xcache_version
-    make clean
-    $php_install_dir/bin/phpize
-    ./configure --enable-xcache --enable-xcache-coverager --enable-xcache-optimizer --with-php-config=$php_install_dir/bin/php-config
-    make -j ${THREAD} && make install
-    if [ -f "${phpExtensionDir}/xcache.so" ];then
-        /bin/cp -R htdocs $wwwroot_dir/default/xcache
-        chown -R ${run_user}.$run_user $wwwroot_dir/default/xcache
-        touch /tmp/xcache;chown ${run_user}.$run_user /tmp/xcache
-    
-        cat > $php_install_dir/etc/php.d/ext-xcache.ini << EOF
+  pushd ${oneinstack_dir}/src
+  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
+  tar xzf xcache-${xcache_version}.tar.gz
+  pushd xcache-${xcache_version}
+  ${php_install_dir}/bin/phpize
+  ./configure --enable-xcache --enable-xcache-coverager --enable-xcache-optimizer --with-php-config=${php_install_dir}/bin/php-config
+  make -j ${THREAD} && make install
+  popd
+  if [ -f "${phpExtensionDir}/xcache.so" ]; then
+    /bin/cp -R htdocs ${wwwroot_dir}/default/xcache
+    chown -R ${run_user}.$run_user ${wwwroot_dir}/default/xcache
+    touch /tmp/xcache;chown ${run_user}.${run_user} /tmp/xcache
+
+    cat > ${php_install_dir}/etc/php.d/ext-xcache.ini << EOF
 [xcache-common]
 [xcache-common]
 extension=xcache.so
 extension=xcache.so
 [xcache.admin]
 [xcache.admin]
@@ -59,12 +59,10 @@ xcache.coverager = Off
 xcache.coverager_autostart = On
 xcache.coverager_autostart = On
 xcache.coveragedump_directory = ""
 xcache.coveragedump_directory = ""
 EOF
 EOF
-        echo "${CSUCCESS}Xcache module installed successfully! ${CEND}"
-        popd
-        rm -rf xcache-$xcache_version
-        [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
-    else
-        echo "${CFAILURE}Xcache module install failed, Please contact the author! ${CEND}"
-    fi
-    popd
+    echo "${CSUCCESS}Xcache module installed successfully! ${CEND}"
+    rm -rf xcache-${xcache_version}
+  else
+    echo "${CFAILURE}Xcache module install failed, Please contact the author! ${CEND}"
+  fi
+  popd
 }
 }

+ 16 - 18
include/zendopcache.sh

@@ -9,16 +9,16 @@
 #       https://github.com/lj2007331/oneinstack
 #       https://github.com/lj2007331/oneinstack
 
 
 Install_ZendOPcache() {
 Install_ZendOPcache() {
-    pushd $oneinstack_dir/src
-    phpExtensionDir=`$php_install_dir/bin/php-config --extension-dir`
-    tar xzf zendopcache-$zendopcache_version.tgz
-    pushd zendopcache-$zendopcache_version
-    make clean
-    $php_install_dir/bin/phpize
-    ./configure --with-php-config=$php_install_dir/bin/php-config
-    make -j ${THREAD} && make install
-    if [ -f "${phpExtensionDir}/opcache.so" ];then
-        cat > $php_install_dir/etc/php.d/ext-opcache.ini << EOF
+  pushd ${oneinstack_dir}/src
+  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
+  tar xzf zendopcache-$zendopcache_version.tgz
+  pushd zendopcache-$zendopcache_version
+  ${php_install_dir}/bin/phpize
+  ./configure --with-php-config=${php_install_dir}/bin/php-config
+  make -j ${THREAD} && make install
+  popd
+  if [ -f "${phpExtensionDir}/opcache.so" ]; then
+    cat > ${php_install_dir}/etc/php.d/ext-opcache.ini << EOF
 [opcache]
 [opcache]
 zend_extension=${phpExtensionDir}/opcache.so
 zend_extension=${phpExtensionDir}/opcache.so
 opcache.enable=1
 opcache.enable=1
@@ -31,12 +31,10 @@ opcache.fast_shutdown=1
 opcache.enable_cli=1
 opcache.enable_cli=1
 ;opcache.optimization_level=0
 ;opcache.optimization_level=0
 EOF
 EOF
-        echo "${CSUCCESS}PHP OPcache module installed successfully! ${CEND}"
-        popd
-        rm -rf zendopcache-$zendopcache_version
-        [ "$Apache_version" != '1' -a "$Apache_version" != '2' ] && service php-fpm restart || service httpd restart
-    else
-        echo "${CFAILURE}PHP OPcache module install failed, Please contact the author! ${CEND}"
-    fi
-    popd
+    echo "${CSUCCESS}PHP OPcache module installed successfully! ${CEND}"
+    rm -rf zendopcache-${zendopcache_version}
+  else
+    echo "${CFAILURE}PHP OPcache module install failed, Please contact the author! ${CEND}"
+  fi
+  popd
 }
 }

File diff suppressed because it is too large
+ 525 - 526
install.sh


+ 102 - 102
pureftpd_vhost.sh

@@ -35,44 +35,44 @@ FTP_bin=$pureftpd_install_dir/bin/pure-pw
 
 
 USER() {
 USER() {
 while :; do echo
 while :; do echo
-    read -p "Please input a username: " User
-    if [ -z "$User" ]; then
-        echo "${CWARNING}username can't be NULL! ${CEND}"
-    else
-        break
-    fi
+  read -p "Please input a username: " User
+  if [ -z "$User" ]; then
+    echo "${CWARNING}username can't be NULL! ${CEND}"
+  else
+    break
+  fi
 done
 done
 }
 }
 
 
 PASSWORD() {
 PASSWORD() {
 while :; do echo
 while :; do echo
-    read -p "Please input the password: " Password
-    [ -n "`echo $Password | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and &${CEND}"; continue; }
-    if (( ${#Password} >= 5 ));then
-        echo -e "${Password}\n$Password" > $FTP_tmp_passfile
-        break
-    else
-        echo "${CWARNING}Ftp password least 5 characters! ${CEND}"
-    fi
+  read -p "Please input the password: " Password
+  [ -n "`echo $Password | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and &${CEND}"; continue; }
+  if (( ${#Password} >= 5 ));then
+    echo -e "${Password}\n$Password" > $FTP_tmp_passfile
+    break
+  else
+    echo "${CWARNING}Ftp password least 5 characters! ${CEND}"
+  fi
 done
 done
 }
 }
 
 
 DIRECTORY() {
 DIRECTORY() {
 while :; do echo
 while :; do echo
-    read -p "Please input the directory(Default directory: $wwwroot_dir): " Directory
-    if [ -z "$Directory" ]; then
-        Directory="$wwwroot_dir"
-    fi
-    if [ ! -d "$Directory" ];then
-        echo "${CWARNING}The directory does not exist${CEND}"
-    else
-        break
-    fi
+  read -p "Please input the directory(Default directory: $wwwroot_dir): " Directory
+  if [ -z "$Directory" ]; then
+    Directory="$wwwroot_dir"
+  fi
+  if [ ! -d "$Directory" ]; then
+    echo "${CWARNING}The directory does not exist${CEND}"
+  else
+    break
+  fi
 done
 done
 }
 }
 
 
 while :; do
 while :; do
-    printf "
+  printf "
 What Are You Doing?
 What Are You Doing?
 \t${CMSG}1${CEND}. UserAdd
 \t${CMSG}1${CEND}. UserAdd
 \t${CMSG}2${CEND}. UserMod
 \t${CMSG}2${CEND}. UserMod
@@ -82,83 +82,83 @@ What Are You Doing?
 \t${CMSG}6${CEND}. ShowUser
 \t${CMSG}6${CEND}. ShowUser
 \t${CMSG}q${CEND}. Exit
 \t${CMSG}q${CEND}. Exit
 "
 "
-    read -p "Please input the correct option: " Number
-    if [[ ! $Number =~ ^[1-6,q]$ ]];then
-        echo "${CFAILURE}input error! Please only input 1 ~ 6 and q${CEND}"
-    else
-        case "$Number" in
-        1)
-            USER
-            [ -e "$Passwdfile" ] && [ -n "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] is already existed! ${CEND}"; continue; }
-            PASSWORD;DIRECTORY
-            $FTP_bin useradd $User -f $Passwdfile -u $run_user -g $run_user -d $Directory -m < $FTP_tmp_passfile
-            $FTP_bin mkdb $Puredbfile -f $Passwdfile > /dev/null 2>&1
-            echo "#####################################"
-            echo
-            echo "[$User] create successful! "
-            echo
-            echo "You user name is : ${CMSG}$User${CEND}"
-            echo "You Password is : ${CMSG}$Password${CEND}"
-            echo "You directory is : ${CMSG}$Directory${CEND}"
-            echo
-            ;;
-        2)
-            USER
-            [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] was not existed! ${CEND}"; continue; }
-            DIRECTORY
-            $FTP_bin usermod $User -f $Passwdfile -d $Directory -m
-            $FTP_bin mkdb $Puredbfile -f $Passwdfile > /dev/null 2>&1
-            echo "#####################################"
-            echo
-            echo "[$User] modify a successful! "
-            echo
-            echo "You user name is : ${CMSG}$User${CEND}"
-            echo "You new directory is : ${CMSG}$Directory${CEND}"
-            echo
-            ;;
-        3)
-            USER
-            [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] was not existed! ${CEND}"; continue; }
-            PASSWORD
-            $FTP_bin passwd $User -f $Passwdfile -m < $FTP_tmp_passfile
-            $FTP_bin mkdb $Puredbfile -f $Passwdfile > /dev/null 2>&1
-            echo "#####################################"
-            echo
-            echo "[$User] Password changed successfully! "
-            echo
-            echo "You user name is : ${CMSG}$User${CEND}"
-            echo "You new password is : ${CMSG}$Password${CEND}"
-            echo
-            ;;
-        4)
-            if [ ! -e "$Passwdfile" ];then
-                echo "${CQUESTION}User was not existed! ${CEND}"
-            else
-                $FTP_bin list
-            fi
+  read -p "Please input the correct option: " Number
+  if [[ ! $Number =~ ^[1-6,q]$ ]]; then
+    echo "${CFAILURE}input error! Please only input 1 ~ 6 and q${CEND}"
+  else
+    case "$Number" in
+    1)
+      USER
+      [ -e "$Passwdfile" ] && [ -n "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] is already existed! ${CEND}"; continue; }
+      PASSWORD;DIRECTORY
+      $FTP_bin useradd $User -f $Passwdfile -u $run_user -g $run_user -d $Directory -m < $FTP_tmp_passfile
+      $FTP_bin mkdb $Puredbfile -f $Passwdfile > /dev/null 2>&1
+      echo "#####################################"
+      echo
+      echo "[$User] create successful! "
+      echo
+      echo "You user name is : ${CMSG}$User${CEND}"
+      echo "You Password is : ${CMSG}$Password${CEND}"
+      echo "You directory is : ${CMSG}$Directory${CEND}"
+      echo
+      ;;
+    2)
+      USER
+      [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] was not existed! ${CEND}"; continue; }
+      DIRECTORY
+      $FTP_bin usermod $User -f $Passwdfile -d $Directory -m
+      $FTP_bin mkdb $Puredbfile -f $Passwdfile > /dev/null 2>&1
+      echo "#####################################"
+      echo
+      echo "[$User] modify a successful! "
+      echo
+      echo "You user name is : ${CMSG}$User${CEND}"
+      echo "You new directory is : ${CMSG}$Directory${CEND}"
+      echo
+      ;;
+    3)
+      USER
+      [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] was not existed! ${CEND}"; continue; }
+      PASSWORD
+      $FTP_bin passwd $User -f $Passwdfile -m < $FTP_tmp_passfile
+      $FTP_bin mkdb $Puredbfile -f $Passwdfile > /dev/null 2>&1
+      echo "#####################################"
+      echo
+      echo "[$User] Password changed successfully! "
+      echo
+      echo "You user name is : ${CMSG}$User${CEND}"
+      echo "You new password is : ${CMSG}$Password${CEND}"
+      echo
+      ;;
+    4)
+      if [ ! -e "$Passwdfile" ]; then
+        echo "${CQUESTION}User was not existed! ${CEND}"
+      else
+        $FTP_bin list
+      fi
 
 
-            USER
-            [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] was not existed! ${CEND}"; continue; }
-            $FTP_bin userdel $User -f $Passwdfile -m
-            $FTP_bin mkdb $Puredbfile -f $Passwdfile > /dev/null 2>&1
-            echo
-            echo "[$User] have been deleted! "
-            ;;
-        5)
-            if [ ! -e "$Passwdfile" ];then
-                echo "${CQUESTION}User was not existed! ${CEND}"
-            else
-                $FTP_bin list
-            fi
-            ;;
-        6)
-            USER
-            [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] was not existed! ${CEND}"; continue; }
-            $FTP_bin show $User
-            ;;
-        q)
-            exit
-            ;;
-        esac
-    fi
+      USER
+      [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] was not existed! ${CEND}"; continue; }
+      $FTP_bin userdel $User -f $Passwdfile -m
+      $FTP_bin mkdb $Puredbfile -f $Passwdfile > /dev/null 2>&1
+      echo
+      echo "[$User] have been deleted! "
+      ;;
+    5)
+      if [ ! -e "$Passwdfile" ]; then
+        echo "${CQUESTION}User was not existed! ${CEND}"
+      else
+        $FTP_bin list
+      fi
+      ;;
+    6)
+      USER
+      [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] was not existed! ${CEND}"; continue; }
+      $FTP_bin show $User
+      ;;
+    q)
+      exit
+      ;;
+    esac
+  fi
 done
 done

+ 11 - 11
reset_db_root_password.sh

@@ -27,25 +27,25 @@ printf "
 
 
 Reset_db_root_password()
 Reset_db_root_password()
 {
 {
-[ ! -d "$db_install_dir" ] && { echo "${CFAILURE}Database is not installed on your system! ${CEND}"; exit 1; }
-while :; do echo
+  [ ! -d "$db_install_dir" ] && { echo "${CFAILURE}Database is not installed on your system! ${CEND}"; exit 1; }
+  while :; do echo
     read -p "Please input the root password of database: " New_dbrootpwd
     read -p "Please input the root password of database: " New_dbrootpwd
     [ -n "`echo $New_dbrootpwd | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and &${CEND}"; continue; }
     [ -n "`echo $New_dbrootpwd | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and &${CEND}"; continue; }
     (( ${#New_dbrootpwd} >= 5 )) && break || echo "${CWARNING}database root password least 5 characters! ${CEND}"
     (( ${#New_dbrootpwd} >= 5 )) && break || echo "${CWARNING}database root password least 5 characters! ${CEND}"
-done
-
-$db_install_dir/bin/mysqladmin -uroot -p"$dbrootpwd" password "$New_dbrootpwd" -h localhost > /dev/null 2>&1
-status_Localhost=`echo $?`
-$db_install_dir/bin/mysqladmin -uroot -p"$dbrootpwd" password "$New_dbrootpwd" -h 127.0.0.1 > /dev/null 2>&1
-status_127=`echo $?`
-if [ $status_Localhost == '0' -a $status_127 == '0' ]; then
+  done
+  
+  $db_install_dir/bin/mysqladmin -uroot -p"$dbrootpwd" password "$New_dbrootpwd" -h localhost > /dev/null 2>&1
+  status_Localhost=`echo $?`
+  $db_install_dir/bin/mysqladmin -uroot -p"$dbrootpwd" password "$New_dbrootpwd" -h 127.0.0.1 > /dev/null 2>&1
+  status_127=`echo $?`
+  if [ $status_Localhost == '0' -a $status_127 == '0' ]; then
     sed -i "s+^dbrootpwd.*+dbrootpwd='$New_dbrootpwd'+" ./options.conf
     sed -i "s+^dbrootpwd.*+dbrootpwd='$New_dbrootpwd'+" ./options.conf
     echo
     echo
     echo "Password reset succesfully! "
     echo "Password reset succesfully! "
     echo "The new password: ${CMSG}${New_dbrootpwd}${CEND}"
     echo "The new password: ${CMSG}${New_dbrootpwd}${CEND}"
     echo
     echo
-else
+  else
     echo "${CFAILURE}Reset Database root password failed! ${CEND}"
     echo "${CFAILURE}Reset Database root password failed! ${CEND}"
-fi
+  fi
 }
 }
 Reset_db_root_password
 Reset_db_root_password

+ 145 - 146
shadowsocks.sh

@@ -19,7 +19,7 @@ printf "
 #######################################################################
 #######################################################################
 "
 "
 
 
-cd src
+pushd src > /dev/null
 . ../options.conf
 . ../options.conf
 . ../include/color.sh
 . ../include/color.sh
 . ../include/check_os.sh
 . ../include/check_os.sh
@@ -33,186 +33,185 @@ PUBLIC_IPADDR=`../include/get_public_ipaddr.py`
 [ "$CentOS_RHEL_version" == '5' ] && { echo "${CWARNING}Shadowsocks only support CentOS6,7 or Debian or Ubuntu! ${CEND}"; exit 1; }
 [ "$CentOS_RHEL_version" == '5' ] && { echo "${CWARNING}Shadowsocks only support CentOS6,7 or Debian or Ubuntu! ${CEND}"; exit 1; }
 
 
 Check_shadowsocks() {
 Check_shadowsocks() {
-    [ -f /usr/local/bin/ss-server ] && SS_version=1
-    [ -f /usr/bin/ssserver -o -f /usr/local/bin/ssserver ] && SS_version=2
+  [ -f /usr/local/bin/ss-server ] && SS_version=1
+  [ -f /usr/bin/ssserver -o -f /usr/local/bin/ssserver ] && SS_version=2
 }
 }
 
 
 AddUser_shadowsocks() {
 AddUser_shadowsocks() {
-while :; do echo
+  while :; do echo
     read -p "Please input password for shadowsocks: " Shadowsocks_password
     read -p "Please input password for shadowsocks: " Shadowsocks_password
     [ -n "`echo $Shadowsocks_password | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and & ${CEND}"; continue; }
     [ -n "`echo $Shadowsocks_password | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and & ${CEND}"; continue; }
     (( ${#Shadowsocks_password} >= 5 )) && break || echo "${CWARNING}Shadowsocks password least 5 characters! ${CEND}"
     (( ${#Shadowsocks_password} >= 5 )) && break || echo "${CWARNING}Shadowsocks password least 5 characters! ${CEND}"
-done
+  done
 }
 }
 
 
 Iptables_set() {
 Iptables_set() {
-if [ -e '/etc/sysconfig/iptables' ];then
+  if [ -e '/etc/sysconfig/iptables' ]; then
     Shadowsocks_Already_port=`grep -oE '9[0-9][0-9][0-9]' /etc/sysconfig/iptables | head -n 1`
     Shadowsocks_Already_port=`grep -oE '9[0-9][0-9][0-9]' /etc/sysconfig/iptables | head -n 1`
-elif [ -e '/etc/iptables.up.rules' ];then
+  elif [ -e '/etc/iptables.up.rules' ]; then
     Shadowsocks_Already_port=`grep -oE '9[0-9][0-9][0-9]' /etc/iptables.up.rules | head -n 1`
     Shadowsocks_Already_port=`grep -oE '9[0-9][0-9][0-9]' /etc/iptables.up.rules | head -n 1`
-fi
-
-if [ -n "$Shadowsocks_Already_port" ];then
+  fi
+  
+  if [ -n "$Shadowsocks_Already_port" ]; then
     Shadowsocks_Default_port=`expr $Shadowsocks_Already_port + 1`
     Shadowsocks_Default_port=`expr $Shadowsocks_Already_port + 1`
-else
+  else
     Shadowsocks_Default_port=9001
     Shadowsocks_Default_port=9001
-fi
-
-while :; do echo
+  fi
+  
+  while :; do echo
     read -p "Please input Shadowsocks port(Default: $Shadowsocks_Default_port): " Shadowsocks_port
     read -p "Please input Shadowsocks port(Default: $Shadowsocks_Default_port): " Shadowsocks_port
     [ -z "$Shadowsocks_port" ] && Shadowsocks_port=$Shadowsocks_Default_port
     [ -z "$Shadowsocks_port" ] && Shadowsocks_port=$Shadowsocks_Default_port
-    if [ $Shadowsocks_port -ge 1 >/dev/null 2>&1 -a $Shadowsocks_port -le 65535 >/dev/null 2>&1 ];then
-        [ -z "`netstat -an | grep :$Shadowsocks_port`" ] && break || echo "${CWARNING}This port is already used! ${CEND}"
+    if [ $Shadowsocks_port -ge 1 >/dev/null 2>&1 -a $Shadowsocks_port -le 65535 >/dev/null 2>&1 ]; then
+      [ -z "`netstat -an | grep :$Shadowsocks_port`" ] && break || echo "${CWARNING}This port is already used! ${CEND}"
     else
     else
-        echo "${CWARNING}input error! Input range: 1~65535${CEND}"
+      echo "${CWARNING}input error! Input range: 1~65535${CEND}"
     fi
     fi
-done
-
-if [ "$OS" == 'CentOS' ];then
-    if [ -z "`grep -E $Shadowsocks_port /etc/sysconfig/iptables`" ];then
-        iptables -I INPUT 4 -p udp -m state --state NEW -m udp --dport $Shadowsocks_port -j ACCEPT
-        iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport $Shadowsocks_port -j ACCEPT
-        service iptables save
+  done
+  
+  if [ "$OS" == 'CentOS' ]; then
+    if [ -z "`grep -E $Shadowsocks_port /etc/sysconfig/iptables`" ]; then
+      iptables -I INPUT 4 -p udp -m state --state NEW -m udp --dport $Shadowsocks_port -j ACCEPT
+      iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport $Shadowsocks_port -j ACCEPT
+      service iptables save
     fi
     fi
-elif [[ $OS =~ ^Ubuntu$|^Debian$ ]];then
-    if [ -z "`grep -E $Shadowsocks_port /etc/iptables.up.rules`" ];then
-        iptables -I INPUT 4 -p udp -m state --state NEW -m udp --dport $Shadowsocks_port -j ACCEPT
-        iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport $Shadowsocks_port -j ACCEPT
-        iptables-save > /etc/iptables.up.rules
+  elif [[ $OS =~ ^Ubuntu$|^Debian$ ]]; then
+    if [ -z "`grep -E $Shadowsocks_port /etc/iptables.up.rules`" ]; then
+      iptables -I INPUT 4 -p udp -m state --state NEW -m udp --dport $Shadowsocks_port -j ACCEPT
+      iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport $Shadowsocks_port -j ACCEPT
+      iptables-save > /etc/iptables.up.rules
     fi
     fi
-else
+  else
     echo "${CWARNING}This port is already in iptables! ${CEND}"
     echo "${CWARNING}This port is already in iptables! ${CEND}"
-fi
-
+  fi
 }
 }
 
 
 Def_parameter() {
 Def_parameter() {
-if [ "$OS" == 'CentOS' ]; then
+  if [ "$OS" == 'CentOS' ]; then
     while :; do echo
     while :; do echo
-        echo 'Please select Shadowsocks server version:'
-        echo -e "\t${CMSG}1${CEND}. Install Shadowsocks-libev"
-        echo -e "\t${CMSG}2${CEND}. Install Shadowsocks-python"
-        read -p "Please input a number:(Default 1 press Enter) " SS_version
-        [ -z "$SS_version" ] && SS_version=1
-        if [[ ! $SS_version =~ ^[1-2]$ ]];then
-            echo "${CWARNING}input error! Please only input number 1,2${CEND}"
-        else
-            break
-        fi
+      echo 'Please select Shadowsocks server version:'
+      echo -e "\t${CMSG}1${CEND}. Install Shadowsocks-libev"
+      echo -e "\t${CMSG}2${CEND}. Install Shadowsocks-python"
+      read -p "Please input a number:(Default 1 press Enter) " SS_version
+      [ -z "$SS_version" ] && SS_version=1
+      if [[ ! $SS_version =~ ^[1-2]$ ]]; then
+        echo "${CWARNING}input error! Please only input number 1,2${CEND}"
+      else
+        break
+      fi
     done
     done
     AddUser_shadowsocks
     AddUser_shadowsocks
     Iptables_set
     Iptables_set
     for Package in wget unzip openssl-devel gcc swig python python-devel python-setuptools autoconf libtool libevent automake make curl curl-devel zlib-devel perl perl-devel cpio expat-devel gettext-devel git asciidoc xmlto
     for Package in wget unzip openssl-devel gcc swig python python-devel python-setuptools autoconf libtool libevent automake make curl curl-devel zlib-devel perl perl-devel cpio expat-devel gettext-devel git asciidoc xmlto
     do
     do
-        yum -y install $Package
+      yum -y install $Package
     done
     done
-elif [[ $OS =~ ^Ubuntu$|^Debian$ ]];then
+  elif [[ $OS =~ ^Ubuntu$|^Debian$ ]]; then
     SS_version=2
     SS_version=2
     AddUser_shadowsocks
     AddUser_shadowsocks
     Iptables_set
     Iptables_set
     apt-get -y update
     apt-get -y update
     for Package in python-dev python-pip curl wget unzip gcc swig automake make perl cpio git
     for Package in python-dev python-pip curl wget unzip gcc swig automake make perl cpio git
     do
     do
-        apt-get -y install $Package
+      apt-get -y install $Package
     done
     done
-fi
+  fi
 }
 }
 
 
 Install_shadowsocks-python() {
 Install_shadowsocks-python() {
-src_url=http://mirrors.linuxeye.com/oneinstack/src/ez_setup.py && Download_src
-
-which pip > /dev/null 2>&1
-[ $? -ne 0 ] && [ "$OS" == 'CentOS' ] && { python ez_setup.py install; sleep 1; easy_install pip; }
-
-if [ -f /usr/bin/pip ]; then
+  src_url=http://mirrors.linuxeye.com/oneinstack/src/ez_setup.py && Download_src
+  
+  which pip > /dev/null 2>&1
+  [ $? -ne 0 ] && [ "$OS" == 'CentOS' ] && { python ez_setup.py install; sleep 1; easy_install pip; }
+  
+  if [ -f /usr/bin/pip ]; then
     pip install M2Crypto
     pip install M2Crypto
     pip install greenlet
     pip install greenlet
     pip install gevent
     pip install gevent
     pip install shadowsocks
     pip install shadowsocks
     if [ -f /usr/bin/ssserver -o -f /usr/local/bin/ssserver ]; then
     if [ -f /usr/bin/ssserver -o -f /usr/local/bin/ssserver ]; then
-        /bin/cp ../init.d/Shadowsocks-python-init /etc/init.d/shadowsocks
-        chmod +x /etc/init.d/shadowsocks
-        [ "$OS" == 'CentOS' ] && { chkconfig --add shadowsocks; chkconfig shadowsocks on; }
-        [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d shadowsocks defaults
-        [ ! -e /usr/bin/ssserver -a -e /usr/local/bin/ssserver ] && sed -i 's@Shadowsocks_bin=.*@Shadowsocks_bin=/usr/local/bin/ssserver@' /etc/init.d/shadowsocks
+      /bin/cp ../init.d/Shadowsocks-python-init /etc/init.d/shadowsocks
+      chmod +x /etc/init.d/shadowsocks
+      [ "$OS" == 'CentOS' ] && { chkconfig --add shadowsocks; chkconfig shadowsocks on; }
+      [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d shadowsocks defaults
+      [ ! -e /usr/bin/ssserver -a -e /usr/local/bin/ssserver ] && sed -i 's@Shadowsocks_bin=.*@Shadowsocks_bin=/usr/local/bin/ssserver@' /etc/init.d/shadowsocks
     else
     else
-        echo
-        echo "${CQUESTION}Shadowsocks-python install failed! Please visit https://oneinstack.com${CEND}"
-        exit 1
+      echo
+      echo "${CQUESTION}Shadowsocks-python install failed! Please visit https://oneinstack.com${CEND}"
+      exit 1
     fi
     fi
-fi
+  fi
 }
 }
 
 
 Install_shadowsocks-libev() {
 Install_shadowsocks-libev() {
-git clone https://github.com/shadowsocks/shadowsocks-libev.git
-cd shadowsocks-libev
-./configure
-make -j ${THREAD} && make install
-cd ..
-if [ -f  /usr/local/bin/ss-server ];then
+  git clone https://github.com/shadowsocks/shadowsocks-libev.git
+  pushd shadowsocks-libev
+  ./configure
+  make -j ${THREAD} && make install
+  popd
+  if [ -f  /usr/local/bin/ss-server ]; then
     /bin/cp ../init.d/Shadowsocks-libev-init /etc/init.d/shadowsocks
     /bin/cp ../init.d/Shadowsocks-libev-init /etc/init.d/shadowsocks
     chmod +x /etc/init.d/shadowsocks
     chmod +x /etc/init.d/shadowsocks
     [ "$OS" == 'CentOS' ] && { chkconfig --add shadowsocks; chkconfig shadowsocks on; }
     [ "$OS" == 'CentOS' ] && { chkconfig --add shadowsocks; chkconfig shadowsocks on; }
-else
-   echo
-   echo "${CQUESTION}Shadowsocks-libev install failed! Please visit https://oneinstack.com${CEND}"
-   exit 1
-fi
+  else
+    echo
+    echo "${CQUESTION}Shadowsocks-libev install failed! Please visit https://oneinstack.com${CEND}"
+    exit 1
+  fi
 
 
 }
 }
 
 
 Uninstall_shadowsocks(){
 Uninstall_shadowsocks(){
-while :; do echo
+  while :; do echo
     read -p "Do you want to uninstall Shadowsocks? [y/n]: " Shadowsocks_yn
     read -p "Do you want to uninstall Shadowsocks? [y/n]: " Shadowsocks_yn
-    if [[ ! $Shadowsocks_yn =~ ^[y,n]$ ]];then
-        echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+    if [[ ! $Shadowsocks_yn =~ ^[y,n]$ ]]; then
+      echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
     else
     else
-        break
+      break
     fi
     fi
-done
-
-if [ "$Shadowsocks_yn" == 'y' ]; then
+  done
+  
+  if [ "$Shadowsocks_yn" == 'y' ]; then
     [ -n "`ps -ef | grep -v grep | grep -iE "ssserver|ss-server"`" ] && /etc/init.d/shadowsocks stop
     [ -n "`ps -ef | grep -v grep | grep -iE "ssserver|ss-server"`" ] && /etc/init.d/shadowsocks stop
     [ "$OS" == 'CentOS' ] && chkconfig --del shadowsocks
     [ "$OS" == 'CentOS' ] && chkconfig --del shadowsocks
     [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d -f shadowsocks remove
     [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d -f shadowsocks remove
     rm -rf /etc/shadowsocks /var/run/shadowsocks.pid /etc/init.d/shadowsocks
     rm -rf /etc/shadowsocks /var/run/shadowsocks.pid /etc/init.d/shadowsocks
-    if [ "$SS_version" == '1' ];then
-        rm -f /usr/local/bin/ss-local
-        rm -f /usr/local/bin/ss-tunnel
-        rm -f /usr/local/bin/ss-server
-        rm -f /usr/local/bin/ss-manager
-        rm -f /usr/local/bin/ss-redir
-        rm -f /usr/local/lib/libshadowsocks.a
-        rm -f /usr/local/lib/libshadowsocks.la
-        rm -f /usr/local/include/shadowsocks.h
-        rm -f /usr/local/lib/pkgconfig/shadowsocks-libev.pc
-        rm -f /usr/local/share/man/man1/ss-local.1
-        rm -f /usr/local/share/man/man1/ss-tunnel.1
-        rm -f /usr/local/share/man/man1/ss-server.1
-        rm -f /usr/local/share/man/man1/ss-manager.1
-        rm -f /usr/local/share/man/man1/ss-redir.1
-        rm -f /usr/local/share/man/man8/shadowsocks.8
-        if [ $? -eq 0 ]; then
-            echo "${CSUCCESS}Shadowsocks-libev uninstall success! ${CEND}"
-        else
-            echo "${CFAILURE}Shadowsocks-libev uninstall failed! ${CEND}"
-        fi
-    elif [ "$SS_version" == '2' ];then
-        pip uninstall -y shadowsocks
-        if [ $? -eq 0 ]; then
-            echo "${CSUCCESS}Shadowsocks-python uninstall success! ${CEND}"
-        else
-            echo "${CFAILURE}Shadowsocks-python uninstall failed! ${CEND}"
-        fi
+    if [ "$SS_version" == '1' ]; then
+      rm -f /usr/local/bin/ss-local
+      rm -f /usr/local/bin/ss-tunnel
+      rm -f /usr/local/bin/ss-server
+      rm -f /usr/local/bin/ss-manager
+      rm -f /usr/local/bin/ss-redir
+      rm -f /usr/local/lib/libshadowsocks.a
+      rm -f /usr/local/lib/libshadowsocks.la
+      rm -f /usr/local/include/shadowsocks.h
+      rm -f /usr/local/lib/pkgconfig/shadowsocks-libev.pc
+      rm -f /usr/local/share/man/man1/ss-local.1
+      rm -f /usr/local/share/man/man1/ss-tunnel.1
+      rm -f /usr/local/share/man/man1/ss-server.1
+      rm -f /usr/local/share/man/man1/ss-manager.1
+      rm -f /usr/local/share/man/man1/ss-redir.1
+      rm -f /usr/local/share/man/man8/shadowsocks.8
+      if [ $? -eq 0 ]; then
+        echo "${CSUCCESS}Shadowsocks-libev uninstall success! ${CEND}"
+      else
+        echo "${CFAILURE}Shadowsocks-libev uninstall failed! ${CEND}"
+      fi
+    elif [ "$SS_version" == '2' ]; then
+      pip uninstall -y shadowsocks
+      if [ $? -eq 0 ]; then
+        echo "${CSUCCESS}Shadowsocks-python uninstall success! ${CEND}"
+      else
+        echo "${CFAILURE}Shadowsocks-python uninstall failed! ${CEND}"
+      fi
     fi
     fi
-else
+  else
     echo "${CMSG}Shadowsocks uninstall cancelled! ${CEND}"
     echo "${CMSG}Shadowsocks uninstall cancelled! ${CEND}"
-fi
+  fi
 }
 }
 
 
 Config_shadowsocks(){
 Config_shadowsocks(){
-[ ! -d '/etc/shadowsocks' ] && mkdir /etc/shadowsocks
-[ "$SS_version" == '1' ] && cat > /etc/shadowsocks/config.json<<EOF
+  [ ! -d '/etc/shadowsocks' ] && mkdir /etc/shadowsocks
+  [ "$SS_version" == '1' ] && cat > /etc/shadowsocks/config.json<<EOF
 {
 {
     "server":"0.0.0.0",
     "server":"0.0.0.0",
     "server_port":$Shadowsocks_port,
     "server_port":$Shadowsocks_port,
@@ -224,7 +223,7 @@ Config_shadowsocks(){
 }
 }
 EOF
 EOF
 
 
-[ "$SS_version" == '2' ] && cat > /etc/shadowsocks/config.json<<EOF
+  [ "$SS_version" == '2' ] && cat > /etc/shadowsocks/config.json<<EOF
 {
 {
     "server":"0.0.0.0",
     "server":"0.0.0.0",
     "local_address":"127.0.0.1",
     "local_address":"127.0.0.1",
@@ -240,12 +239,12 @@ EOF
 }
 }
 
 
 AddUser_Config_shadowsocks(){
 AddUser_Config_shadowsocks(){
-[ ! -e /etc/shadowsocks/config.json ] && { echo "${CFAILURE}Shadowsocks is not installed! ${CEND}"; exit 1; }
-[ -z "`grep \"$Shadowsocks_port\" /etc/shadowsocks/config.json`" ] && sed -i "s@\"port_password\":{@\"port_password\":{\n\t\"$Shadowsocks_port\":\"$Shadowsocks_password\",@" /etc/shadowsocks/config.json || { echo "${CWARNING}This port is already in /etc/shadowsocks/config.json${CEND}"; exit 1; }
+  [ ! -e /etc/shadowsocks/config.json ] && { echo "${CFAILURE}Shadowsocks is not installed! ${CEND}"; exit 1; }
+  [ -z "`grep \"$Shadowsocks_port\" /etc/shadowsocks/config.json`" ] && sed -i "s@\"port_password\":{@\"port_password\":{\n\t\"$Shadowsocks_port\":\"$Shadowsocks_password\",@" /etc/shadowsocks/config.json || { echo "${CWARNING}This port is already in /etc/shadowsocks/config.json${CEND}"; exit 1; }
 }
 }
 
 
 Print_User_shadowsocks(){
 Print_User_shadowsocks(){
-printf "
+  printf "
 Your Server IP: ${CMSG}$PUBLIC_IPADDR${CEND}
 Your Server IP: ${CMSG}$PUBLIC_IPADDR${CEND}
 Your Server Port: ${CMSG}$Shadowsocks_port${CEND}
 Your Server Port: ${CMSG}$Shadowsocks_port${CEND}
 Your Password: ${CMSG}$Shadowsocks_password${CEND}
 Your Password: ${CMSG}$Shadowsocks_password${CEND}
@@ -257,37 +256,37 @@ Your Encryption Method: ${CMSG}aes-256-cfb${CEND}
 
 
 case "$1" in
 case "$1" in
 install)
 install)
-    Def_parameter
-    [ "$SS_version" == '1' ] && Install_shadowsocks-libev
-    [ "$SS_version" == '2' ] && Install_shadowsocks-python
-    Config_shadowsocks
-    service shadowsocks start
-    Print_User_shadowsocks
-    ;;
+  Def_parameter
+  [ "$SS_version" == '1' ] && Install_shadowsocks-libev
+  [ "$SS_version" == '2' ] && Install_shadowsocks-python
+  Config_shadowsocks
+  service shadowsocks start
+  Print_User_shadowsocks
+  ;;
 adduser)
 adduser)
-    Check_shadowsocks
-    if [ "$SS_version" == '2' ];then
-        AddUser_shadowsocks
-        Iptables_set
-        AddUser_Config_shadowsocks
-        service shadowsocks restart
-        Print_User_shadowsocks
-    else
-        printf "
-        Sorry, we have no plan to support multi port configuration. Actually you can use multiple instances instead. For example:
-        ss-server -c /etc/shadowsocks/config1.json -f /var/run/shadowsocks-server/pid1
-        ss-server -c /etc/shadowsocks/config2.json -f /var/run/shadowsocks-server/pid2
-        ss-server -c /etc/shadowsocks/config3.json -f /var/run/shadowsocks-server/pid3
-        "
-    fi
-    ;;
+  Check_shadowsocks
+  if [ "$SS_version" == '2' ]; then
+    AddUser_shadowsocks
+    Iptables_set
+    AddUser_Config_shadowsocks
+    service shadowsocks restart
+    Print_User_shadowsocks
+  else
+    printf "
+    Sorry, we have no plan to support multi port configuration. Actually you can use multiple instances instead. For example:
+    ss-server -c /etc/shadowsocks/config1.json -f /var/run/shadowsocks-server/pid1
+    ss-server -c /etc/shadowsocks/config2.json -f /var/run/shadowsocks-server/pid2
+    ss-server -c /etc/shadowsocks/config3.json -f /var/run/shadowsocks-server/pid3
+    "
+  fi
+  ;;
 uninstall)
 uninstall)
-    Check_shadowsocks
-    Uninstall_shadowsocks
-    ;;
+  Check_shadowsocks
+  Uninstall_shadowsocks
+  ;;
 *)
 *)
-    echo
-    echo $"Usage: ${CMSG}$0${CEND} { ${CMSG}install${CEND} | ${CMSG}adduser${CEND} | ${CMSG}uninstall${CEND} }"
-    echo
-    exit 1
+  echo
+  echo $"Usage: ${CMSG}$0${CEND} { ${CMSG}install${CEND} | ${CMSG}adduser${CEND} | ${CMSG}uninstall${CEND} }"
+  echo
+  exit 1
 esac
 esac

+ 216 - 216
uninstall.sh

@@ -28,7 +28,7 @@ printf "
 
 
 
 
 Usage(){
 Usage(){
-printf "
+  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} ]
 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}all${CEND}            --->Uninstall All
 ${CMSG}web${CEND}            --->Uninstall Nginx/Tengine/Apache/Tomcat
 ${CMSG}web${CEND}            --->Uninstall Nginx/Tengine/Apache/Tomcat
@@ -43,136 +43,136 @@ ${CMSG}memcached${CEND}      --->Uninstall Memcached
 }
 }
 
 
 Uninstall_status() {
 Uninstall_status() {
-while :; do echo
+  while :; do echo
     read -p "Do you want to uninstall? [y/n]: " uninstall_yn
     read -p "Do you want to uninstall? [y/n]: " uninstall_yn
     echo
     echo
-    if [[ ! $uninstall_yn =~ ^[y,n]$ ]];then
-        echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+    if [[ ! ${uninstall_yn} =~ ^[y,n]$ ]]; then
+      echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
     else
     else
-        break
+      break
     fi
     fi
-done
+  done
 }
 }
 
 
 Print_Warn() {
 Print_Warn() {
-echo
-echo "${CWARNING}You will uninstall OneinStack, Please backup your configure files and DB data! ${CEND}"
+  echo
+  echo "${CWARNING}You will uninstall OneinStack, Please backup your configure files and DB data! ${CEND}"
 }
 }
 
 
 Print_web() {
 Print_web() {
-[ -d "$nginx_install_dir" ] && echo "$nginx_install_dir"
-[ -d "$tengine_install_dir" ] && echo "$tengine_install_dir"
-[ -d "$openresty_install_dir" ] && echo "$openresty_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'
-[ -d "/usr/local/apr" ] && echo '/usr/local/apr'
+  [ -d "${nginx_install_dir}" ] && echo "${nginx_install_dir}"
+  [ -d "${tengine_install_dir}" ] && echo "${tengine_install_dir}"
+  [ -d "${openresty_install_dir}" ] && echo "${openresty_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'
+  [ -d "/usr/local/apr" ] && echo '/usr/local/apr'
 }
 }
 
 
 Uninstall_Web() {
 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 "$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; }
-[ -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; chmod +x /etc/logrotate.d/tomcat; rm -rf $tomcat_install_dir /etc/init.d/tomcat /etc/logrotate.d/tomcat /usr/local/apr; }
-[ -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
-echo "${CMSG}Web uninstall completed${CEND}"
+  [ -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 "${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; }
+  [ -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; chmod +x /etc/logrotate.d/tomcat; rm -rf ${tomcat_install_dir} /etc/init.d/tomcat /etc/logrotate.d/tomcat /usr/local/apr; }
+  [ -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
+  echo "${CMSG}Web uninstall completed${CEND}"
 }
 }
 
 
 Print_DB() {
 Print_DB() {
-[ -e "$db_install_dir" ] && echo "$db_install_dir"
-[ -e "/etc/init.d/mysqld" ] && echo "/etc/init.d/mysqld"
-[ -e "/etc/my.cnf" ] && echo "/etc/my.cnf"
+  [ -e "${db_install_dir}" ] && echo "${db_install_dir}"
+  [ -e "/etc/init.d/mysqld" ] && echo "/etc/init.d/mysqld"
+  [ -e "/etc/my.cnf" ] && echo "/etc/my.cnf"
 }
 }
 
 
 Uninstall_DB() {
 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}"
+  [ -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() {
 Print_PHP() {
-[ -e "$php_install_dir" ] && echo "$php_install_dir"
-[ -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'
+  [ -e "${php_install_dir}" ] && echo "${php_install_dir}"
+  [ -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() {
 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}"
+  [ -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() {
 Print_HHVM() {
-[ -e "/usr/bin/hhvm" ] && echo "/usr/bin/hhvm"
-[ -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"
+  [ -e "/usr/bin/hhvm" ] && echo "/usr/bin/hhvm"
+  [ -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() {
 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}"
+  [ -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() {
 Print_PureFtpd() {
-[ -e "$pureftpd_install_dir" ] && echo "$pureftpd_install_dir"
-[ -e "/etc/init.d/pureftpd" ] && echo "/etc/init.d/pureftpd"
+  [ -e "$pureftpd_install_dir" ] && echo "$pureftpd_install_dir"
+  [ -e "/etc/init.d/pureftpd" ] && echo "/etc/init.d/pureftpd"
 }
 }
 
 
 Uninstall_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}"
+  [ -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() {
 Print_Redis() {
-[ -e "$redis_install_dir" ] && echo "$redis_install_dir"
-[ -e "/etc/init.d/redis-server" ] && echo "/etc/init.d/redis-server"
+  [ -e "$redis_install_dir" ] && echo "$redis_install_dir"
+  [ -e "/etc/init.d/redis-server" ] && echo "/etc/init.d/redis-server"
 }
 }
 
 
 Uninstall_Redis() {
 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-*; }
-[ -e "$php_install_dir/etc/php.d/ext-redis.ini" ] && rm -rf $php_install_dir/etc/php.d/ext-redis.ini
-echo "${CMSG}Redis uninstall completed${CEND}"
+  [ -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-*; }
+  [ -e "${php_install_dir}/etc/php.d/ext-redis.ini" ] && rm -rf ${php_install_dir}/etc/php.d/ext-redis.ini
+  echo "${CMSG}Redis uninstall completed${CEND}"
 }
 }
 
 
 Print_Memcached() {
 Print_Memcached() {
-[ -e "$memcached_install_dir" ] && echo "$memcached_install_dir"
-[ -e "/etc/init.d/memcached" ] && echo "/etc/init.d/memcached"
-[ -e "/usr/bin/memcached" ] && echo "/usr/bin/memcached"
+  [ -e "${memcached_install_dir}" ] && echo "${memcached_install_dir}"
+  [ -e "/etc/init.d/memcached" ] && echo "/etc/init.d/memcached"
+  [ -e "/usr/bin/memcached" ] && echo "/usr/bin/memcached"
 }
 }
 
 
 Uninstall_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; }
-[ -e "$php_install_dir/etc/php.d/ext-memcache.ini" ] && rm -rf $php_install_dir/etc/php.d/ext-memcache.ini
-[ -e "$php_install_dir/etc/php.d/ext-memcached.ini" ] && rm -rf $php_install_dir/etc/php.d/ext-memcached.ini
-echo "${CMSG}Memcached uninstall completed${CEND}"
+  [ -e "${memcached_install_dir}" ] && { service memcached stop > /dev/null 2>&1; rm -rf ${memcached_install_dir} /etc/init.d/memcached /usr/bin/memcached; }
+  [ -e "${php_install_dir}/etc/php.d/ext-memcache.ini" ] && rm -rf ${php_install_dir}/etc/php.d/ext-memcache.ini
+  [ -e "${php_install_dir}/etc/php.d/ext-memcached.ini" ] && rm -rf ${php_install_dir}/etc/php.d/ext-memcached.ini
+  echo "${CMSG}Memcached uninstall completed${CEND}"
 }
 }
 
 
 Menu(){
 Menu(){
 while :; do
 while :; do
-    printf "
+  printf "
 What Are You Doing?
 What Are You Doing?
 \t${CMSG}0${CEND}. Uninstall All
 \t${CMSG}0${CEND}. Uninstall All
 \t${CMSG}1${CEND}. Uninstall Nginx/Tengine/Apache/Tomcat
 \t${CMSG}1${CEND}. Uninstall Nginx/Tengine/Apache/Tomcat
@@ -184,148 +184,148 @@ What Are You Doing?
 \t${CMSG}7${CEND}. Uninstall Memcached
 \t${CMSG}7${CEND}. Uninstall Memcached
 \t${CMSG}q${CEND}. Exit
 \t${CMSG}q${CEND}. Exit
 "
 "
-    echo
-    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
-        case "$Number" in
-        0)
-            Print_Warn
-            Print_web
-            Print_DB
-            Print_PHP
-            Print_HHVM
-            Print_PureFtpd
-            Print_Redis
-            Print_Memcached
+  echo
+  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
+    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
+      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
 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
+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_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
+    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
     Usage
+    ;;
+  esac
+else
+  Usage
 fi
 fi

+ 53 - 62
upgrade.sh

@@ -41,7 +41,7 @@ PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
 IPADDR_COUNTRY=`./include/get_ipaddr_state.py $PUBLIC_IPADDR | awk '{print $1}'`
 IPADDR_COUNTRY=`./include/get_ipaddr_state.py $PUBLIC_IPADDR | awk '{print $1}'`
 
 
 Usage(){
 Usage(){
-printf "
+  printf "
 Usage: $0 [ ${CMSG}web${CEND} | ${CMSG}db${CEND} | ${CMSG}php${CEND} | ${CMSG}redis${CEND} | ${CMSG}phpmyadmin${CEND} ]
 Usage: $0 [ ${CMSG}web${CEND} | ${CMSG}db${CEND} | ${CMSG}php${CEND} | ${CMSG}redis${CEND} | ${CMSG}phpmyadmin${CEND} ]
 ${CMSG}web${CEND}            --->Upgrade Nginx/Tengine/OpenResty
 ${CMSG}web${CEND}            --->Upgrade Nginx/Tengine/OpenResty
 ${CMSG}db${CEND}             --->Upgrade MySQL/MariaDB/Percona
 ${CMSG}db${CEND}             --->Upgrade MySQL/MariaDB/Percona
@@ -53,7 +53,7 @@ ${CMSG}phpmyadmin${CEND}     --->Upgrade phpMyAdmin
 }
 }
 
 
 Menu(){
 Menu(){
-while :; do
+  while :; do
     printf "
     printf "
 What Are You Doing?
 What Are You Doing?
 \t${CMSG}1${CEND}. Upgrade Nginx/Tengine/OpenResty
 \t${CMSG}1${CEND}. Upgrade Nginx/Tengine/OpenResty
@@ -65,77 +65,68 @@ What Are You Doing?
 "
 "
     echo
     echo
     read -p "Please input the correct option: " Number
     read -p "Please input the correct option: " Number
-    if [[ ! $Number =~ ^[1-5,q]$ ]];then
-        echo "${CWARNING}input error! Please only input 1,2,3,4,5 and q${CEND}"
+    if [[ ! $Number =~ ^[1-5,q]$ ]]; then
+      echo "${CWARNING}input error! Please only input 1,2,3,4,5 and q${CEND}"
     else
     else
-        case "$Number" in
-        1)
-            if [ -e "$nginx_install_dir/sbin/nginx" ];then
-                Upgrade_Nginx
-            elif [ -e "$tengine_install_dir/sbin/nginx" ];then
-                Upgrade_Tengine
-            elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ];then
-                Upgrade_OpenResty
-            fi
-            ;;
-
-        2)
-            Upgrade_DB
-            ;;
-
-        3)
-            Upgrade_PHP
-            ;;
-        4)
-            Upgrade_Redis
-            ;;
-
-        5)
-            Upgrade_phpMyAdmin
-            ;;
-
-        q)
-            exit
-            ;;
-        esac
-    fi
-done
-}
-
-if [ $# == 0 ];then
-    Menu
-elif [ $# == 1 ];then
-    case $1 in
-    web)
-        if [ -e "$nginx_install_dir/sbin/nginx" ];then
-            Upgrade_Nginx
-        elif [ -e "$tengine_install_dir/sbin/nginx" ];then
-            Upgrade_Tengine
-        elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ];then
-            Upgrade_OpenResty
+      case "$Number" in
+      1)
+        if [ -e "$nginx_install_dir/sbin/nginx" ]; then
+          Upgrade_Nginx
+        elif [ -e "$tengine_install_dir/sbin/nginx" ]; then
+          Upgrade_Tengine
+        elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ]; then
+          Upgrade_OpenResty
         fi
         fi
         ;;
         ;;
-
-    db)
+      2)
         Upgrade_DB
         Upgrade_DB
         ;;
         ;;
-
-    php)
+      3)
         Upgrade_PHP
         Upgrade_PHP
         ;;
         ;;
-
-    redis)
+      4)
         Upgrade_Redis
         Upgrade_Redis
         ;;
         ;;
-
-    phpmyadmin)
+      5)
         Upgrade_phpMyAdmin
         Upgrade_phpMyAdmin
         ;;
         ;;
-
-    *)
-        Usage
+      q)
+        exit
         ;;
         ;;
-    esac
-else
+      esac
+    fi
+  done
+}
+
+if [ $# == 0 ]; then
+  Menu
+elif [ $# == 1 ]; then
+  case $1 in
+  web)
+    if [ -e "$nginx_install_dir/sbin/nginx" ]; then
+      Upgrade_Nginx
+    elif [ -e "$tengine_install_dir/sbin/nginx" ]; then
+      Upgrade_Tengine
+    elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ]; then
+      Upgrade_OpenResty
+    fi
+    ;;
+  db)
+    Upgrade_DB
+    ;;
+  php)
+    Upgrade_PHP
+    ;;
+  redis)
+    Upgrade_Redis
+    ;;
+  phpmyadmin)
+    Upgrade_phpMyAdmin
+    ;;
+  *)
     Usage
     Usage
+    ;;
+  esac
+else
+  Usage
 fi
 fi

+ 5 - 5
versions.txt

@@ -16,9 +16,9 @@ apr_version=1.5.2
 apr_util_version=1.5.4
 apr_util_version=1.5.4
 
 
 # DB
 # DB
-mysql_5_7_version=5.7.15
-mysql_5_6_version=5.6.33
-mysql_5_5_version=5.5.52
+mysql_5_7_version=5.7.16
+mysql_5_6_version=5.6.34
+mysql_5_5_version=5.5.53
 
 
 mariadb_10_1_version=10.1.18
 mariadb_10_1_version=10.1.18
 mariadb_10_0_version=10.0.27
 mariadb_10_0_version=10.0.27
@@ -44,14 +44,14 @@ zendopcache_version=7.0.5
 xcache_version=3.2.0
 xcache_version=3.2.0
 apcu_version=4.0.11
 apcu_version=4.0.11
 apcu_for_php7_version=5.1.6
 apcu_for_php7_version=5.1.6
-ImageMagick_version=6.9.6-0
+ImageMagick_version=6.9.6-2
 imagick_version=3.4.1
 imagick_version=3.4.1
 imagick_for_php53_version=3.3.0
 imagick_for_php53_version=3.3.0
 GraphicsMagick_version=1.3.25
 GraphicsMagick_version=1.3.25
 gmagick_for_php7_version=2.0.4RC1
 gmagick_for_php7_version=2.0.4RC1
 gmagick_version=1.1.7RC3
 gmagick_version=1.1.7RC3
 libiconv_version=1.14
 libiconv_version=1.14
-curl_version=7.35.0
+curl_version=7.50.3
 libmcrypt_version=2.5.8
 libmcrypt_version=2.5.8
 mcrypt_version=2.6.8
 mcrypt_version=2.6.8
 mhash_version=0.9.9.9
 mhash_version=0.9.9.9

+ 505 - 506
vhost.sh

@@ -27,7 +27,7 @@ printf "
 [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
 [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
 
 
 Usage() {
 Usage() {
-printf "
+  printf "
 Usage: $0 [ ${CMSG}add${CEND} | ${CMSG}del${CEND} ]
 Usage: $0 [ ${CMSG}add${CEND} | ${CMSG}del${CEND} ]
 ${CMSG}add${CEND}    --->Add Virtualhost
 ${CMSG}add${CEND}    --->Add Virtualhost
 ${CMSG}del${CEND}    --->Delete Virtualhost
 ${CMSG}del${CEND}    --->Delete Virtualhost
@@ -36,97 +36,97 @@ ${CMSG}del${CEND}    --->Delete Virtualhost
 }
 }
 
 
 Choose_env() {
 Choose_env() {
-if [ -e "$php_install_dir/bin/phpize" -a -e "$tomcat_install_dir/conf/server.xml" -a -e "/usr/bin/hhvm" ];then
+  if [ -e "$php_install_dir/bin/phpize" -a -e "$tomcat_install_dir/conf/server.xml" -a -e "/usr/bin/hhvm" ]; then
     Number=111
     Number=111
     while :; do echo
     while :; do echo
-        echo 'Please choose to use environment:'
-        echo -e "\t${CMSG}1${CEND}. Use php"
-        echo -e "\t${CMSG}2${CEND}. Use java"
-        echo -e "\t${CMSG}3${CEND}. Use hhvm"
-        read -p "Please input a number:(Default 1 press Enter) " Choose_number
-        [ -z "$Choose_number" ] && Choose_number=1
-        if [[ ! $Choose_number =~ ^[1-3]$ ]];then
-            echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
-        else
-            break
-        fi
+      echo 'Please choose to use environment:'
+      echo -e "\t${CMSG}1${CEND}. Use php"
+      echo -e "\t${CMSG}2${CEND}. Use java"
+      echo -e "\t${CMSG}3${CEND}. Use hhvm"
+      read -p "Please input a number:(Default 1 press Enter) " Choose_number
+      [ -z "$Choose_number" ] && Choose_number=1
+      if [[ ! $Choose_number =~ ^[1-3]$ ]]; then
+        echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
+      else
+        break
+      fi
     done
     done
     [ "$Choose_number" == '1' ] && NGX_FLAG=php
     [ "$Choose_number" == '1' ] && NGX_FLAG=php
     [ "$Choose_number" == '2' ] && NGX_FLAG=java
     [ "$Choose_number" == '2' ] && NGX_FLAG=java
     [ "$Choose_number" == '3' ] && NGX_FLAG=hhvm
     [ "$Choose_number" == '3' ] && NGX_FLAG=hhvm
-elif [ -e "$php_install_dir/bin/phpize" -a -e "$tomcat_install_dir/conf/server.xml" -a ! -e "/usr/bin/hhvm" ];then
+  elif [ -e "$php_install_dir/bin/phpize" -a -e "$tomcat_install_dir/conf/server.xml" -a ! -e "/usr/bin/hhvm" ]; then
     Number=110
     Number=110
     while :; do echo
     while :; do echo
-        echo 'Please choose to use environment:'
-        echo -e "\t${CMSG}1${CEND}. Use php"
-        echo -e "\t${CMSG}2${CEND}. Use java"
-        read -p "Please input a number:(Default 1 press Enter) " Choose_number
-        [ -z "$Choose_number" ] && Choose_number=1
-        if [[ ! $Choose_number =~ ^[1-2]$ ]];then
-            echo "${CWARNING}input error! Please only input number 1,2${CEND}"
-        else
-            break
-        fi
+      echo 'Please choose to use environment:'
+      echo -e "\t${CMSG}1${CEND}. Use php"
+      echo -e "\t${CMSG}2${CEND}. Use java"
+      read -p "Please input a number:(Default 1 press Enter) " Choose_number
+      [ -z "$Choose_number" ] && Choose_number=1
+      if [[ ! $Choose_number =~ ^[1-2]$ ]]; then
+        echo "${CWARNING}input error! Please only input number 1,2${CEND}"
+      else
+        break
+      fi
     done
     done
     [ "$Choose_number" == '1' ] && NGX_FLAG=php
     [ "$Choose_number" == '1' ] && NGX_FLAG=php
     [ "$Choose_number" == '2' ] && NGX_FLAG=java
     [ "$Choose_number" == '2' ] && NGX_FLAG=java
-elif [ -e "$php_install_dir/bin/phpize" -a ! -e "$tomcat_install_dir/conf/server.xml" -a ! -e "/usr/bin/hhvm" ];then
+  elif [ -e "$php_install_dir/bin/phpize" -a ! -e "$tomcat_install_dir/conf/server.xml" -a ! -e "/usr/bin/hhvm" ]; then
     Number=100
     Number=100
     NGX_FLAG=php
     NGX_FLAG=php
-elif [ -e "$php_install_dir/bin/phpize" -a ! -e "$tomcat_install_dir/conf/server.xml" -a -e "/usr/bin/hhvm" ];then
+  elif [ -e "$php_install_dir/bin/phpize" -a ! -e "$tomcat_install_dir/conf/server.xml" -a -e "/usr/bin/hhvm" ]; then
     Number=101
     Number=101
     while :; do echo
     while :; do echo
-        echo 'Please choose to use environment:'
-        echo -e "\t${CMSG}1${CEND}. Use php"
-        echo -e "\t${CMSG}2${CEND}. Use hhvm"
-        read -p "Please input a number:(Default 1 press Enter) " Choose_number
-        [ -z "$Choose_number" ] && Choose_number=1
-        if [[ ! $Choose_number =~ ^[1-2]$ ]];then
-            echo "${CWARNING}input error! Please only input number 1,2${CEND}"
-        else
-            break
-        fi
+      echo 'Please choose to use environment:'
+      echo -e "\t${CMSG}1${CEND}. Use php"
+      echo -e "\t${CMSG}2${CEND}. Use hhvm"
+      read -p "Please input a number:(Default 1 press Enter) " Choose_number
+      [ -z "$Choose_number" ] && Choose_number=1
+      if [[ ! $Choose_number =~ ^[1-2]$ ]]; then
+        echo "${CWARNING}input error! Please only input number 1,2${CEND}"
+      else
+        break
+      fi
     done
     done
     [ "$Choose_number" == '1' ] && NGX_FLAG=php
     [ "$Choose_number" == '1' ] && NGX_FLAG=php
     [ "$Choose_number" == '2' ] && NGX_FLAG=hhvm
     [ "$Choose_number" == '2' ] && NGX_FLAG=hhvm
-elif [ ! -e "$php_install_dir/bin/phpize" -a -e "$tomcat_install_dir/conf/server.xml" -a -e "/usr/bin/hhvm" ];then
+  elif [ ! -e "$php_install_dir/bin/phpize" -a -e "$tomcat_install_dir/conf/server.xml" -a -e "/usr/bin/hhvm" ]; then
     Number=011
     Number=011
     while :; do echo
     while :; do echo
-        echo 'Please choose to use environment:'
-        echo -e "\t${CMSG}1${CEND}. Use java"
-        echo -e "\t${CMSG}2${CEND}. Use hhvm"
-        read -p "Please input a number:(Default 1 press Enter) " Choose_number
-        [ -z "$Choose_number" ] && Choose_number=1
-        if [[ ! $Choose_number =~ ^[1-2]$ ]];then
-            echo "${CWARNING}input error! Please only input number 1,2${CEND}"
-        else
-            break
-        fi
+      echo 'Please choose to use environment:'
+      echo -e "\t${CMSG}1${CEND}. Use java"
+      echo -e "\t${CMSG}2${CEND}. Use hhvm"
+      read -p "Please input a number:(Default 1 press Enter) " Choose_number
+      [ -z "$Choose_number" ] && Choose_number=1
+      if [[ ! $Choose_number =~ ^[1-2]$ ]]; then
+        echo "${CWARNING}input error! Please only input number 1,2${CEND}"
+      else
+        break
+      fi
     done
     done
     [ "$Choose_number" == '1' ] && NGX_FLAG=java
     [ "$Choose_number" == '1' ] && NGX_FLAG=java
     [ "$Choose_number" == '2' ] && NGX_FLAG=hhvm
     [ "$Choose_number" == '2' ] && NGX_FLAG=hhvm
-elif [ ! -e "$php_install_dir/bin/phpize" -a -e "$tomcat_install_dir/conf/server.xml" -a ! -e "/usr/bin/hhvm" ];then
+  elif [ ! -e "$php_install_dir/bin/phpize" -a -e "$tomcat_install_dir/conf/server.xml" -a ! -e "/usr/bin/hhvm" ]; then
     Number=010
     Number=010
     NGX_FLAG=java
     NGX_FLAG=java
-elif [ ! -e "$php_install_dir/bin/phpize" -a ! -e "$tomcat_install_dir/conf/server.xml" -a -e "/usr/bin/hhvm" ];then
+  elif [ ! -e "$php_install_dir/bin/phpize" -a ! -e "$tomcat_install_dir/conf/server.xml" -a -e "/usr/bin/hhvm" ]; then
     Number=001
     Number=001
     NGX_FLAG=hhvm
     NGX_FLAG=hhvm
-else
+  else
     Number=000
     Number=000
     NGX_FLAG=php
     NGX_FLAG=php
-fi
+  fi
 
 
-if [ "$NGX_FLAG" == 'php' ];then
+  if [ "$NGX_FLAG" == 'php' ]; then
     NGX_CONF=$(echo -e "location ~ [^/]\.php(/|$) {\n    #fastcgi_pass remote_php_ip:9000;\n    fastcgi_pass unix:/dev/shm/php-cgi.sock;\n    fastcgi_index index.php;\n    include fastcgi.conf;\n    }")
     NGX_CONF=$(echo -e "location ~ [^/]\.php(/|$) {\n    #fastcgi_pass remote_php_ip:9000;\n    fastcgi_pass unix:/dev/shm/php-cgi.sock;\n    fastcgi_index index.php;\n    include fastcgi.conf;\n    }")
-elif [ "$NGX_FLAG" == 'java' ];then
+  elif [ "$NGX_FLAG" == 'java' ]; then
     NGX_CONF=$(echo -e "location ~ {\n    proxy_pass http://127.0.0.1:8080;\n    include proxy.conf;\n    }")
     NGX_CONF=$(echo -e "location ~ {\n    proxy_pass http://127.0.0.1:8080;\n    include proxy.conf;\n    }")
-elif [ "$NGX_FLAG" == 'hhvm' ];then
+  elif [ "$NGX_FLAG" == 'hhvm' ]; then
     NGX_CONF=$(echo -e "location ~ .*\.(php|php5)?$ {\n    fastcgi_pass unix:/var/log/hhvm/sock;\n    fastcgi_index index.php;\n    fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;\n    include fastcgi_params;\n    }")
     NGX_CONF=$(echo -e "location ~ .*\.(php|php5)?$ {\n    fastcgi_pass unix:/var/log/hhvm/sock;\n    fastcgi_index index.php;\n    fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;\n    include fastcgi_params;\n    }")
-fi
+  fi
 }
 }
 
 
 Create_self_SSL() {
 Create_self_SSL() {
-printf "
+  printf "
 You are about to be asked to enter information that will be incorporated
 You are about to be asked to enter information that will be incorporated
 into your certificate request.
 into your certificate request.
 What you are about to enter is what is called a Distinguished Name or a DN.
 What you are about to enter is what is called a Distinguished Name or a DN.
@@ -135,190 +135,190 @@ For some fields there will be a default value,
 If you enter '.', the field will be left blank.
 If you enter '.', the field will be left blank.
 "
 "
 
 
-echo
-read -p "Country Name (2 letter code) [CN]: " SELFSIGNEDSSL_C
-[ -z "$SELFSIGNEDSSL_C" ] && SELFSIGNEDSSL_C=CN
-
-echo
-read -p "State or Province Name (full name) [Shanghai]: " SELFSIGNEDSSL_ST
-[ -z "$SELFSIGNEDSSL_ST" ] && SELFSIGNEDSSL_ST=Shanghai
-
-echo
-read -p "Locality Name (eg, city) [Shanghai]: " SELFSIGNEDSSL_L
-[ -z "$SELFSIGNEDSSL_L" ] && SELFSIGNEDSSL_L=Shanghai
-
-echo
-read -p "Organization Name (eg, company) [LinuxEye Inc.]: " SELFSIGNEDSSL_O
-[ -z "$SELFSIGNEDSSL_O" ] && SELFSIGNEDSSL_O='LinuxEye Inc.'
-
-echo
-read -p "Organizational Unit Name (eg, section) [IT Dept.]: " SELFSIGNEDSSL_OU
-[ -z "$SELFSIGNEDSSL_OU" ] && SELFSIGNEDSSL_OU='IT Dept.'
-
-openssl req -new -newkey rsa:2048 -sha256 -nodes -out $PATH_SSL/${domain}.csr -keyout $PATH_SSL/${domain}.key -subj "/C=${SELFSIGNEDSSL_C}/ST=${SELFSIGNEDSSL_ST}/L=${SELFSIGNEDSSL_L}/O=${SELFSIGNEDSSL_O}/OU=${SELFSIGNEDSSL_OU}/CN=${domain}" > /dev/null 2>&1
-/bin/cp $PATH_SSL/${domain}.csr{,_bk.`date +%Y-%m-%d_%H%M`}
-/bin/cp $PATH_SSL/${domain}.key{,_bk.`date +%Y-%m-%d_%H%M`}
-openssl x509 -req -days 36500 -sha256 -in $PATH_SSL/${domain}.csr -signkey $PATH_SSL/${domain}.key -out $PATH_SSL/${domain}.crt > /dev/null 2>&1
+  echo
+  read -p "Country Name (2 letter code) [CN]: " SELFSIGNEDSSL_C
+  [ -z "$SELFSIGNEDSSL_C" ] && SELFSIGNEDSSL_C=CN
+  
+  echo
+  read -p "State or Province Name (full name) [Shanghai]: " SELFSIGNEDSSL_ST
+  [ -z "$SELFSIGNEDSSL_ST" ] && SELFSIGNEDSSL_ST=Shanghai
+  
+  echo
+  read -p "Locality Name (eg, city) [Shanghai]: " SELFSIGNEDSSL_L
+  [ -z "$SELFSIGNEDSSL_L" ] && SELFSIGNEDSSL_L=Shanghai
+  
+  echo
+  read -p "Organization Name (eg, company) [LinuxEye Inc.]: " SELFSIGNEDSSL_O
+  [ -z "$SELFSIGNEDSSL_O" ] && SELFSIGNEDSSL_O='LinuxEye Inc.'
+  
+  echo
+  read -p "Organizational Unit Name (eg, section) [IT Dept.]: " SELFSIGNEDSSL_OU
+  [ -z "$SELFSIGNEDSSL_OU" ] && SELFSIGNEDSSL_OU='IT Dept.'
+  
+  openssl req -new -newkey rsa:2048 -sha256 -nodes -out $PATH_SSL/${domain}.csr -keyout $PATH_SSL/${domain}.key -subj "/C=${SELFSIGNEDSSL_C}/ST=${SELFSIGNEDSSL_ST}/L=${SELFSIGNEDSSL_L}/O=${SELFSIGNEDSSL_O}/OU=${SELFSIGNEDSSL_OU}/CN=${domain}" > /dev/null 2>&1
+  /bin/cp $PATH_SSL/${domain}.csr{,_bk.`date +%Y-%m-%d_%H%M`}
+  /bin/cp $PATH_SSL/${domain}.key{,_bk.`date +%Y-%m-%d_%H%M`}
+  openssl x509 -req -days 36500 -sha256 -in $PATH_SSL/${domain}.csr -signkey $PATH_SSL/${domain}.key -out $PATH_SSL/${domain}.crt > /dev/null 2>&1
 }
 }
 
 
 Create_SSL() {
 Create_SSL() {
-if [ -e "/usr/local/bin/certbot-auto" -a -e "/root/.local/share/letsencrypt/bin/letsencrypt" ];then
+  if [ -e "/usr/local/bin/certbot-auto" -a -e "/root/.local/share/letsencrypt/bin/letsencrypt" ]; then
     while :; do echo
     while :; do echo
-        read -p "Do you want to use a Let's Encrypt certificate? [y/n]: " letsencrypt_yn 
-        if [[ ! $letsencrypt_yn =~ ^[y,n]$ ]];then
-            echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
-        else
-            break
-        fi
+      read -p "Do you want to use a Let's Encrypt certificate? [y/n]: " letsencrypt_yn 
+      if [[ ! $letsencrypt_yn =~ ^[y,n]$ ]]; then
+        echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+      else
+        break
+      fi
     done
     done
-    if [ "$letsencrypt_yn" == 'y' ];then
-        PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
-        for D in $domain $moredomainame
-        do
-            Domain_IPADDR=`ping $D -c1 | sed '1{s/[^(]*(//;s/).*//;q}'`
-            [ "$PUBLIC_IPADDR" != "$Domain_IPADDR" ] && { echo; echo "${CFAILURE}DNS problem: NXDOMAIN looking up A for $D${CEND}"; echo; exit 1; }
-        done
-
-        #add Email
-        while :
-        do
-            echo
-            read -p "Please enter Administrator Email(example: admin@linuxeye.com): " Admin_Email
-            if [ -z "`echo $Admin_Email | grep '.*@.*\..*'`" ]; then
-                echo "${CWARNING}input error! ${CEND}"
-            else
-                break
-            fi
-        done
-        [ "$moredomainame_yn" == 'y' ] && moredomainame_D="`for D in $moredomainame; do echo -d $D; done`"
-        [ "$nginx_ssl_yn" == 'y' ] && S=nginx
-        [ "$apache_ssl_yn" == 'y' ] && S=httpd
-        [ ! -d "$wwwroot_dir/$domain/.well-known" ] && mkdir -p $wwwroot_dir/$domain/.well-known;chown -R $run_user.$run_user $wwwroot_dir/$domain/.well-known 
-        certbot-auto certonly --standalone --agree-tos --email $Admin_Email -d $domain $moredomainame_D --pre-hook "service $S stop" --post-hook "service $S start"
-        if [ -s "/etc/letsencrypt/live/$domain/cert.pem" ];then
-            [ -e "$PATH_SSL/$domain.crt" ] && rm -rf $PATH_SSL/$domain.{crt,key}
-            ln -s /etc/letsencrypt/live/$domain/fullchain.pem $PATH_SSL/$domain.crt
-            ln -s /etc/letsencrypt/live/$domain/privkey.pem $PATH_SSL/$domain.key
-            if [ -e "$web_install_dir/sbin/nginx" -a -e "$apache_install_dir/conf/httpd.conf" ];then 
-                Cron_Command='/etc/init.d/nginx reload;/etc/init.d/httpd graceful'
-            elif [ -e "$web_install_dir/sbin/nginx" -a ! -e "$apache_install_dir/conf/httpd.conf" ];then 
-                Cron_Command='/etc/init.d/nginx reload'
-            elif [ ! -e "$web_install_dir/sbin/nginx" -a -e "$apache_install_dir/conf/httpd.conf" ];then 
-                Cron_Command='/etc/init.d/httpd graceful'
-            fi
-            [ "$OS" == 'CentOS' ] && Cron_file=/var/spool/cron/root || Cron_file=/var/spool/cron/crontabs/root
-            [ -z "`grep "$domain $moredomainame_D" $Cron_file`" ] && echo "0 10 * * 1 /usr/local/bin/certbot-auto certonly -a webroot --agree-tos --renew-by-default --webroot-path=$wwwroot_dir/$domain -d $domain $moredomainame_D;$Cron_Command" >> $Cron_file
+    if [ "$letsencrypt_yn" == 'y' ]; then
+      PUBLIC_IPADDR=`./include/get_public_ipaddr.py`
+      for D in $domain $moredomainame
+      do
+        Domain_IPADDR=`ping $D -c1 | sed '1{s/[^(]*(//;s/).*//;q}'`
+        [ "$PUBLIC_IPADDR" != "$Domain_IPADDR" ] && { echo; echo "${CFAILURE}DNS problem: NXDOMAIN looking up A for $D${CEND}"; echo; exit 1; }
+      done
+
+      #add Email
+      while :
+      do
+        echo
+        read -p "Please enter Administrator Email(example: admin@linuxeye.com): " Admin_Email
+        if [ -z "`echo $Admin_Email | grep '.*@.*\..*'`" ]; then
+          echo "${CWARNING}input error! ${CEND}"
         else
         else
-            echo "${CFAILURE}Error: Let's Encrypt SSL certificate installation failed${CEND}"
-            exit 1
+          break
         fi
         fi
+      done
+      [ "$moredomainame_yn" == 'y' ] && moredomainame_D="`for D in $moredomainame; do echo -d $D; done`"
+      [ "$nginx_ssl_yn" == 'y' ] && S=nginx
+      [ "$apache_ssl_yn" == 'y' ] && S=httpd
+      [ ! -d "$wwwroot_dir/$domain/.well-known" ] && mkdir -p $wwwroot_dir/$domain/.well-known;chown -R $run_user.$run_user $wwwroot_dir/$domain/.well-known 
+      certbot-auto certonly --standalone --agree-tos --email $Admin_Email -d $domain $moredomainame_D --pre-hook "service $S stop" --post-hook "service $S start"
+      if [ -s "/etc/letsencrypt/live/$domain/cert.pem" ]; then
+        [ -e "$PATH_SSL/$domain.crt" ] && rm -rf $PATH_SSL/$domain.{crt,key}
+        ln -s /etc/letsencrypt/live/$domain/fullchain.pem $PATH_SSL/$domain.crt
+        ln -s /etc/letsencrypt/live/$domain/privkey.pem $PATH_SSL/$domain.key
+        if [ -e "$web_install_dir/sbin/nginx" -a -e "$apache_install_dir/conf/httpd.conf" ]; then 
+          Cron_Command='/etc/init.d/nginx reload;/etc/init.d/httpd graceful'
+        elif [ -e "$web_install_dir/sbin/nginx" -a ! -e "$apache_install_dir/conf/httpd.conf" ]; then 
+          Cron_Command='/etc/init.d/nginx reload'
+        elif [ ! -e "$web_install_dir/sbin/nginx" -a -e "$apache_install_dir/conf/httpd.conf" ]; then 
+          Cron_Command='/etc/init.d/httpd graceful'
+        fi
+        [ "$OS" == 'CentOS' ] && Cron_file=/var/spool/cron/root || Cron_file=/var/spool/cron/crontabs/root
+        [ -z "`grep "$domain $moredomainame_D" $Cron_file`" ] && echo "0 10 * * 1 /usr/local/bin/certbot-auto certonly -a webroot --agree-tos --renew-by-default --webroot-path=$wwwroot_dir/$domain -d $domain $moredomainame_D;$Cron_Command" >> $Cron_file
+      else
+        echo "${CFAILURE}Error: Let's Encrypt SSL certificate installation failed${CEND}"
+        exit 1
+      fi
     else
     else
-        Create_self_SSL
+      Create_self_SSL
     fi
     fi
-else
+  else
     Create_self_SSL
     Create_self_SSL
-fi
+  fi
 }
 }
 
 
 Print_ssl() {
 Print_ssl() {
-if [ "$letsencrypt_yn" == 'y' ];then
+  if [ "$letsencrypt_yn" == 'y' ]; then
     echo "`printf "%-30s" "Let's Encrypt SSL Certificate:"`${CMSG}/etc/letsencrypt/live/$domain/fullchain.pem${CEND}"
     echo "`printf "%-30s" "Let's Encrypt SSL Certificate:"`${CMSG}/etc/letsencrypt/live/$domain/fullchain.pem${CEND}"
     echo "`printf "%-30s" "SSL Private Key:"`${CMSG}/etc/letsencrypt/live/$domain/privkey.pem${CEND}"
     echo "`printf "%-30s" "SSL Private Key:"`${CMSG}/etc/letsencrypt/live/$domain/privkey.pem${CEND}"
-else
+  else
     echo "`printf "%-30s" "Self-signed SSL Certificate:"`${CMSG}$PATH_SSL/${domain}.crt${CEND}"
     echo "`printf "%-30s" "Self-signed SSL Certificate:"`${CMSG}$PATH_SSL/${domain}.crt${CEND}"
     echo "`printf "%-30s" "SSL Private Key:"`${CMSG}$PATH_SSL/${domain}.key${CEND}"
     echo "`printf "%-30s" "SSL Private Key:"`${CMSG}$PATH_SSL/${domain}.key${CEND}"
     echo "`printf "%-30s" "SSL CSR File:"`${CMSG}$PATH_SSL/${domain}.csr${CEND}"
     echo "`printf "%-30s" "SSL CSR File:"`${CMSG}$PATH_SSL/${domain}.csr${CEND}"
-fi
+  fi
 }
 }
 
 
 
 
 Input_Add_domain() {
 Input_Add_domain() {
-if [ -e "$web_install_dir/sbin/nginx" ];then
+  if [ -e "$web_install_dir/sbin/nginx" ]; then
     while :; do echo
     while :; do echo
-        read -p "Do you want to setup SSL under Nginx? [y/n]: " nginx_ssl_yn
-        if [[ ! $nginx_ssl_yn =~ ^[y,n]$ ]];then
-            echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
-        else
-            break
-        fi
+      read -p "Do you want to setup SSL under Nginx? [y/n]: " nginx_ssl_yn
+      if [[ ! $nginx_ssl_yn =~ ^[y,n]$ ]]; then
+        echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+      else
+        break
+      fi
     done
     done
-elif [ ! -e "$web_install_dir/sbin/nginx" -a -e "$apache_install_dir/bin/apachectl" ];then
+  elif [ ! -e "$web_install_dir/sbin/nginx" -a -e "$apache_install_dir/bin/apachectl" ]; then
     while :; do echo
     while :; do echo
-        read -p "Do you want to setup SSL under Apache? [y/n]: " apache_ssl_yn
-        if [[ ! $apache_ssl_yn =~ ^[y,n]$ ]];then
-            echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
-        else
-            break
-        fi
+      read -p "Do you want to setup SSL under Apache? [y/n]: " apache_ssl_yn
+      if [[ ! $apache_ssl_yn =~ ^[y,n]$ ]]; then
+        echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+      else
+        break
+      fi
     done
     done
-fi
+  fi
 
 
-[ "$apache_ssl_yn" == 'y' ] && { PATH_SSL=$apache_install_dir/conf/ssl; [ ! -d "$PATH_SSL" ] && mkdir $PATH_SSL; }
-[ "$nginx_ssl_yn" == 'y' ] && { PATH_SSL=$web_install_dir/conf/ssl; [ ! -d "$PATH_SSL" ] && mkdir $PATH_SSL; }
+  [ "$apache_ssl_yn" == 'y' ] && { PATH_SSL=$apache_install_dir/conf/ssl; [ ! -d "$PATH_SSL" ] && mkdir $PATH_SSL; }
+  [ "$nginx_ssl_yn" == 'y' ] && { PATH_SSL=$web_install_dir/conf/ssl; [ ! -d "$PATH_SSL" ] && mkdir $PATH_SSL; }
 
 
-while :; do echo
+  while :; do echo
     read -p "Please input domain(example: www.linuxeye.com): " domain
     read -p "Please input domain(example: www.linuxeye.com): " domain
     if [ -z "`echo $domain | grep '.*\..*'`" ]; then
     if [ -z "`echo $domain | grep '.*\..*'`" ]; then
-        echo "${CWARNING}input error! ${CEND}"
+      echo "${CWARNING}input error! ${CEND}"
     else
     else
-        break
+      break
     fi
     fi
-done
+  done
 
 
-if [ -e "$web_install_dir/conf/vhost/$domain.conf" -o -e "$apache_install_dir/conf/vhost/$domain.conf" -o -e "$tomcat_install_dir/conf/vhost/$domain.xml" ]; then
+  if [ -e "$web_install_dir/conf/vhost/$domain.conf" -o -e "$apache_install_dir/conf/vhost/$domain.conf" -o -e "$tomcat_install_dir/conf/vhost/$domain.xml" ]; then
     [ -e "$web_install_dir/conf/vhost/$domain.conf" ] && echo -e "$domain in the Nginx/Tengine/OpenResty already exist! \nYou can delete ${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND} and re-create"
     [ -e "$web_install_dir/conf/vhost/$domain.conf" ] && echo -e "$domain in the Nginx/Tengine/OpenResty already exist! \nYou can delete ${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND} and re-create"
     [ -e "$apache_install_dir/conf/vhost/$domain.conf" ] && echo -e "$domain in the Apache already exist! \nYou can delete ${CMSG}$apache_install_dir/conf/vhost/$domain.conf${CEND} and re-create"
     [ -e "$apache_install_dir/conf/vhost/$domain.conf" ] && echo -e "$domain in the Apache already exist! \nYou can delete ${CMSG}$apache_install_dir/conf/vhost/$domain.conf${CEND} and re-create"
     [ -e "$tomcat_install_dir/conf/vhost/$domain.xml" ] && echo -e "$domain in the Tomcat already exist! \nYou can delete ${CMSG}$tomcat_install_dir/conf/vhost/$domain.xml${CEND} and re-create"
     [ -e "$tomcat_install_dir/conf/vhost/$domain.xml" ] && echo -e "$domain in the Tomcat already exist! \nYou can delete ${CMSG}$tomcat_install_dir/conf/vhost/$domain.xml${CEND} and re-create"
     exit
     exit
-else
+  else
     echo "domain=$domain"
     echo "domain=$domain"
-fi
+  fi
 
 
-while :; do echo
+  while :; do echo
     read -p "Do you want to add more domain name? [y/n]: " moredomainame_yn
     read -p "Do you want to add more domain name? [y/n]: " moredomainame_yn
-    if [[ ! $moredomainame_yn =~ ^[y,n]$ ]];then
-        echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+    if [[ ! $moredomainame_yn =~ ^[y,n]$ ]]; then
+      echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
     else
     else
-        break
+      break
     fi
     fi
-done
+  done
 
 
-if [ "$moredomainame_yn" == 'y' ]; then
+  if [ "$moredomainame_yn" == 'y' ]; then
     while :; do echo
     while :; do echo
-        read -p "Type domainname or IP(example: linuxeye.com 121.43.8.8): " moredomain
-        if [ -z "`echo $moredomain | grep '.*\..*'`" ]; then
-            echo "${CWARNING}input error! ${CEND}"
-        else
-            [ "$moredomain" == "$domain" ] && echo "${CWARNING}Domain name already exists! ${CND}" && continue
-            echo domain list="$moredomain"
-            moredomainame=" $moredomain"
-            break
-        fi
+      read -p "Type domainname or IP(example: linuxeye.com 121.43.8.8): " moredomain
+      if [ -z "`echo $moredomain | grep '.*\..*'`" ]; then
+        echo "${CWARNING}input error! ${CEND}"
+      else
+        [ "$moredomain" == "$domain" ] && echo "${CWARNING}Domain name already exists! ${CND}" && continue
+        echo domain list="$moredomain"
+        moredomainame=" $moredomain"
+        break
+      fi
     done
     done
     Apache_Domain_alias=ServerAlias$moredomainame
     Apache_Domain_alias=ServerAlias$moredomainame
     Tomcat_Domain_alias=$(for D in `echo $moredomainame`; do echo "<Alias>$D</Alias>"; done)
     Tomcat_Domain_alias=$(for D in `echo $moredomainame`; do echo "<Alias>$D</Alias>"; done)
 
 
-    if [ -e "$web_install_dir/sbin/nginx" ];then
-        while :; do echo
-            read -p "Do you want to redirect from $moredomain to $domain? [y/n]: " redirect_yn
-            if [[ ! $redirect_yn =~ ^[y,n]$ ]];then
-                echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
-            else
-                break
-            fi
-        done
-        [ "$redirect_yn" == 'y' ] && Nginx_redirect=$(echo -e "if (\$host != $domain) {\n    rewrite ^/(.*)\$ \$scheme://$domain/\$1 permanent;\n    }")
+    if [ -e "$web_install_dir/sbin/nginx" ]; then
+      while :; do echo
+        read -p "Do you want to redirect from $moredomain to $domain? [y/n]: " redirect_yn
+        if [[ ! $redirect_yn =~ ^[y,n]$ ]]; then
+          echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+        else
+          break
+        fi
+      done
+      [ "$redirect_yn" == 'y' ] && Nginx_redirect=$(echo -e "if (\$host != $domain) {\n    rewrite ^/(.*)\$ \$scheme://$domain/\$1 permanent;\n    }")
     fi
     fi
-fi
+  fi
 
 
-if [ "$nginx_ssl_yn" == 'y' ]; then
+  if [ "$nginx_ssl_yn" == 'y' ]; then
     while :; do echo
     while :; do echo
-        read -p "Do you want to redirect all HTTP requests to HTTPS? [y/n]: " https_yn
-        if [[ ! $https_yn =~ ^[y,n]$ ]];then
-            echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
-        else
-            break
-        fi
+      read -p "Do you want to redirect all HTTP requests to HTTPS? [y/n]: " https_yn
+      if [[ ! $https_yn =~ ^[y,n]$ ]]; then
+        echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+      else
+        break
+      fi
     done
     done
 
 
     if [[ "$($web_install_dir/sbin/nginx -V 2>&1 | grep -Eo 'with-http_v2_module')" = 'with-http_v2_module' ]]; then
     if [[ "$($web_install_dir/sbin/nginx -V 2>&1 | grep -Eo 'with-http_v2_module')" = 'with-http_v2_module' ]]; then
@@ -329,114 +329,114 @@ if [ "$nginx_ssl_yn" == 'y' ]; then
     Create_SSL
     Create_SSL
     Nginx_conf=$(echo -e "listen 80;\nlisten $LISTENOPT;\nssl_certificate $PATH_SSL/$domain.crt;\nssl_certificate_key $PATH_SSL/$domain.key;\nssl_protocols TLSv1 TLSv1.1 TLSv1.2;\nssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;\nssl_prefer_server_ciphers on;\nssl_session_timeout 10m;\nssl_session_cache builtin:1000 shared:SSL:10m;\nssl_buffer_size 1400;\nadd_header Strict-Transport-Security max-age=15768000;\nssl_stapling on;\nssl_stapling_verify on;\n")
     Nginx_conf=$(echo -e "listen 80;\nlisten $LISTENOPT;\nssl_certificate $PATH_SSL/$domain.crt;\nssl_certificate_key $PATH_SSL/$domain.key;\nssl_protocols TLSv1 TLSv1.1 TLSv1.2;\nssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;\nssl_prefer_server_ciphers on;\nssl_session_timeout 10m;\nssl_session_cache builtin:1000 shared:SSL:10m;\nssl_buffer_size 1400;\nadd_header Strict-Transport-Security max-age=15768000;\nssl_stapling on;\nssl_stapling_verify on;\n")
     Apache_SSL=$(echo -e "SSLEngine on\n    SSLCertificateFile \"$PATH_SSL/$domain.crt\"\n    SSLCertificateKeyFile \"$PATH_SSL/$domain.key\"")
     Apache_SSL=$(echo -e "SSLEngine on\n    SSLCertificateFile \"$PATH_SSL/$domain.crt\"\n    SSLCertificateKeyFile \"$PATH_SSL/$domain.key\"")
-elif [ "$apache_ssl_yn" == 'y' ]; then
+  elif [ "$apache_ssl_yn" == 'y' ]; then
     Create_SSL
     Create_SSL
     Apache_SSL=$(echo -e "SSLEngine on\n    SSLCertificateFile \"$PATH_SSL/$domain.crt\"\n    SSLCertificateKeyFile \"$PATH_SSL/$domain.key\"")
     Apache_SSL=$(echo -e "SSLEngine on\n    SSLCertificateFile \"$PATH_SSL/$domain.crt\"\n    SSLCertificateKeyFile \"$PATH_SSL/$domain.key\"")
     [ -z "`grep 'Listen 443' $apache_install_dir/conf/httpd.conf`" ] && sed -i "s@Listen 80@&\nListen 443@" $apache_install_dir/conf/httpd.conf
     [ -z "`grep 'Listen 443' $apache_install_dir/conf/httpd.conf`" ] && sed -i "s@Listen 80@&\nListen 443@" $apache_install_dir/conf/httpd.conf
     [ -z "`grep 'ServerName 0.0.0.0:443' $apache_install_dir/conf/httpd.conf`" ] && sed -i "s@ServerName 0.0.0.0:80@&\nServerName 0.0.0.0:443@" $apache_install_dir/conf/httpd.conf
     [ -z "`grep 'ServerName 0.0.0.0:443' $apache_install_dir/conf/httpd.conf`" ] && sed -i "s@ServerName 0.0.0.0:80@&\nServerName 0.0.0.0:443@" $apache_install_dir/conf/httpd.conf
-else
+  else
     Nginx_conf='listen 80;'
     Nginx_conf='listen 80;'
-fi
+  fi
 
 
-while :; do echo
+  while :; do echo
     echo "Please input the directory for the domain:$domain :"
     echo "Please input the directory for the domain:$domain :"
     read -p "(Default directory: $wwwroot_dir/$domain): " vhostdir
     read -p "(Default directory: $wwwroot_dir/$domain): " vhostdir
-    if [ -n "$vhostdir" -a -z "`echo $vhostdir | grep '^/'`" ];then
-        echo "${CWARNING}input error! Press Enter to continue...${CEND}"
+    if [ -n "$vhostdir" -a -z "`echo $vhostdir | grep '^/'`" ]; then
+      echo "${CWARNING}input error! Press Enter to continue...${CEND}"
     else
     else
-        if [ -z "$vhostdir" ]; then
-            vhostdir="$wwwroot_dir/$domain"
-            echo "Virtual Host Directory=${CMSG}$vhostdir${CEND}"
-        fi
-        echo
-        echo "Create Virtul Host directory......"
-        mkdir -p $vhostdir
-        echo "set permissions of Virtual Host directory......"
-        chown -R ${run_user}.$run_user $vhostdir
-        break
+      if [ -z "$vhostdir" ]; then
+        vhostdir="$wwwroot_dir/$domain"
+        echo "Virtual Host Directory=${CMSG}$vhostdir${CEND}"
+      fi
+      echo
+      echo "Create Virtul Host directory......"
+      mkdir -p $vhostdir
+      echo "set permissions of Virtual Host directory......"
+      chown -R ${run_user}.$run_user $vhostdir
+      break
     fi
     fi
-done
+  done
 }
 }
 
 
 Nginx_anti_hotlinking() {
 Nginx_anti_hotlinking() {
-while :; do echo
+  while :; do echo
     read -p "Do you want to add hotlink protection? [y/n]: " anti_hotlinking_yn
     read -p "Do you want to add hotlink protection? [y/n]: " anti_hotlinking_yn
-    if [[ ! $anti_hotlinking_yn =~ ^[y,n]$ ]];then
-        echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+    if [[ ! $anti_hotlinking_yn =~ ^[y,n]$ ]]; then
+      echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
     else
     else
-        break
+      break
     fi
     fi
-done
+  done
 
 
-if [ -n "`echo $domain | grep '.*\..*\..*'`" ];then
+  if [ -n "`echo $domain | grep '.*\..*\..*'`" ]; then
     domain_allow="*.${domain#*.} $domain"
     domain_allow="*.${domain#*.} $domain"
-else
+  else
     domain_allow="*.$domain $domain"
     domain_allow="*.$domain $domain"
-fi
+  fi
 
 
-if [ "$anti_hotlinking_yn" == 'y' ];then
+  if [ "$anti_hotlinking_yn" == 'y' ]; then
     if [ "$moredomainame_yn" == 'y' ]; then
     if [ "$moredomainame_yn" == 'y' ]; then
-        domain_allow_all=$domain_allow$moredomainame
+      domain_allow_all=$domain_allow$moredomainame
     else
     else
-        domain_allow_all=$domain_allow
+      domain_allow_all=$domain_allow
     fi
     fi
     anti_hotlinking=$(echo -e "location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv)$ {\n    valid_referers none blocked $domain_allow_all;\n    if (\$invalid_referer) {\n        #rewrite ^/ http://www.linuxeye.com/403.html;\n        return 403;\n        }\n    }")
     anti_hotlinking=$(echo -e "location ~ .*\.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv)$ {\n    valid_referers none blocked $domain_allow_all;\n    if (\$invalid_referer) {\n        #rewrite ^/ http://www.linuxeye.com/403.html;\n        return 403;\n        }\n    }")
-else
+  else
     anti_hotlinking=
     anti_hotlinking=
-fi
+  fi
 }
 }
 
 
 Nginx_rewrite() {
 Nginx_rewrite() {
-[ ! -d "$web_install_dir/conf/rewrite" ] && mkdir $web_install_dir/conf/rewrite
-while :; do echo
+  [ ! -d "$web_install_dir/conf/rewrite" ] && mkdir $web_install_dir/conf/rewrite
+  while :; do echo
     read -p "Allow Rewrite rule? [y/n]: " rewrite_yn
     read -p "Allow Rewrite rule? [y/n]: " rewrite_yn
-    if [[ ! $rewrite_yn =~ ^[y,n]$ ]];then
-        echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+    if [[ ! $rewrite_yn =~ ^[y,n]$ ]]; then
+      echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
     else
     else
-        break
+      break
     fi
     fi
-done
-if [ "$rewrite_yn" == 'n' ];then
+  done
+  if [ "$rewrite_yn" == 'n' ]; then
     rewrite="none"
     rewrite="none"
     touch "$web_install_dir/conf/rewrite/$rewrite.conf"
     touch "$web_install_dir/conf/rewrite/$rewrite.conf"
-else
+  else
     echo
     echo
     echo "Please input the rewrite of programme :"
     echo "Please input the rewrite of programme :"
     echo "${CMSG}wordpress${CEND},${CMSG}discuz${CEND},${CMSG}opencart${CEND},${CMSG}thinkphp${CEND},${CMSG}laravel${CEND},${CMSG}typecho${CEND},${CMSG}ecshop${CEND},${CMSG}drupal${CEND},${CMSG}joomla${CEND} rewrite was exist."
     echo "${CMSG}wordpress${CEND},${CMSG}discuz${CEND},${CMSG}opencart${CEND},${CMSG}thinkphp${CEND},${CMSG}laravel${CEND},${CMSG}typecho${CEND},${CMSG}ecshop${CEND},${CMSG}drupal${CEND},${CMSG}joomla${CEND} rewrite was exist."
     read -p "(Default rewrite: other):" rewrite
     read -p "(Default rewrite: other):" rewrite
     if [ "$rewrite" == "" ]; then
     if [ "$rewrite" == "" ]; then
-        rewrite="other"
+      rewrite="other"
     fi
     fi
     echo "You choose rewrite=${CMSG}$rewrite${CEND}"
     echo "You choose rewrite=${CMSG}$rewrite${CEND}"
     [ "$NGX_FLAG" == 'php' -a "$rewrite" == "thinkphp" ] && NGX_CONF=$(echo -e "location ~ \.php {\n    #fastcgi_pass remote_php_ip:9000;\n    fastcgi_pass unix:/dev/shm/php-cgi.sock;\n    fastcgi_index index.php;\n    include fastcgi_params;\n    set \$real_script_name \$fastcgi_script_name;\n        if (\$fastcgi_script_name ~ \"^(.+?\.php)(/.+)\$\") {\n        set \$real_script_name \$1;\n        #set \$path_info \$2;\n        }\n    fastcgi_param SCRIPT_FILENAME \$document_root\$real_script_name;\n    fastcgi_param SCRIPT_NAME \$real_script_name;\n    #fastcgi_param PATH_INFO \$path_info;\n    }")
     [ "$NGX_FLAG" == 'php' -a "$rewrite" == "thinkphp" ] && NGX_CONF=$(echo -e "location ~ \.php {\n    #fastcgi_pass remote_php_ip:9000;\n    fastcgi_pass unix:/dev/shm/php-cgi.sock;\n    fastcgi_index index.php;\n    include fastcgi_params;\n    set \$real_script_name \$fastcgi_script_name;\n        if (\$fastcgi_script_name ~ \"^(.+?\.php)(/.+)\$\") {\n        set \$real_script_name \$1;\n        #set \$path_info \$2;\n        }\n    fastcgi_param SCRIPT_FILENAME \$document_root\$real_script_name;\n    fastcgi_param SCRIPT_NAME \$real_script_name;\n    #fastcgi_param PATH_INFO \$path_info;\n    }")
-    if [ -e "config/$rewrite.conf" ];then
-        /bin/cp config/$rewrite.conf $web_install_dir/conf/rewrite/$rewrite.conf
+    if [ -e "config/$rewrite.conf" ]; then
+      /bin/cp config/$rewrite.conf $web_install_dir/conf/rewrite/$rewrite.conf
     else
     else
-        touch "$web_install_dir/conf/rewrite/$rewrite.conf"
+      touch "$web_install_dir/conf/rewrite/$rewrite.conf"
     fi
     fi
-fi
+  fi
 }
 }
 
 
 Nginx_log() {
 Nginx_log() {
-while :; do echo
+  while :; do echo
     read -p "Allow Nginx/Tengine/OpenResty access_log? [y/n]: " access_yn
     read -p "Allow Nginx/Tengine/OpenResty access_log? [y/n]: " access_yn
-    if [[ ! $access_yn =~ ^[y,n]$ ]];then
-        echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+    if [[ ! $access_yn =~ ^[y,n]$ ]]; then
+      echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
     else
     else
-        break
+      break
     fi
     fi
-done
-if [ "$access_yn" == 'n' ]; then
+  done
+  if [ "$access_yn" == 'n' ]; then
     N_log="access_log off;"
     N_log="access_log off;"
-else
+  else
     N_log="access_log $wwwlogs_dir/${domain}_nginx.log combined;"
     N_log="access_log $wwwlogs_dir/${domain}_nginx.log combined;"
     echo "You access log file=${CMSG}$wwwlogs_dir/${domain}_nginx.log${CEND}"
     echo "You access log file=${CMSG}$wwwlogs_dir/${domain}_nginx.log${CEND}"
-fi
+  fi
 }
 }
 
 
 Create_nginx_tomcat_conf() {
 Create_nginx_tomcat_conf() {
-[ ! -d $web_install_dir/conf/vhost ] && mkdir $web_install_dir/conf/vhost
-cat > $web_install_dir/conf/vhost/$domain.conf << EOF
+  [ ! -d $web_install_dir/conf/vhost ] && mkdir $web_install_dir/conf/vhost
+  cat > $web_install_dir/conf/vhost/$domain.conf << EOF
 server {
 server {
 $Nginx_conf
 $Nginx_conf
 server_name $domain$moredomainame;
 server_name $domain$moredomainame;
@@ -457,72 +457,72 @@ $NGX_CONF
 }
 }
 EOF
 EOF
 
 
-[ "$https_yn" == 'y' ] && sed -i "s@^root.*;@&\nif (\$ssl_protocol = \"\") { return 301 https://\$host\$request_uri; }@" $web_install_dir/conf/vhost/$domain.conf
+  [ "$https_yn" == 'y' ] && sed -i "s@^root.*;@&\nif (\$ssl_protocol = \"\") { return 301 https://\$host\$request_uri; }@" $web_install_dir/conf/vhost/$domain.conf
 
 
-cat > $tomcat_install_dir/conf/vhost/$domain.xml << EOF
+  cat > $tomcat_install_dir/conf/vhost/$domain.xml << EOF
 <Host name="$domain" appBase="webapps" unpackWARs="true" autoDeploy="true"> $Tomcat_Domain_alias
 <Host name="$domain" appBase="webapps" unpackWARs="true" autoDeploy="true"> $Tomcat_Domain_alias
   <Context path="" docBase="$vhostdir" debug="0" reloadable="false" crossContext="true"/>
   <Context path="" docBase="$vhostdir" debug="0" reloadable="false" crossContext="true"/>
   <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
   <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
          prefix="${domain}_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
          prefix="${domain}_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
 </Host>
 </Host>
 EOF
 EOF
-[ -z "`grep -o "vhost-${domain} SYSTEM" $tomcat_install_dir/conf/server.xml`" ] && sed -i "/vhost-localhost SYSTEM/a<\!ENTITY vhost-${domain} SYSTEM \"file://$tomcat_install_dir/conf/vhost/$domain.xml\">" $tomcat_install_dir/conf/server.xml
-[ -z "`grep -o "vhost-${domain};" $tomcat_install_dir/conf/server.xml`" ] && sed -i "s@vhost-localhost;@&\n      \&vhost-${domain};@" $tomcat_install_dir/conf/server.xml
+  [ -z "`grep -o "vhost-${domain} SYSTEM" $tomcat_install_dir/conf/server.xml`" ] && sed -i "/vhost-localhost SYSTEM/a<\!ENTITY vhost-${domain} SYSTEM \"file://$tomcat_install_dir/conf/vhost/$domain.xml\">" $tomcat_install_dir/conf/server.xml
+  [ -z "`grep -o "vhost-${domain};" $tomcat_install_dir/conf/server.xml`" ] && sed -i "s@vhost-localhost;@&\n      \&vhost-${domain};@" $tomcat_install_dir/conf/server.xml
 
 
-echo
-$web_install_dir/sbin/nginx -t
-if [ $? == 0 ];then
+  echo
+  $web_install_dir/sbin/nginx -t
+  if [ $? == 0 ]; then
     echo "Reload Nginx......"
     echo "Reload Nginx......"
     $web_install_dir/sbin/nginx -s reload
     $web_install_dir/sbin/nginx -s reload
     /etc/init.d/tomcat restart
     /etc/init.d/tomcat restart
-else
+  else
     rm -rf $web_install_dir/conf/vhost/$domain.conf
     rm -rf $web_install_dir/conf/vhost/$domain.conf
     echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
     echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
     exit 1
     exit 1
-fi
+  fi
 
 
-printf "
+  printf "
 #######################################################################
 #######################################################################
 #       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
 #       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
 #       For more information please visit https://oneinstack.com      #
 #       For more information please visit https://oneinstack.com      #
 #######################################################################
 #######################################################################
 "
 "
-echo "`printf "%-30s" "Your domain:"`${CMSG}$domain${CEND}"
-echo "`printf "%-30s" "Nginx Virtualhost conf:"`${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND}"
-echo "`printf "%-30s" "Tomcat Virtualhost conf:"`${CMSG}$tomcat_install_dir/conf/vhost/$domain.xml${CEND}"
-echo "`printf "%-30s" "Directory of:"`${CMSG}$vhostdir${CEND}"
-[ "$nginx_ssl_yn" == 'y' ] && Print_ssl
+  echo "`printf "%-30s" "Your domain:"`${CMSG}$domain${CEND}"
+  echo "`printf "%-30s" "Nginx Virtualhost conf:"`${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND}"
+  echo "`printf "%-30s" "Tomcat Virtualhost conf:"`${CMSG}$tomcat_install_dir/conf/vhost/$domain.xml${CEND}"
+  echo "`printf "%-30s" "Directory of:"`${CMSG}$vhostdir${CEND}"
+  [ "$nginx_ssl_yn" == 'y' ] && Print_ssl
 }
 }
 
 
 Create_tomcat_conf() {
 Create_tomcat_conf() {
-cat > $tomcat_install_dir/conf/vhost/$domain.xml << EOF
+  cat > $tomcat_install_dir/conf/vhost/$domain.xml << EOF
 <Host name="$domain" appBase="webapps" unpackWARs="true" autoDeploy="true"> $Tomcat_Domain_alias
 <Host name="$domain" appBase="webapps" unpackWARs="true" autoDeploy="true"> $Tomcat_Domain_alias
   <Context path="" docBase="$vhostdir" debug="0" reloadable="false" crossContext="true"/>
   <Context path="" docBase="$vhostdir" debug="0" reloadable="false" crossContext="true"/>
   <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
   <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
          prefix="${domain}_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
          prefix="${domain}_access_log." suffix=".txt" pattern="%h %l %u %t &quot;%r&quot; %s %b" />
 </Host>
 </Host>
 EOF
 EOF
-[ -z "`grep -o "vhost-${domain} SYSTEM" $tomcat_install_dir/conf/server.xml`" ] && sed -i "/vhost-localhost SYSTEM/a<\!ENTITY vhost-${domain} SYSTEM \"file://$tomcat_install_dir/conf/vhost/$domain.xml\">" $tomcat_install_dir/conf/server.xml
-[ -z "`grep -o "vhost-${domain};" $tomcat_install_dir/conf/server.xml`" ] && sed -i "s@vhost-localhost;@&\n      \&vhost-${domain};@" $tomcat_install_dir/conf/server.xml
+  [ -z "`grep -o "vhost-${domain} SYSTEM" $tomcat_install_dir/conf/server.xml`" ] && sed -i "/vhost-localhost SYSTEM/a<\!ENTITY vhost-${domain} SYSTEM \"file://$tomcat_install_dir/conf/vhost/$domain.xml\">" $tomcat_install_dir/conf/server.xml
+  [ -z "`grep -o "vhost-${domain};" $tomcat_install_dir/conf/server.xml`" ] && sed -i "s@vhost-localhost;@&\n      \&vhost-${domain};@" $tomcat_install_dir/conf/server.xml
 
 
-echo
-/etc/init.d/tomcat restart
+  echo
+  /etc/init.d/tomcat restart
 
 
-printf "
+  printf "
 #######################################################################
 #######################################################################
 #       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
 #       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
 #       For more information please visit https://oneinstack.com      #
 #       For more information please visit https://oneinstack.com      #
 #######################################################################
 #######################################################################
 "
 "
-echo "`printf "%-30s" "Your domain:"`${CMSG}$domain${CEND}"
-echo "`printf "%-30s" "Tomcat Virtualhost conf:"`${CMSG}$tomcat_install_dir/conf/vhost/$domain.xml${CEND}"
-echo "`printf "%-30s" "Directory of:"`${CMSG}$vhostdir${CEND}"
-echo "`printf "%-30s" "index url:"`${CMSG}http://${domain}:8080/${CEND}"
+  echo "`printf "%-30s" "Your domain:"`${CMSG}$domain${CEND}"
+  echo "`printf "%-30s" "Tomcat Virtualhost conf:"`${CMSG}$tomcat_install_dir/conf/vhost/$domain.xml${CEND}"
+  echo "`printf "%-30s" "Directory of:"`${CMSG}$vhostdir${CEND}"
+  echo "`printf "%-30s" "index url:"`${CMSG}http://${domain}:8080/${CEND}"
 }
 }
 
 
 Create_nginx_php-fpm_hhvm_conf() {
 Create_nginx_php-fpm_hhvm_conf() {
-[ ! -d $web_install_dir/conf/vhost ] && mkdir $web_install_dir/conf/vhost
-cat > $web_install_dir/conf/vhost/$domain.conf << EOF
+  [ ! -d $web_install_dir/conf/vhost ] && mkdir $web_install_dir/conf/vhost
+  cat > $web_install_dir/conf/vhost/$domain.conf << EOF
 server {
 server {
 $Nginx_conf
 $Nginx_conf
 server_name $domain$moredomainame;
 server_name $domain$moredomainame;
@@ -544,54 +544,54 @@ location ~ .*\.(js|css)?$ {
 }
 }
 EOF
 EOF
 
 
-[ "$https_yn" == 'y' ] && sed -i "s@^root.*;@&\nif (\$ssl_protocol = \"\") { return 301 https://\$host\$request_uri; }@" $web_install_dir/conf/vhost/$domain.conf
+  [ "$https_yn" == 'y' ] && sed -i "s@^root.*;@&\nif (\$ssl_protocol = \"\") { return 301 https://\$host\$request_uri; }@" $web_install_dir/conf/vhost/$domain.conf
 
 
-echo
-$web_install_dir/sbin/nginx -t
-if [ $? == 0 ];then
+  echo
+  $web_install_dir/sbin/nginx -t
+  if [ $? == 0 ]; then
     echo "Reload Nginx......"
     echo "Reload Nginx......"
     $web_install_dir/sbin/nginx -s reload
     $web_install_dir/sbin/nginx -s reload
-else
+  else
     rm -rf $web_install_dir/conf/vhost/$domain.conf
     rm -rf $web_install_dir/conf/vhost/$domain.conf
     echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
     echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
     exit 1
     exit 1
-fi
+  fi
 
 
-printf "
+  printf "
 #######################################################################
 #######################################################################
 #       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
 #       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
 #       For more information please visit https://oneinstack.com      #
 #       For more information please visit https://oneinstack.com      #
 #######################################################################
 #######################################################################
 "
 "
-echo "`printf "%-30s" "Your domain:"`${CMSG}$domain${CEND}"
-echo "`printf "%-30s" "Virtualhost conf:"`${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND}"
-echo "`printf "%-30s" "Directory of:"`${CMSG}$vhostdir${CEND}"
-[ "$rewrite_yn" == 'y' ] && echo "`printf "%-30s" "Rewrite rule:"`${CMSG}$web_install_dir/conf/rewrite/$rewrite.conf${CEND}"
-[ "$nginx_ssl_yn" == 'y' ] && Print_ssl
+  echo "`printf "%-30s" "Your domain:"`${CMSG}$domain${CEND}"
+  echo "`printf "%-30s" "Virtualhost conf:"`${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND}"
+  echo "`printf "%-30s" "Directory of:"`${CMSG}$vhostdir${CEND}"
+  [ "$rewrite_yn" == 'y' ] && echo "`printf "%-30s" "Rewrite rule:"`${CMSG}$web_install_dir/conf/rewrite/$rewrite.conf${CEND}"
+  [ "$nginx_ssl_yn" == 'y' ] && Print_ssl
 }
 }
 
 
 Apache_log() {
 Apache_log() {
-while :; do echo
+  while :; do echo
     read -p "Allow Apache access_log? [y/n]: " access_yn
     read -p "Allow Apache access_log? [y/n]: " access_yn
-    if [[ ! $access_yn =~ ^[y,n]$ ]];then
-        echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+    if [[ ! $access_yn =~ ^[y,n]$ ]]; then
+      echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
     else
     else
-        break
+      break
     fi
     fi
-done
+  done
 
 
-if [ "$access_yn" == 'n' ]; then
+  if [ "$access_yn" == 'n' ]; then
     A_log='CustomLog "/dev/null" common'
     A_log='CustomLog "/dev/null" common'
-else
+  else
     A_log="CustomLog \"$wwwlogs_dir/${domain}_apache.log\" common"
     A_log="CustomLog \"$wwwlogs_dir/${domain}_apache.log\" common"
     echo "You access log file=$wwwlogs_dir/${domain}_apache.log"
     echo "You access log file=$wwwlogs_dir/${domain}_apache.log"
-fi
+  fi
 }
 }
 
 
 Create_apache_conf() {
 Create_apache_conf() {
-[ "`$apache_install_dir/bin/apachectl -v | awk -F'.' /version/'{print $2}'`" == '4' ] && R_TMP='Require all granted' || R_TMP=
-[ ! -d $apache_install_dir/conf/vhost ] && mkdir $apache_install_dir/conf/vhost
-cat > $apache_install_dir/conf/vhost/$domain.conf << EOF
+  [ "`$apache_install_dir/bin/apachectl -v | awk -F'.' /version/'{print $2}'`" == '4' ] && R_TMP='Require all granted' || R_TMP=
+  [ ! -d $apache_install_dir/conf/vhost ] && mkdir $apache_install_dir/conf/vhost
+  cat > $apache_install_dir/conf/vhost/$domain.conf << EOF
 <VirtualHost *:80>
 <VirtualHost *:80>
     ServerAdmin admin@linuxeye.com
     ServerAdmin admin@linuxeye.com
     DocumentRoot "$vhostdir"
     DocumentRoot "$vhostdir"
@@ -610,7 +610,7 @@ cat > $apache_install_dir/conf/vhost/$domain.conf << EOF
 </Directory>
 </Directory>
 </VirtualHost>
 </VirtualHost>
 EOF
 EOF
-[ "$apache_ssl_yn" == 'y' ] && cat >> $apache_install_dir/conf/vhost/$domain.conf << EOF
+  [ "$apache_ssl_yn" == 'y' ] && cat >> $apache_install_dir/conf/vhost/$domain.conf << EOF
 <VirtualHost *:443>
 <VirtualHost *:443>
     ServerAdmin admin@linuxeye.com
     ServerAdmin admin@linuxeye.com
     DocumentRoot "$vhostdir"
     DocumentRoot "$vhostdir"
@@ -631,32 +631,32 @@ EOF
 </VirtualHost>
 </VirtualHost>
 EOF
 EOF
 
 
-echo
-$apache_install_dir/bin/apachectl -t
-if [ $? == 0 ];then
+  echo
+  $apache_install_dir/bin/apachectl -t
+  if [ $? == 0 ]; then
     echo "Restart Apache......"
     echo "Restart Apache......"
     /etc/init.d/httpd restart
     /etc/init.d/httpd restart
-else
+  else
     rm -rf $apache_install_dir/conf/vhost/$domain.conf
     rm -rf $apache_install_dir/conf/vhost/$domain.conf
     echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
     echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
     exit 1
     exit 1
-fi
+  fi
 
 
-printf "
+  printf "
 #######################################################################
 #######################################################################
 #       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
 #       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
 #       For more information please visit https://oneinstack.com      #
 #       For more information please visit https://oneinstack.com      #
 #######################################################################
 #######################################################################
 "
 "
-echo "`printf "%-30s" "Your domain:"`${CMSG}$domain${CEND}"
-echo "`printf "%-30s" "Virtualhost conf:"`${CMSG}$apache_install_dir/conf/vhost/$domain.conf${CEND}"
-echo "`printf "%-30s" "Directory of:"`${CMSG}$vhostdir${CEND}"
+  echo "`printf "%-30s" "Your domain:"`${CMSG}$domain${CEND}"
+  echo "`printf "%-30s" "Virtualhost conf:"`${CMSG}$apache_install_dir/conf/vhost/$domain.conf${CEND}"
+  echo "`printf "%-30s" "Directory of:"`${CMSG}$vhostdir${CEND}"
 }
 }
 
 
 Create_nginx_apache_mod-php_conf() {
 Create_nginx_apache_mod-php_conf() {
-# Nginx/Tengine/OpenResty
-[ ! -d $web_install_dir/conf/vhost ] && mkdir $web_install_dir/conf/vhost
-cat > $web_install_dir/conf/vhost/$domain.conf << EOF
+  # Nginx/Tengine/OpenResty
+  [ ! -d $web_install_dir/conf/vhost ] && mkdir $web_install_dir/conf/vhost
+  cat > $web_install_dir/conf/vhost/$domain.conf << EOF
 server {
 server {
 $Nginx_conf
 $Nginx_conf
 server_name $domain$moredomainame;
 server_name $domain$moredomainame;
@@ -687,22 +687,22 @@ location ~ .*\.(js|css)?$ {
 }
 }
 EOF
 EOF
 
 
-[ "$https_yn" == 'y' ] && sed -i "s@^root.*;@&\nif (\$ssl_protocol = \"\") { return 301 https://\$host\$request_uri; }@" $web_install_dir/conf/vhost/$domain.conf
+  [ "$https_yn" == 'y' ] && sed -i "s@^root.*;@&\nif (\$ssl_protocol = \"\") { return 301 https://\$host\$request_uri; }@" $web_install_dir/conf/vhost/$domain.conf
 
 
-echo
-$web_install_dir/sbin/nginx -t
-if [ $? == 0 ];then
+  echo
+  $web_install_dir/sbin/nginx -t
+  if [ $? == 0 ]; then
     echo "Reload Nginx......"
     echo "Reload Nginx......"
     $web_install_dir/sbin/nginx -s reload
     $web_install_dir/sbin/nginx -s reload
-else
+  else
     rm -rf $web_install_dir/conf/vhost/$domain.conf
     rm -rf $web_install_dir/conf/vhost/$domain.conf
     echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
     echo "Create virtualhost ... [${CFAILURE}FAILED${CEND}]"
-fi
+  fi
 
 
-# Apache
-[ "`$apache_install_dir/bin/apachectl -v | awk -F'.' /version/'{print $2}'`" == '4' ] && R_TMP='Require all granted' || R_TMP=
-[ ! -d $apache_install_dir/conf/vhost ] && mkdir $apache_install_dir/conf/vhost
-cat > $apache_install_dir/conf/vhost/$domain.conf << EOF
+  # Apache
+  [ "`$apache_install_dir/bin/apachectl -v | awk -F'.' /version/'{print $2}'`" == '4' ] && R_TMP='Require all granted' || R_TMP=
+  [ ! -d $apache_install_dir/conf/vhost ] && mkdir $apache_install_dir/conf/vhost
+  cat > $apache_install_dir/conf/vhost/$domain.conf << EOF
 <VirtualHost *:88>
 <VirtualHost *:88>
     ServerAdmin admin@linuxeye.com
     ServerAdmin admin@linuxeye.com
     DocumentRoot "$vhostdir"
     DocumentRoot "$vhostdir"
@@ -723,232 +723,231 @@ cat > $apache_install_dir/conf/vhost/$domain.conf << EOF
 </VirtualHost>
 </VirtualHost>
 EOF
 EOF
 
 
-echo
-$apache_install_dir/bin/apachectl -t
-if [ $? == 0 ];then
+  echo
+  $apache_install_dir/bin/apachectl -t
+  if [ $? == 0 ]; then
     echo "Restart Apache......"
     echo "Restart Apache......"
     /etc/init.d/httpd restart
     /etc/init.d/httpd restart
-else
+  else
     rm -rf $apache_install_dir/conf/vhost/$domain.conf
     rm -rf $apache_install_dir/conf/vhost/$domain.conf
     exit 1
     exit 1
-fi
+  fi
 
 
-printf "
+  printf "
 #######################################################################
 #######################################################################
 #       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
 #       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
 #       For more information please visit https://oneinstack.com      #
 #       For more information please visit https://oneinstack.com      #
 #######################################################################
 #######################################################################
 "
 "
-echo "`printf "%-30s" "Your domain:"`${CMSG}$domain${CEND}"
-echo "`printf "%-30s" "Nginx Virtualhost conf:"`${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND}"
-echo "`printf "%-30s" "Apache Virtualhost conf:"`${CMSG}$apache_install_dir/conf/vhost/$domain.conf${CEND}"
-echo "`printf "%-30s" "Directory of:"`${CMSG}$vhostdir${CEND}"
-[ "$rewrite_yn" == 'y' ] && echo "`printf "%-28s" "Rewrite rule:"`${CMSG}$web_install_dir/conf/rewrite/$rewrite.conf${CEND}"
-[ "$nginx_ssl_yn" == 'y' ] && Print_ssl
+  echo "`printf "%-30s" "Your domain:"`${CMSG}$domain${CEND}"
+  echo "`printf "%-30s" "Nginx Virtualhost conf:"`${CMSG}$web_install_dir/conf/vhost/$domain.conf${CEND}"
+  echo "`printf "%-30s" "Apache Virtualhost conf:"`${CMSG}$apache_install_dir/conf/vhost/$domain.conf${CEND}"
+  echo "`printf "%-30s" "Directory of:"`${CMSG}$vhostdir${CEND}"
+  [ "$rewrite_yn" == 'y' ] && echo "`printf "%-28s" "Rewrite rule:"`${CMSG}$web_install_dir/conf/rewrite/$rewrite.conf${CEND}"
+  [ "$nginx_ssl_yn" == 'y' ] && Print_ssl
 }
 }
 
 
 Add_Vhost() {
 Add_Vhost() {
-    if [ -e "$web_install_dir/sbin/nginx" -a ! -e "$apache_install_dir/conf/httpd.conf" ];then
-        Choose_env
-        Input_Add_domain
-        Nginx_anti_hotlinking
-        if [ "$NGX_FLAG" == 'java' ];then
-            Nginx_log
-            Create_nginx_tomcat_conf
-        else
-            Nginx_rewrite
-            Nginx_log
-            Create_nginx_php-fpm_hhvm_conf
-        fi
-    elif [ ! -e "$web_install_dir/sbin/nginx" -a -e "$apache_install_dir/conf/httpd.conf" ];then
-        Choose_env
-        Input_Add_domain
-        Apache_log
-        Create_apache_conf
-    elif [ ! -e "$web_install_dir/sbin/nginx" -a ! -e "$apache_install_dir/conf/httpd.conf" -a -e "$tomcat_install_dir/conf/server.xml" ];then
-        Choose_env
-        Input_Add_domain
-        Create_tomcat_conf
-    elif [ -e "$web_install_dir/sbin/nginx" -a -e "`ls $apache_install_dir/modules/libphp?.so 2>/dev/null`" ];then
-        Choose_env
-        Input_Add_domain
-        Nginx_anti_hotlinking
-        if [ "$NGX_FLAG" == 'java' ];then
-            Nginx_log
-            Create_nginx_tomcat_conf
-        elif [ "$NGX_FLAG" == 'hhvm' ];then
-            Nginx_rewrite
-            Nginx_log
-            Create_nginx_php-fpm_hhvm_conf
-        elif [ "$NGX_FLAG" == 'php' ];then
-            #Nginx_rewrite
-            Nginx_log
-            Apache_log
-            Create_nginx_apache_mod-php_conf
-        fi
+  if [ -e "$web_install_dir/sbin/nginx" -a ! -e "$apache_install_dir/conf/httpd.conf" ]; then
+    Choose_env
+    Input_Add_domain
+    Nginx_anti_hotlinking
+    if [ "$NGX_FLAG" == 'java' ]; then
+      Nginx_log
+      Create_nginx_tomcat_conf
+    else
+      Nginx_rewrite
+      Nginx_log
+      Create_nginx_php-fpm_hhvm_conf
     fi
     fi
+  elif [ ! -e "$web_install_dir/sbin/nginx" -a -e "$apache_install_dir/conf/httpd.conf" ]; then
+    Choose_env
+    Input_Add_domain
+    Apache_log
+    Create_apache_conf
+  elif [ ! -e "$web_install_dir/sbin/nginx" -a ! -e "$apache_install_dir/conf/httpd.conf" -a -e "$tomcat_install_dir/conf/server.xml" ]; then
+    Choose_env
+    Input_Add_domain
+    Create_tomcat_conf
+  elif [ -e "$web_install_dir/sbin/nginx" -a -e "`ls $apache_install_dir/modules/libphp?.so 2>/dev/null`" ]; then
+    Choose_env
+    Input_Add_domain
+    Nginx_anti_hotlinking
+    if [ "$NGX_FLAG" == 'java' ]; then
+      Nginx_log
+      Create_nginx_tomcat_conf
+    elif [ "$NGX_FLAG" == 'hhvm' ]; then
+      Nginx_rewrite
+      Nginx_log
+      Create_nginx_php-fpm_hhvm_conf
+    elif [ "$NGX_FLAG" == 'php' ]; then
+      #Nginx_rewrite
+      Nginx_log
+      Apache_log
+      Create_nginx_apache_mod-php_conf
+    fi
+  fi
 }
 }
 
 
 Del_NGX_Vhost() {
 Del_NGX_Vhost() {
-    if [ -e "$web_install_dir/sbin/nginx" ];then
-        [ -d "$web_install_dir/conf/vhost" ] && Domain_List=`ls $web_install_dir/conf/vhost | sed "s@.conf@@g"`
-        if [ -n "$Domain_List" ];then
-            echo
-            echo "Virtualhost list:"
-        echo ${CMSG}$Domain_List${CEND}
+  if [ -e "$web_install_dir/sbin/nginx" ]; then
+    [ -d "$web_install_dir/conf/vhost" ] && Domain_List=`ls $web_install_dir/conf/vhost | sed "s@.conf@@g"`
+    if [ -n "$Domain_List" ]; then
+      echo
+      echo "Virtualhost list:"
+      echo ${CMSG}$Domain_List${CEND}
+      while :; do echo
+        read -p "Please input a domain you want to delete: " domain
+        if [ -z "`echo $domain | grep '.*\..*'`" ]; then
+          echo "${CWARNING}input error! ${CEND}"
+        else
+          if [ -e "$web_install_dir/conf/vhost/${domain}.conf" ]; then
+            Directory=`grep ^root $web_install_dir/conf/vhost/${domain}.conf | awk -F'[ ;]' '{print $2}'`
+            rm -rf $web_install_dir/conf/vhost/${domain}.conf
+            $web_install_dir/sbin/nginx -s reload
             while :; do echo
             while :; do echo
-                read -p "Please input a domain you want to delete: " domain
-                if [ -z "`echo $domain | grep '.*\..*'`" ]; then
-                    echo "${CWARNING}input error! ${CEND}"
-                else
-                    if [ -e "$web_install_dir/conf/vhost/${domain}.conf" ];then
-                        Directory=`grep ^root $web_install_dir/conf/vhost/${domain}.conf | awk -F'[ ;]' '{print $2}'`
-                        rm -rf $web_install_dir/conf/vhost/${domain}.conf
-                        $web_install_dir/sbin/nginx -s reload
-                        while :; do echo
-                            read -p "Do you want to delete Virtul Host directory? [y/n]: " Del_Vhost_wwwroot_yn
-                            if [[ ! $Del_Vhost_wwwroot_yn =~ ^[y,n]$ ]];then
-                                echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
-                            else
-                                break
-                            fi
-                        done
-                        if [ "$Del_Vhost_wwwroot_yn" == 'y' ];then
-                            echo "Press Ctrl+c to cancel or Press any key to continue..."
-                            char=`get_char`
-                            rm -rf $Directory
-                        fi
-                        echo "${CSUCCESS}Domain: ${domain} has been deleted.${CEND}"
-                    else
-                        echo "${CWARNING}Virtualhost: $domain was not exist! ${CEND}"
-                    fi
-                    break
-                fi
+              read -p "Do you want to delete Virtul Host directory? [y/n]: " Del_Vhost_wwwroot_yn
+              if [[ ! $Del_Vhost_wwwroot_yn =~ ^[y,n]$ ]]; then
+                echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+              else
+                break
+              fi
             done
             done
-
-        else
-            echo "${CWARNING}Virtualhost was not exist! ${CEND}"
+            if [ "$Del_Vhost_wwwroot_yn" == 'y' ]; then
+              echo "Press Ctrl+c to cancel or Press any key to continue..."
+              char=`get_char`
+              rm -rf $Directory
+            fi
+            echo "${CSUCCESS}Domain: ${domain} has been deleted.${CEND}"
+          else
+            echo "${CWARNING}Virtualhost: $domain was not exist! ${CEND}"
+          fi
+          break
         fi
         fi
+      done
+    else
+      echo "${CWARNING}Virtualhost was not exist! ${CEND}"
     fi
     fi
+  fi
 }
 }
 
 
 Del_Apache_Vhost() {
 Del_Apache_Vhost() {
-    if [ -e "$apache_install_dir/conf/httpd.conf" ];then
-        if [ -e "$web_install_dir/sbin/nginx" ];then
-            rm -rf $apache_install_dir/conf/vhost/${domain}.conf
-            /etc/init.d/httpd restart
-        else
-            Domain_List=`ls $apache_install_dir/conf/vhost | grep -v '0.conf' | sed "s@.conf@@g"`
-            if [ -n "$Domain_List" ];then
-                echo
-                echo "Virtualhost list:"
-                echo ${CMSG}$Domain_List${CEND}
-                while :; do echo
-                    read -p "Please input a domain you want to delete: " domain
-                    if [ -z "`echo $domain | grep '.*\..*'`" ]; then
-                        echo "${CWARNING}input error! ${CEND}"
-                    else
-                        if [ -e "$apache_install_dir/conf/vhost/${domain}.conf" ];then
-                            Directory=`grep '^<Directory' $apache_install_dir/conf/vhost/${domain}.conf | awk -F'"' '{print $2}'`
-                            rm -rf $apache_install_dir/conf/vhost/${domain}.conf
-                            /etc/init.d/httpd restart
-                            while :; do echo
-                                read -p "Do you want to delete Virtul Host directory? [y/n]: " Del_Vhost_wwwroot_yn
-                                if [[ ! $Del_Vhost_wwwroot_yn =~ ^[y,n]$ ]];then
-                                    echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
-                                else
-                                    break
-                                fi
-                            done
-
-                            if [ "$Del_Vhost_wwwroot_yn" == 'y' ];then
-                                echo "Press Ctrl+c to cancel or Press any key to continue..."
-                                char=`get_char`
-                                rm -rf $Directory
-                            fi
-                            echo "${CSUCCESS}Domain: ${domain} has been deleted.${CEND}"
-                        else
-                            echo "${CWARNING}Virtualhost: $domain was not exist! ${CEND}"
-                        fi
-                        break
-                    fi
-                done
-
+  if [ -e "$apache_install_dir/conf/httpd.conf" ]; then
+    if [ -e "$web_install_dir/sbin/nginx" ]; then
+      rm -rf $apache_install_dir/conf/vhost/${domain}.conf
+      /etc/init.d/httpd restart
+    else
+      Domain_List=`ls $apache_install_dir/conf/vhost | grep -v '0.conf' | sed "s@.conf@@g"`
+      if [ -n "$Domain_List" ]; then
+        echo
+        echo "Virtualhost list:"
+        echo ${CMSG}$Domain_List${CEND}
+        while :; do echo
+          read -p "Please input a domain you want to delete: " domain
+          if [ -z "`echo $domain | grep '.*\..*'`" ]; then
+            echo "${CWARNING}input error! ${CEND}"
+          else
+            if [ -e "$apache_install_dir/conf/vhost/${domain}.conf" ]; then
+              Directory=`grep '^<Directory' $apache_install_dir/conf/vhost/${domain}.conf | awk -F'"' '{print $2}'`
+              rm -rf $apache_install_dir/conf/vhost/${domain}.conf
+              /etc/init.d/httpd restart
+              while :; do echo
+                read -p "Do you want to delete Virtul Host directory? [y/n]: " Del_Vhost_wwwroot_yn
+                if [[ ! $Del_Vhost_wwwroot_yn =~ ^[y,n]$ ]]; then
+                  echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+                else
+                  break
+                fi
+              done
+
+              if [ "$Del_Vhost_wwwroot_yn" == 'y' ]; then
+                echo "Press Ctrl+c to cancel or Press any key to continue..."
+                char=`get_char`
+                rm -rf $Directory
+              fi
+              echo "${CSUCCESS}Domain: ${domain} has been deleted.${CEND}"
             else
             else
-                echo "${CWARNING}Virtualhost was not exist! ${CEND}"
+              echo "${CWARNING}Virtualhost: $domain was not exist! ${CEND}"
             fi
             fi
-        fi
+            break
+          fi
+        done
+
+      else
+        echo "${CWARNING}Virtualhost was not exist! ${CEND}"
+      fi
     fi
     fi
+  fi
 }
 }
 
 
 Del_Tomcat_Vhost() {
 Del_Tomcat_Vhost() {
-    if [ -e "$tomcat_install_dir/conf/server.xml" ];then
-        if [ -e "$web_install_dir/sbin/nginx" ];then
-            if [ -n "`grep vhost-${domain} $tomcat_install_dir/conf/server.xml`" ];then
-                sed -i /vhost-${domain}/d $tomcat_install_dir/conf/server.xml
-                rm -rf $tomcat_install_dir/conf/vhost/${domain}.xml
-                /etc/init.d/tomcat restart
-            fi
-        else
-            Domain_List=`ls $tomcat_install_dir/conf/vhost | grep -v 'localhost.xml' | sed "s@.xml@@g"`
-            if [ -n "$Domain_List" ];then
-                echo
-                echo "Virtualhost list:"
-                echo ${CMSG}$Domain_List${CEND}
-                while :; do echo
-                    read -p "Please input a domain you want to delete: " domain
-                    if [ -z "`echo $domain | grep '.*\..*'`" ]; then
-                        echo "${CWARNING}input error! ${CEND}"
-                    else
-                        if [ -n "`grep vhost-${domain} $tomcat_install_dir/conf/server.xml`" ];then
-                            sed -i /vhost-${domain}/d $tomcat_install_dir/conf/server.xml
-                            rm -rf $tomcat_install_dir/conf/vhost/${domain}.xml
-                            /etc/init.d/tomcat restart
-                            while :; do echo
-                                read -p "Do you want to delete Virtul Host directory? [y/n]: " Del_Vhost_wwwroot_yn
-                                if [[ ! $Del_Vhost_wwwroot_yn =~ ^[y,n]$ ]];then
-                                    echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
-                                else
-                                    break
-                                fi
-                            done
-
-                            if [ "$Del_Vhost_wwwroot_yn" == 'y' ];then
-                                echo "Press Ctrl+c to cancel or Press any key to continue..."
-                                char=`get_char`
-                                rm -rf $Directory
-                            fi
-                            echo "${CSUCCESS}Domain: ${domain} has been deleted.${CEND}"
-                        else
-                            echo "${CWARNING}Virtualhost: $domain was not exist! ${CEND}"
-                        fi
-                        break
-                    fi
-                done
-
+  if [ -e "$tomcat_install_dir/conf/server.xml" ]; then
+    if [ -e "$web_install_dir/sbin/nginx" ]; then
+      if [ -n "`grep vhost-${domain} $tomcat_install_dir/conf/server.xml`" ]; then
+        sed -i /vhost-${domain}/d $tomcat_install_dir/conf/server.xml
+        rm -rf $tomcat_install_dir/conf/vhost/${domain}.xml
+        /etc/init.d/tomcat restart
+      fi
+    else
+      Domain_List=`ls $tomcat_install_dir/conf/vhost | grep -v 'localhost.xml' | sed "s@.xml@@g"`
+      if [ -n "$Domain_List" ]; then
+        echo
+        echo "Virtualhost list:"
+        echo ${CMSG}$Domain_List${CEND}
+        while :; do echo
+          read -p "Please input a domain you want to delete: " domain
+          if [ -z "`echo $domain | grep '.*\..*'`" ]; then
+            echo "${CWARNING}input error! ${CEND}"
+          else
+            if [ -n "`grep vhost-${domain} $tomcat_install_dir/conf/server.xml`" ]; then
+              sed -i /vhost-${domain}/d $tomcat_install_dir/conf/server.xml
+              rm -rf $tomcat_install_dir/conf/vhost/${domain}.xml
+              /etc/init.d/tomcat restart
+              while :; do echo
+                read -p "Do you want to delete Virtul Host directory? [y/n]: " Del_Vhost_wwwroot_yn
+                if [[ ! $Del_Vhost_wwwroot_yn =~ ^[y,n]$ ]]; then
+                  echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+                else
+                  break
+                fi
+              done
+
+              if [ "$Del_Vhost_wwwroot_yn" == 'y' ]; then
+                echo "Press Ctrl+c to cancel or Press any key to continue..."
+                char=`get_char`
+                rm -rf $Directory
+              fi
+              echo "${CSUCCESS}Domain: ${domain} has been deleted.${CEND}"
             else
             else
-                echo "${CWARNING}Virtualhost was not exist! ${CEND}"
+              echo "${CWARNING}Virtualhost: $domain was not exist! ${CEND}"
             fi
             fi
-        fi
+            break
+          fi
+        done
+
+      else
+        echo "${CWARNING}Virtualhost was not exist! ${CEND}"
+      fi
     fi
     fi
+  fi
 }
 }
 
 
-if [ $# == 0 ];then
+if [ $# == 0 ]; then
+  Add_Vhost
+elif [ $# == 1 ]; then
+  case $1 in
+  add)
     Add_Vhost
     Add_Vhost
-elif [ $# == 1 ];then
-    case $1 in
-    add)
-        Add_Vhost
-        ;;
-    del)
-        Del_NGX_Vhost
-        Del_Apache_Vhost
-        Del_Tomcat_Vhost
-        ;;
-    *)
-        Usage
-        ;;
-    esac
-else
+    ;;
+  del)
+    Del_NGX_Vhost
+    Del_Apache_Vhost
+    Del_Tomcat_Vhost
+    ;;
+  *)
     Usage
     Usage
+    ;;
+  esac
+else
+  Usage
 fi
 fi

Some files were not shown because too many files changed in this diff