瀏覽代碼

Update by kaneawk

lj2007331 8 年之前
父節點
當前提交
b1e617e9a9

+ 278 - 270
addons.sh

@@ -19,7 +19,7 @@ printf "
 "
 
 # get pwd
-sed -i "s@^oneinstack_dir.*@oneinstack_dir=`pwd`@" ./options.conf
+sed -i "s@^oneinstack_dir.*@oneinstack_dir=$(pwd)@" ./options.conf
 
 . ./versions.txt
 . ./options.conf
@@ -33,8 +33,7 @@ sed -i "s@^oneinstack_dir.*@oneinstack_dir=`pwd`@" ./options.conf
 . ./include/zendopcache.sh
 . ./include/xcache.sh
 . ./include/apcu.sh
-. ./include/eaccelerator-0.9.sh
-. ./include/eaccelerator-1.0-dev.sh
+. ./include/eaccelerator.sh
 
 . ./include/ZendGuardLoader.sh
 . ./include/ioncube.sh
@@ -47,62 +46,62 @@ sed -i "s@^oneinstack_dir.*@oneinstack_dir=`pwd`@" ./options.conf
 . ./include/redis.sh
 
 # Check if user is root
-[ $(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
-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`
+if [ -e "${php_install_dir}/bin/phpize" ]; then
+  phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
+  PHP_detail_version=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
   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
+
+  case "${PHP_main_version}" in
+    "5.3")
+      PHP_version=1
+      ;;
+    "5.4")
+      PHP_version=2
+      ;;
+    "5.5")
+      PHP_version=3
+      ;;
+    "5.6")
+      PHP_version=4
+      ;;
+    "7.0" | "7.1")
+      PHP_version=5
+      ;;
+    *)
+      echo "${CFAILURE}Your PHP version ${PHP_main_version} is not supported! ${CEND}"
+      kill -9 $$
+      ;;
+  esac
+else
+  echo "${CFAILURE}Couldn't find phpize! ${CEND}"
+  kill -9 $$
 fi
 
 # Check PHP Extensions
 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() {
-  [ -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() {
-  [ -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() {
-  [ -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
-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
-[opcache]
-zend_extension=opcache.so
-opcache.enable=1
-opcache.memory_consumption=$Memory_limit
-opcache.interned_strings_buffer=8
-opcache.max_accelerated_files=4000
-opcache.revalidate_freq=60
-opcache.save_comments=0
-opcache.fast_shutdown=1
-opcache.enable_cli=1
-;opcache.optimization_level=0
-EOF
+  [ -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}"; }
 }
 
 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
 [epel]
 name=Extra Packages for Enterprise Linux 7 - \$basearch
@@ -112,7 +111,7 @@ failovermethod=priority
 enabled=1
 gpgcheck=0
 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
 [epel]
 name=Extra Packages for Enterprise Linux 6 - \$basearch
@@ -124,34 +123,35 @@ gpgcheck=0
 EOF
   fi
 
-  pushd $oneinstack_dir/src
+  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
+  popd
   if [ -e "/root/.local/share/letsencrypt/bin/letsencrypt" ] && certbot-auto -h | grep '\-\-standalone' > /dev/null ; then
     echo; echo "${CSUCCESS}Let's Encrypt client installed successfully! ${CEND}"
   else
-    echo; echo "${CFAILURE}Let's Encrypt client install failed, Please install again! ${CEND}"
+    echo; echo "${CSUCCESS}Let's Encrypt client install failed, Please try again! ${CEND}"
   fi
 }
 
 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
+  [ "${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() {
   while :; do
     echo
-    echo 'Please select an action:'
+    echo "Please select an action:"
     echo -e "\t${CMSG}1${CEND}. install"
     echo -e "\t${CMSG}2${CEND}. uninstall"
     read -p "Please input a number:(Default 1 press Enter) " ACTION
-    [ -z "$ACTION" ] && ACTION=1
-    if [[ ! $ACTION =~ ^[1,2]$ ]]; then
+    [ -z "${ACTION}" ] && ACTION=1
+    if [[ ! "${ACTION}" =~ ^[1,2]$ ]]; then
       echo "${CWARNING}input error! Please only input number 1,2${CEND}"
     else
       break
@@ -172,253 +172,261 @@ What Are You Doing?
 \t${CMSG}q${CEND}. Exit
 "
   read -p "Please input the correct option: " Number
-  if [[ ! $Number =~ ^[1-7,q]$ ]]; then
+  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}"
+    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
+            case "${PHP_cache}" in
+              1)
+                PHP_extension=opcache
+                ;;
+              2)
+                PHP_extension=xcache
+                ;;
+              3)
+                PHP_extension=apcu
+                ;;
+              4)
+                PHP_extension=eaccelerator
+                ;;
+            esac
+            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
+            case "${PHP_cache}" in
+              1)
+                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
+                else
+                  src_url=http://www.php.net/distributions/php-${PHP_detail_version}.tar.gz && Download_src
+                  Install_ZendOPcache
+                fi
+                popd
+                Check_succ
+                ;;
+              2)
+                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
+                  echo "${CWARNING}Your php does not support XCache! ${CEND}"; exit 1
+                fi
+                ;;
+              3)
+                if [[ "${PHP_main_version}" =~ ^5.[3-6]$|^7.[0-1]$ ]]; then
+                  checkDownload
+                  Install_APCU
+                  Check_succ
+                else
+                  echo "${CWARNING}Your php does not support APCU! ${CEND}"; exit 1
+                fi
+                ;;
+              4)
+                if [[ "${PHP_main_version}" =~ ^5.[3-4]$ ]]; then
+                  checkDownload
+                  Install_eAccelerator
+                  Check_succ
+                else
+                  echo "${CWARNING}Your php does not support eAccelerator! ${CEND}"; exit 1
+                fi
+                ;;
+            esac
+          fi
         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
+          Uninstall_succ
         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
-            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
+        ;;
+      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 "${CWARNING}Your php does not support XCache! ${CEND}"; exit 1
+              echo; echo "${CWARNING}Your php ${PHP_detail_version} or platform ${TARGET_ARCH} does not support ${PHP_extension}! ${CEND}";
             fi
-          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
+          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 "${CWARNING}Your php does not support eAccelerator! ${CEND}"; exit 1
+              echo; echo "${CWARNING}Your php ${PHP_detail_version} or platform ${TARGET_ARCH} does not support ${PHP_extension}! ${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
+          Uninstall_succ
         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
+        ;;
+      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
-            echo; echo "${CWARNING}Your php ${PHP_detail_version} or platform arm does not support ${PHP_extension}! ${CEND}";
+            [ "${Magick}" = '1' ] && PHP_extension=imagick
+            [ "${Magick}" = '2' ] && PHP_extension=gmagick
+            break
           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}";
+        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
-        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
+          Uninstall_succ
+          [ -d "/usr/local/imagemagick" ] && rm -rf /usr/local/imagemagick
+          [ -d "/usr/local/graphicsmagick" ] && rm -rf /usr/local/graphicsmagick
         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
+        ;;
+      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
+          popd
+          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
+          popd
+          echo "extension=fileinfo.so" > ${php_install_dir}/etc/php.d/ext-fileinfo.ini
           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
+          Uninstall_succ
         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
+        ;;
+      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
-          [ ! -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}"; }
+          case "${Memcache}" in
+            1)
+              [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached
+              Check_PHP_Extension
+              Install_php-memcache
+              Check_succ
+              ;;
+            2)
+              [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached
+              Check_PHP_Extension
+              Install_php-memcached
+              Check_succ
+              ;;
+            3)
+              [ ! -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}"; }
+              ;;
+          esac
+        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
-      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
+        ;;
+      6)
+        ACTION_FUN
+        PHP_extension=redis
         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)
+        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

+ 1 - 1
config/nginx.conf

@@ -76,7 +76,7 @@ http {
         fastcgi_index index.php;
         include fastcgi.conf;
         }
-    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
+    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
         expires 30d;
         access_log off;
         }

+ 1 - 1
config/nginx_apache.conf

@@ -81,7 +81,7 @@ http {
         proxy_pass http://127.0.0.1:88;
         include proxy.conf;
         }
-    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
+    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
         expires 30d;
         access_log off;
         }

+ 1 - 1
config/nginx_tomcat.conf

@@ -70,7 +70,7 @@ http {
         allow 127.0.0.1;
         deny all;
         }
-    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
+    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
         expires 30d;
         access_log off;
         }

File diff suppressed because it is too large
+ 513 - 467
include/check_download.sh


+ 32 - 20
include/check_os.sh

@@ -16,20 +16,30 @@ if [ -n "$(grep 'Aliyun Linux release' /etc/issue)" -o -e /etc/redhat-release ];
 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
+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
+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
+# kali rolling
+elif [ -n "$(grep 'Kali GNU/Linux Rolling' /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == "Kali" ]; then
+  OS=Debian
+  [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
+  if [ -n "$(grep 'VERSION="2016.*"' /etc/os-release)" ]; then
+    Debian_version=8
+  else
+    echo "${CFAILURE}Does not support this OS, Please contact the author! ${CEND}"
+    kill -9 $$
+  fi
+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
-elif [ -n "$(grep elementary /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == 'elementary' ]; then
+elif [ -n "$(grep 'elementary' /etc/issue)" -o "$(lsb_release -is 2>/dev/null)" == 'elementary' ]; then
   OS=Ubuntu
   [ ! -e "$(which lsb_release)" ] && { apt-get -y update; apt-get -y install lsb-release; clear; }
   Ubuntu_version=16
@@ -38,18 +48,7 @@ else
   kill -9 $$
 fi
 
-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
-fi
-
-if [ $(getconf WORD_BIT) == 32 ] && [ $(getconf LONG_BIT) == 64 ]; then
+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
@@ -62,19 +61,32 @@ 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 == '0' ] && GLIBC_FLAG=linux-glibc_214 || GLIBC_FLAG=linux
 
+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
+fi
+
 THREAD=$(grep 'processor' /proc/cpuinfo | sort -u | wc -l)
 
 # Percona
-if [ -f "/usr/lib/x86_64-linux-gnu/libssl.so.1.0.0" ]; then
-  if [ "${Debian_version}" == "6" ]; then
+if [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]]; 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
+elif [ "${OS}" == "CentOS" ]; then
+  if [ "${CentOS_RHEL_version}" == '5' ]; then
     sslLibVer=ssl098e
   else
     sslLibVer=ssl101
   fi
+else
+  sslLibVer=unknown
 fi

+ 167 - 0
include/check_sw.sh

@@ -0,0 +1,167 @@
+#!/bin/bash
+# Author:  Alpha Eva <kaneawk AT gmail.com>
+#
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       https://oneinstack.com
+#       https://github.com/lj2007331/oneinstack
+
+installDepsDebian() {
+  echo "${CMSG}Removing the conflicting packages...${CEND}"
+  pkgList="apache2 apache2-data 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 ${pkgList};do
+      apt-get -y remove --purge ${Package}
+  done
+  dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
+
+  apt-get -y update
+  echo "${CMSG}Installing dependencies packages...${CEND}"
+  # critical security updates
+  grep security /etc/apt/sources.list > /tmp/security.sources.list
+  apt-get -y upgrade -o Dir::Etc::SourceList=/tmp/security.sources.list
+
+  apt-get autoremove
+
+  # Install needed packages
+  case "${Debian_version}" in
+    [6,7])
+      pkgList="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 numactl 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 wget"
+      ;;
+    8)
+      pkgList="gcc g++ make cmake autoconf libjpeg8 libjpeg62-turbo-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 numactl 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 wget"
+      ;;
+    *)
+      echo "${CFAILURE}Your system Debian ${Debian_version} are not supported!${CEND}"
+      kill -9 $$
+      ;;
+  esac
+
+  for Package in ${pkgList}; do
+    apt-get -y install ${Package}
+  done
+}
+
+installDepsCentOS() {
+  sed -i 's@^exclude@#exclude@' /etc/yum.conf
+  yum clean all
+
+  yum makecache
+  # Uninstall the conflicting packages
+  echo "${CMSG}Removing the conflicting packages...${CEND}"
+  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
+
+  echo "${CMSG}Installing dependencies packages...${CEND}"
+  yum check-update
+  # Install needed packages
+  pkgList="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 numactl-libs 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 wget"
+  for Package in ${pkgList}; do
+    yum -y install ${Package}
+  done
+
+  yum -y update bash openssl glibc
+
+  # 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"
+  fi
+}
+
+installDepsUbuntu() {
+  # Uninstall the conflicting software
+  echo "${CMSG}Removing the conflicting packages...${CEND}"
+  pkgList="apache2 apache2-data 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 ${pkgList}; do
+    apt-get -y remove --purge ${Package}
+  done
+  dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
+
+  apt-get autoremove
+
+  echo "${CMSG}Installing dependencies packages...${CEND}"
+  apt-get -y update
+  # critical security updates
+  grep security /etc/apt/sources.list > /tmp/security.sources.list
+  apt-get -y upgrade -o Dir::Etc::SourceList=/tmp/security.sources.list
+
+  # Install needed packages
+  pkgList="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 numactl 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 wget"
+  for Package in ${pkgList}; do
+    apt-get -y install ${Package} --force-yes
+  done
+
+  if [[ "${Ubuntu_version}" =~ ^14$|^15$ ]]; then
+    apt-get -y install libcloog-ppl1
+    apt-get -y remove bison
+    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
+  else
+    apt-get -y install bison libcloog-ppl1
+  fi
+}
+
+installDepsBySrc() {
+  pushd ${oneinstack_dir}/src
+
+  if [ "${OS}" == "Ubuntu" ]; then
+    if [[ "${Ubuntu_version}" =~ ^14$|^15$ ]]; then
+      # Install bison on ubt 14.x 15.x
+      tar xzf bison-${bison_version}.tar.gz
+      pushd bison-${bison_version}
+      ./configure
+      make -j ${THREAD} && make install
+      popd
+      rm -rf bison-${bison_version}
+    fi
+  elif [ "${OS}" == "CentOS" ]; then
+    # Install tmux
+    if [ ! -e "$(which tmux)" ]; then
+      # Install libevent first
+      tar xzf libevent-${libevent_version}.tar.gz
+      pushd libevent-${libevent_version}
+      ./configure
+      make -j ${THREAD} && make install
+      popd
+      rm -rf libevent-${libevent_version}
+
+      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
+      rm -rf tmux-${tmux_version}
+
+      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
+
+    # install htop
+    if [ ! -e "$(which htop)" ]; then
+      tar xzf htop-${htop_version}.tar.gz
+      pushd htop-${htop_version}
+      ./configure
+      make -j ${THREAD} && make install
+      popd
+      rm -rf htop-${htop_version}
+    fi
+  else
+    echo "No need to install software from source packages."
+  fi
+  popd
+}

+ 1 - 1
include/demo.sh

@@ -23,7 +23,7 @@ DEMO() {
       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
 
-    echo '<?php phpinfo() ?>' > ${wwwroot_dir}/default/phpinfo.php
+    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

+ 0 - 51
include/eaccelerator-1.0-dev.sh

@@ -1,51 +0,0 @@
-#!/bin/bash
-# Author:  yeho <lj2007331 AT gmail.com>
-# BLOG:  https://blog.linuxeye.com
-#
-# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
-#
-# Project home page:
-#       https://oneinstack.com
-#       https://github.com/lj2007331/oneinstack
-
-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
-  ${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]
-zend_extension=${phpExtensionDir}/eaccelerator.so
-eaccelerator.shm_size=64
-eaccelerator.cache_dir=/var/eaccelerator_cache
-eaccelerator.enable=1
-eaccelerator.optimizer=1
-eaccelerator.check_mtime=1
-eaccelerator.debug=0
-eaccelerator.filter=
-eaccelerator.shm_max=0
-eaccelerator.shm_ttl=0
-eaccelerator.shm_prune_period=0
-eaccelerator.shm_only=0
-eaccelerator.compress=0
-eaccelerator.compress_level=9
-eaccelerator.keys=disk_only
-eaccelerator.sessions=disk_only
-eaccelerator.content=disk_only
-EOF
-    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
-}

+ 18 - 6
include/eaccelerator-0.9.sh → include/eaccelerator.sh

@@ -8,11 +8,23 @@
 #       https://oneinstack.com
 #       https://github.com/lj2007331/oneinstack
 
-Install_eAccelerator-0-9() {
+Install_eAccelerator() {
   pushd ${oneinstack_dir}/src
-  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
-  tar jxf eaccelerator-${eaccelerator_version}.tar.bz2
-  pushd eaccelerator-${eaccelerator_version}
+  phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
+  case "${PHP_version}" in
+    1)
+      tar jxf eaccelerator-${eaccelerator_version}.tar.bz2
+      pushd eaccelerator-${eaccelerator_version}
+      ;;
+    2)
+      /bin/mv master eaccelerator-eaccelerator-42067ac.tar.gz
+      tar xzf eaccelerator-eaccelerator-42067ac.tar.gz
+      pushd eaccelerator-eaccelerator-42067ac
+      ;;
+    *)
+      echo "${CWARNING}Your php does not support eAccelerator! ${CEND}"
+      kill -9 $$
+  esac
   ${php_install_dir}/bin/phpize
   ./configure --enable-eaccelerator=shared --with-php-config=${php_install_dir}/bin/php-config
   make -j ${THREAD} && make install
@@ -40,9 +52,9 @@ eaccelerator.sessions=disk_only
 eaccelerator.content=disk_only
 EOF
     echo "${CSUCCESS}Accelerator module installed successfully! ${CEND}"
-    [ -z "`grep 'kernel.shmmax = 67108864' /etc/sysctl.conf`" ] && echo 'kernel.shmmax = 67108864' >> /etc/sysctl.conf
+    [ -z "$(grep 'kernel.shmmax = 67108864' /etc/sysctl.conf)" ] && echo "kernel.shmmax = 67108864" >> /etc/sysctl.conf
     sysctl -p
-    rm -rf eaccelerator-${eaccelerator_version}
+    rm -rf eaccelerator-${eaccelerator_version} eaccelerator-eaccelerator-42067ac
   else
     echo "${CFAILURE}Accelerator module install failed, Please contact the author! ${CEND}"
   fi

+ 20 - 20
include/hhvm_CentOS.sh

@@ -9,10 +9,11 @@
 #       https://github.com/lj2007331/oneinstack
 
 Install_hhvm_CentOS() {
-  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
+
+  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
 [epel]
 name=Extra Packages for Enterprise Linux 7 - \$basearch
@@ -33,7 +34,7 @@ EOF
     [ ! -e "/usr/bin/hhvm" -a "/usr/local/bin/hhvm" ] && ln -s /usr/local/bin/hhvm /usr/bin/hhvm
   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
 [epel]
 name=Extra Packages for Enterprise Linux 6 - \$basearch
@@ -43,12 +44,12 @@ failovermethod=priority
 enabled=1
 gpgcheck=0
 EOF
-
-    for Package in libmcrypt-devel glog-devel jemalloc-devel tbb-devel libdwarf-devel libxml2-devel libicu-devel pcre-devel gd-devel boost-devel sqlite-devel pam-devel bzip2-devel oniguruma-devel openldap-devel readline-devel libc-client-devel libcap-devel libevent-devel libcurl-devel libmemcached-devel lcms2 inotify-tools
-    do
-        yum -y install $Package
+    # Install needed packages
+    pkgList="libmcrypt-devel glog-devel jemalloc-devel tbb-devel libdwarf-devel libxml2-devel libicu-devel pcre-devel gd-devel boost-devel sqlite-devel pam-devel bzip2-devel oniguruma-devel openldap-devel readline-devel libc-client-devel libcap-devel libevent-devel libcurl-devel libmemcached-devel lcms2 inotify-tools"
+    for Package in ${pkgList}; do
+      yum -y install ${Package}
     done
-
+    # Uninstall the conflicting packages
     yum -y remove libwebp boost-system boost-filesystem
 
     cat > /etc/yum.repos.d/hhvm.repo << EOF
@@ -61,7 +62,7 @@ EOF
     yum --disablerepo=epel -y install mysql mysql-devel mysql-libs
     yum --disablerepo=epel -y install hhvm
   fi
-  
+
   userdel -r nginx;userdel -r saslauth
   rm -rf /var/log/hhvm
   mkdir /var/log/hhvm
@@ -126,13 +127,13 @@ memory_limit = 400000000
 post_max_size = 50000000
 EOF
 
-  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
-    [ -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
+  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
+    [ -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
     service nginx reload
   fi
-  
+
   rm -rf /etc/ld.so.conf.d/*_64.conf
   ldconfig
   # Supervisor
@@ -141,18 +142,17 @@ EOF
   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
+  [ -z "$(grep 'program:hhvm' /etc/supervisord.conf)" ] && cat >> /etc/supervisord.conf << EOF
 [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)
 directory=/tmp ; directory to cwd to before exec (def no cwd)
 autostart=true ; start at supervisord start (default: true)
 autorestart=unexpected ; whether/when to restart (default: unexpected)
 stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
 EOF
-  /bin/cp ../init.d/Supervisor-init-CentOS /etc/init.d/supervisord
+  /bin/cp ${oneinstack_dir}/init.d/Supervisor-init-CentOS /etc/init.d/supervisord
   chmod +x /etc/init.d/supervisord
   chkconfig supervisord on
   service supervisord start
-  popd
 }

+ 16 - 80
include/init_CentOS.sh

@@ -8,43 +8,11 @@
 #       https://oneinstack.com
 #       https://github.com/lj2007331/oneinstack
 
-sed -i 's@^exclude@#exclude@' /etc/yum.conf
-yum clean all
-
-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"
-fi
-
-yum check-update
-
-# 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 numactl 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
-  yum -y install $Package
-done
-
-yum -y update bash openssl glibc
-
-# 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"
-fi
-
 # closed Unnecessary services and remove obsolete rpm package
-[ "$CentOS_RHEL_version" == '7' ] && [ "`systemctl is-active NetworkManager.service`" == 'active' ] && NM_flag=1
-for Service in `chkconfig --list | grep 3:on | awk '{print $1}' | grep -vE 'nginx|httpd|tomcat|mysqld|php-fpm|pureftpd|redis-server|memcached|supervisord|aegis|NetworkManager'`;do chkconfig --level 3 $Service off;done
-[ "$NM_flag" == '1' ] && systemctl enable NetworkManager.service
-for Service in sshd network crond iptables messagebus irqbalance syslog rsyslog;do chkconfig --level 3 $Service on;done
+[ "${CentOS_RHEL_version}" == '7' ] && [ "$(systemctl is-active NetworkManager.service)" == 'active' ] && NM_flag=1
+for Service in $(chkconfig --list | grep 3:on | awk '{print $1}' | grep -vE 'nginx|httpd|tomcat|mysqld|php-fpm|pureftpd|redis-server|memcached|supervisord|aegis|NetworkManager');do chkconfig --level 3 ${Service} off;done
+[ "${NM_flag}" == '1' ] && systemctl enable NetworkManager.service
+for Service in sshd network crond iptables messagebus irqbalance syslog rsyslog;do chkconfig --level 3 ${Service} on;done
 
 # Close SELINUX
 setenforce 0
@@ -54,7 +22,7 @@ sed -i 's/^SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config
 cat > /etc/profile.d/oneinstack.sh << EOF
 HISTSIZE=10000
 PS1="\[\e[37;40m\][\[\e[32;40m\]\u\[\e[37;40m\]@\h \[\e[35;40m\]\W\[\e[0m\]]\\\\$ "
-HISTTIMEFORMAT="%F %T \`whoami\` "
+HISTTIMEFORMAT="%F %T \$(whoami) "
 
 alias l='ls -AFhlt'
 alias lh='l | head'
@@ -66,7 +34,7 @@ alias egrep='egrep --color'
 alias fgrep='fgrep --color'
 EOF
 
-[ -z "`grep ^'PROMPT_COMMAND=' /etc/bashrc`" ] && cat >> /etc/bashrc << EOF
+[ -z "$(grep ^'PROMPT_COMMAND=' /etc/bashrc)" ] && cat >> /etc/bashrc << EOF
 PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });logger "[euid=\$(whoami)]":\$(who am i):[\`pwd\`]"\$msg"; }'
 EOF
 
@@ -82,7 +50,7 @@ cat >> /etc/security/limits.conf <<EOF
 EOF
 
 # /etc/hosts
-[ "$(hostname -i | awk '{print $1}')" != "127.0.0.1" ] && sed -i "s@^127.0.0.1\(.*\)@127.0.0.1   `hostname` \1@" /etc/hosts
+[ "$(hostname -i | awk '{print $1}')" != "127.0.0.1" ] && sed -i "s@127.0.0.1.*localhost@&\n127.0.0.1 $(hostname)@g" /etc/hosts
 
 # Set timezone
 rm -rf /etc/localtime
@@ -134,31 +102,31 @@ net.netfilter.nf_conntrack_tcp_timeout_established = 3600
 EOF
 sysctl -p
 
-if [ "$CentOS_RHEL_version" == '5' ]; then
+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
+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
+elif [ "${CentOS_RHEL_version}" == '7' ]; then
   sed -i 's@LANG=.*$@LANG="en_US.UTF-8"@g' /etc/locale.conf
 fi
 
 # Update time
 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
-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
+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
   IPTABLES_STATUS=no
 fi
 
-if [ "$IPTABLES_STATUS" == 'no' ]; then
-  [ -e '/etc/sysconfig/iptables' ] && /bin/mv /etc/sysconfig/iptables{,_bk}
+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
 # Manual customization of this file is not recommended.
@@ -182,41 +150,9 @@ COMMIT
 EOF
 fi
 
-FW_PORT_FLAG=`grep -ow "dport $SSH_PORT" /etc/sysconfig/iptables`
-[ -z "$FW_PORT_FLAG" -a "$SSH_PORT" != '22' ] && sed -i "s@dport 22 -j ACCEPT@&\n-A INPUT -p tcp -m state --state NEW -m tcp --dport $SSH_PORT -j ACCEPT@" /etc/sysconfig/iptables
+FW_PORT_FLAG=$(grep -ow "dport ${SSH_PORT}" /etc/sysconfig/iptables)
+[ -z "${FW_PORT_FLAG}" -a "${SSH_PORT}" != "22" ] && sed -i "s@dport 22 -j ACCEPT@&\n-A INPUT -p tcp -m state --state NEW -m tcp --dport ${SSH_PORT} -j ACCEPT@" /etc/sysconfig/iptables
 service iptables restart
 service sshd restart
 
-# install tmux
-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
-
-# install htop
-if [ ! -e "`which htop`" ]; then
-  tar xzf htop-${htop_version}.tar.gz
-  pushd htop-${htop_version}
-  ./configure
-  make -j ${THREAD} && make install
-  popd
-fi
-
 . /etc/profile
-popd

+ 11 - 29
include/init_Debian.sh

@@ -8,29 +8,11 @@
 #       https://oneinstack.com
 #       https://github.com/lj2007331/oneinstack
 
-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
-  apt-get -y remove --purge $Package
-done
-dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
-
-apt-get -y update
-
-# critical security updates 
-grep security /etc/apt/sources.list > /tmp/security.sources.list
-apt-get -y upgrade -o Dir::Etc::SourceList=/tmp/security.sources.list
-
-# 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 numactl 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
-  apt-get -y install $Package
-done
-
 # Custom profile
 cat > /etc/profile.d/oneinstack.sh << EOF
 HISTSIZE=10000
 PS1='\${debian_chroot:+(\$debian_chroot)}\\[\\e[1;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ '
-HISTTIMEFORMAT="%F %T \`whoami\` "
+HISTTIMEFORMAT="%F %T \$(whoami) "
 
 alias l='ls -AFhlt --color=auto'
 alias lh='l | head'
@@ -47,11 +29,11 @@ EOF
 sed -i 's@^"syntax on@syntax on@' /etc/vim/vimrc
 
 # history
-[ -z "`grep history-timestamp ~/.bashrc`" ] && echo "PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });user=\$(whoami); echo \$(date \"+%Y-%m-%d %H:%M:%S\"):\$user:\`pwd\`/:\$msg ---- \$(who am i); } >> /tmp/\`hostname\`.\`whoami\`.history-timestamp'" >> ~/.bashrc
+[ -z "$(grep history-timestamp ~/.bashrc)" ] && echo "PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });user=\$(whoami); echo \$(date \"+%Y-%m-%d %H:%M:%S\"):\$user:\`pwd\`/:\$msg ---- \$(who am i); } >> /tmp/\`hostname\`.\`whoami\`.history-timestamp'" >> ~/.bashrc
 
 # /etc/security/limits.conf
 [ -e /etc/security/limits.d/*nproc.conf ] && rename nproc.conf nproc.conf_bk /etc/security/limits.d/*nproc.conf
-[ -z "`grep 'session required pam_limits.so' /etc/pam.d/common-session`" ] && echo 'session required pam_limits.so' >> /etc/pam.d/common-session
+[ -z "$(grep 'session required pam_limits.so' /etc/pam.d/common-session)" ] && echo "session required pam_limits.so" >> /etc/pam.d/common-session
 sed -i '/^# End of file/,$d' /etc/security/limits.conf
 cat >> /etc/security/limits.conf <<EOF
 # End of file
@@ -66,7 +48,7 @@ root hard nofile 65535
 EOF
 
 # /etc/hosts
-[ "$(hostname -i | awk '{print $1}')" != "127.0.0.1" ] && sed -i "s@^127.0.0.1\(.*\)@127.0.0.1   `hostname` \1@" /etc/hosts
+[ "$(hostname -i | awk '{print $1}')" != "127.0.0.1" ] && sed -i "s@127.0.0.1.*localhost@&\n127.0.0.1 $(hostname)@g" /etc/hosts
 
 # Set timezone
 rm -rf /etc/localtime
@@ -79,7 +61,7 @@ ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
 #EOF
 
 # /etc/sysctl.conf
-[ -z "`grep 'fs.file-max' /etc/sysctl.conf`" ] && cat >> /etc/sysctl.conf << EOF
+[ -z "$(grep 'fs.file-max' /etc/sysctl.conf)" ] && cat >> /etc/sysctl.conf << EOF
 fs.file-max=65535
 fs.inotify.max_user_instances = 8192
 net.ipv4.tcp_syncookies = 1
@@ -105,17 +87,17 @@ init q
 
 # Update time
 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
-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
+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
   IPTABLES_STATUS=no
 fi
 
-if [ "$IPTABLES_STATUS" == 'no' ]; then
-  [ -e '/etc/iptables.up.rules' ] && /bin/mv /etc/iptables.up.rules{,_bk}
+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
 # Manual customization of this file is not recommended.
@@ -139,8 +121,8 @@ COMMIT
 EOF
 fi
 
-FW_PORT_FLAG=`grep -ow "dport $SSH_PORT" /etc/iptables.up.rules`
-[ -z "$FW_PORT_FLAG" -a "$SSH_PORT" != '22' ] && sed -i "s@dport 22 -j ACCEPT@&\n-A INPUT -p tcp -m state --state NEW -m tcp --dport $SSH_PORT -j ACCEPT@" /etc/iptables.up.rules
+FW_PORT_FLAG=$(grep -ow "dport ${SSH_PORT}" /etc/iptables.up.rules)
+[ -z "${FW_PORT_FLAG}" -a "${SSH_PORT}" != "22" ] && sed -i "s@dport 22 -j ACCEPT@&\n-A INPUT -p tcp -m state --state NEW -m tcp --dport ${SSH_PORT} -j ACCEPT@" /etc/iptables.up.rules
 iptables-restore < /etc/iptables.up.rules
 cat > /etc/network/if-pre-up.d/iptables << EOF
 #!/bin/bash

+ 13 - 49
include/init_Ubuntu.sh

@@ -8,45 +8,10 @@
 #       https://oneinstack.com
 #       https://github.com/lj2007331/oneinstack
 
-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
-  apt-get -y remove --purge $Package
-done
-dpkg -l | grep ^rc | awk '{print $2}' | xargs dpkg -P
-
-apt-get -y update
-
-# critical security updates 
-grep security /etc/apt/sources.list > /tmp/security.sources.list
-apt-get -y upgrade -o Dir::Etc::SourceList=/tmp/security.sources.list
-
-# 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 numactl 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
-  apt-get -y install $Package
-done
-
-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
-
 # Custom profile
 cat > /etc/profile.d/oneinstack.sh << EOF
 HISTSIZE=10000
-HISTTIMEFORMAT="%F %T \`whoami\` "
+HISTTIMEFORMAT="%F %T \$(whoami) "
 
 alias l='ls -AFhlt --color=auto'
 alias lh='l | head'
@@ -63,14 +28,14 @@ EOF
 sed -i 's@^"syntax on@syntax on@' /etc/vim/vimrc
 
 # PS1
-[ -z "`grep ^PS1 ~/.bashrc`" ] && echo "PS1='\${debian_chroot:+(\$debian_chroot)}\\[\\e[1;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ '" >> ~/.bashrc
+[ -z "$(grep ^PS1 ~/.bashrc)" ] && echo "PS1='\${debian_chroot:+(\$debian_chroot)}\\[\\e[1;32m\\]\\u@\\h\\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ '" >> ~/.bashrc
 
 # history
-[ -z "`grep history-timestamp ~/.bashrc`" ] && echo "PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });user=\$(whoami); echo \$(date \"+%Y-%m-%d %H:%M:%S\"):\$user:\`pwd\`/:\$msg ---- \$(who am i); } >> /tmp/\`hostname\`.\`whoami\`.history-timestamp'" >> ~/.bashrc
+[ -z "$(grep history-timestamp ~/.bashrc)" ] && echo "PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; });user=\$(whoami); echo \$(date \"+%Y-%m-%d %H:%M:%S\"):\$user:\`pwd\`/:\$msg ---- \$(who am i); } >> /tmp/\`hostname\`.\`whoami\`.history-timestamp'" >> ~/.bashrc
 
 # /etc/security/limits.conf
 [ -e /etc/security/limits.d/*nproc.conf ] && rename nproc.conf nproc.conf_bk /etc/security/limits.d/*nproc.conf
-[ -z "`grep 'session required pam_limits.so' /etc/pam.d/common-session`" ] && echo 'session required pam_limits.so' >> /etc/pam.d/common-session
+[ -z "$(grep 'session required pam_limits.so' /etc/pam.d/common-session)" ] && echo "session required pam_limits.so" >> /etc/pam.d/common-session
 sed -i '/^# End of file/,$d' /etc/security/limits.conf
 cat >> /etc/security/limits.conf <<EOF
 # End of file
@@ -85,7 +50,7 @@ root hard nofile 65535
 EOF
 
 # /etc/hosts
-[ "$(hostname -i | awk '{print $1}')" != "127.0.0.1" ] && sed -i "s@^127.0.0.1\(.*\)@127.0.0.1   `hostname` \1@" /etc/hosts
+[ "$(hostname -i | awk '{print $1}')" != "127.0.0.1" ] && sed -i "s@127.0.0.1.*localhost@&\n127.0.0.1 $(hostname)@g" /etc/hosts
 
 # Set timezone
 rm -rf /etc/localtime
@@ -98,7 +63,7 @@ ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
 #EOF
 
 # /etc/sysctl.conf
-[ -z "`grep 'fs.file-max' /etc/sysctl.conf`" ] && cat >> /etc/sysctl.conf << EOF
+[ -z "$(grep 'fs.file-max' /etc/sysctl.conf)" ] && cat >> /etc/sysctl.conf << EOF
 fs.file-max=65535
 fs.inotify.max_user_instances = 8192
 net.ipv4.tcp_syncookies = 1
@@ -120,22 +85,22 @@ sysctl -p
 
 sed -i 's@^ACTIVE_CONSOLES.*@ACTIVE_CONSOLES="/dev/tty[1-2]"@' /etc/default/console-setup
 sed -i 's@^@#@g' /etc/init/tty[3-6].conf
-echo 'en_US.UTF-8 UTF-8' > /var/lib/locales/supported.d/local
+echo "en_US.UTF-8 UTF-8" > /var/lib/locales/supported.d/local
 sed -i 's@^@#@g' /etc/init/control-alt-delete.conf
 
 # Update time
 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
-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
+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
   IPTABLES_STATUS=no
 fi
 
-if [ "$IPTABLES_STATUS" == 'no' ]; then
-  [ -e '/etc/iptables.up.rules' ] && /bin/mv /etc/iptables.up.rules{,_bk}
+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
 # Manual customization of this file is not recommended.
@@ -159,8 +124,8 @@ COMMIT
 EOF
 fi
 
-FW_PORT_FLAG=`grep -ow "dport $SSH_PORT" /etc/iptables.up.rules`
-[ -z "$FW_PORT_FLAG" -a "$SSH_PORT" != '22' ] && sed -i "s@dport 22 -j ACCEPT@&\n-A INPUT -p tcp -m state --state NEW -m tcp --dport $SSH_PORT -j ACCEPT@" /etc/iptables.up.rules
+FW_PORT_FLAG=$(grep -ow "dport ${SSH_PORT}" /etc/iptables.up.rules)
+[ -z "${FW_PORT_FLAG}" -a "${SSH_PORT}" != "22" ] && sed -i "s@dport 22 -j ACCEPT@&\n-A INPUT -p tcp -m state --state NEW -m tcp --dport ${SSH_PORT} -j ACCEPT@" /etc/iptables.up.rules
 iptables-restore < /etc/iptables.up.rules
 cat > /etc/network/if-pre-up.d/iptables << EOF
 #!/bin/bash
@@ -171,4 +136,3 @@ service ssh restart
 
 . /etc/profile
 . ~/.bashrc
-popd

+ 20 - 15
include/memcached.sh

@@ -10,9 +10,11 @@
 
 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}
@@ -23,11 +25,12 @@ Install_memcached() {
     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; }
+    [ "${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
+    let memcachedCache="${Mem}/8"
+    [ -n "$(grep 'CACHESIZE=' /etc/init.d/memcached)" ] && sed -i "s@^CACHESIZE=.*@CACHESIZE=${memcachedCache}@" /etc/init.d/memcached
+    [ -n "$(grep 'start_instance default 256;' /etc/init.d/memcached)" ] && sed -i "s@start_instance default 256;@start_instance default ${memcachedCache};@" /etc/init.d/memcached
     service memcached start
     rm -rf memcached-${memcached_version}
   else
@@ -40,11 +43,12 @@ Install_memcached() {
 
 Install_php-memcache() {
   pushd ${oneinstack_dir}/src
-  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
+  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
+    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
@@ -56,7 +60,7 @@ Install_php-memcache() {
     make -j ${THREAD} && make install
     popd
     if [ -f "${phpExtensionDir}/memcache.so" ]; then
-      echo 'extension=memcache.so' > ${php_install_dir}/etc/php.d/ext-memcache.ini
+      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
@@ -68,20 +72,21 @@ Install_php-memcache() {
 
 Install_php-memcached() {
   pushd ${oneinstack_dir}/src
-  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
+  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
+    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
+    rm -rf libmemcached-${libmemcached_version}
 
-    if [ "`${php_install_dir}/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}'`" == '7' ]; then
+    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
@@ -93,7 +98,7 @@ Install_php-memcached() {
     make -j ${THREAD} && make install
     popd
     if [ -f "${phpExtensionDir}/memcached.so" ]; then
-      cat > ${php_install_dir}/etc/php.d/ext-memcached.ini << EOF
+        cat > ${php_install_dir}/etc/php.d/ext-memcached.ini << EOF
 extension=memcached.so
 memcached.use_sasl=1
 EOF

+ 1 - 1
include/nginx.sh

@@ -35,7 +35,7 @@ Install_Nginx() {
   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
+  ./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-http_mp4_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 

+ 1 - 1
include/openresty.sh

@@ -32,7 +32,7 @@ Install_OpenResty() {
   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
+  ./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-http_mp4_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

+ 29 - 29
include/pureftpd.sh

@@ -10,53 +10,53 @@
 
 Install_PureFTPd() {
   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
+
+  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}"
-    [ ! -e "$pureftpd_install_dir/etc" ] && mkdir $pureftpd_install_dir/etc
-    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
-    chmod +x $pureftpd_install_dir/sbin/pure-config.pl
+  if [ -e "${pureftpd_install_dir}/sbin/pure-ftpwho" ]; then
+    [ ! -e "${pureftpd_install_dir}/etc" ] && mkdir ${pureftpd_install_dir}/etc
+    /bin/cp configuration-file/pure-config.pl ${pureftpd_install_dir}/sbin
     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}@" ${pureftpd_install_dir}/sbin/pure-config.pl
+    chmod +x ${pureftpd_install_dir}/sbin/pure-config.pl
+    /bin/cp ../init.d/Pureftpd-init /etc/init.d/pureftpd
+    /bin/cp ../config/pure-ftpd.conf ${pureftpd_install_dir}/etc
+    sed -i "s@/usr/local/pureftpd@${pureftpd_install_dir}@g" /etc/init.d/pureftpd
     chmod +x /etc/init.d/pureftpd
-    [ "$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; }
-    [ "$Debian_version" == '7' ] && sed -i 's@/var/lock/subsys/@/var/lock/@g' /etc/init.d/pureftpd
+    [ "${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; }
+    [ "${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
-    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@^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
     ulimit -s unlimited
     service pureftpd start
-    echo "${CSUCCESS}Pureftpd installed successfully! ${CEND}"
-    rm -rf pure-ftpd-$pureftpd_version
 
     # iptables Ftp
-    if [ "$OS" == 'CentOS' ]; then
-      if [ -z "`grep '20000:30000' /etc/sysconfig/iptables`" ]; then
+    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
+    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
+
+    echo "${CSUCCESS}Pure-Ftp installed successfully! ${CEND}"
+    rm -rf pure-ftpd-${pureftpd_version}
   else
-    rm -rf $pureftpd_install_dir
+    rm -rf ${pureftpd_install_dir}
     echo "${CFAILURE}Pure-Ftpd install failed, Please contact the author! ${CEND}"
     kill -9 $$
   fi

+ 1 - 1
include/tengine.sh

@@ -33,7 +33,7 @@ Install_Tengine() {
   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
+  ./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_mp4_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

+ 86 - 78
include/tomcat-6.sh

@@ -9,112 +9,120 @@
 #       https://github.com/lj2007331/oneinstack
 
 Install_tomcat-6() {
-  cd ${oneinstack_dir}/src
+  pushd ${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
-    cd $tomcat_install_dir/lib
-    [ ! -d "$tomcat_install_dir/lib/catalina" ] &&  mkdir $tomcat_install_dir/lib/catalina
-    cd $tomcat_install_dir/lib/catalina
-    jar xf ../catalina.jar
-    sed -i 's@^server.info=.*@server.info=Tomcat@' org/apache/catalina/util/ServerInfo.properties
-    sed -i 's@^server.number=.*@server.number=6@' org/apache/catalina/util/ServerInfo.properties
-    sed -i "s@^server.built=.*@server.built=`date`@" org/apache/catalina/util/ServerInfo.properties
-    jar cf ../catalina.jar ./*
-    cd ../../bin
-    rm -rf $tomcat_install_dir/lib/catalina
-    [ "$OS" == 'CentOS' ] && yum -y install apr apr-devel
-    [[ $OS =~ ^Ubuntu$|^Debian$ ]] && apt-get -y install libapr1-dev libaprutil1-dev
-    tar xzf tomcat-native.tar.gz
-    cd tomcat-native-*-src/jni/native/
+
+  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
+    rm -rf ${tomcat_install_dir}
+    echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}"
+    kill -9 $$
+  fi
+
+  /bin/cp catalina-jmx-remote.jar ${tomcat_install_dir}/lib
+  [ ! -d "${tomcat_install_dir}/lib/catalina" ] &&  mkdir ${tomcat_install_dir}/lib/catalina
+  pushd ${tomcat_install_dir}/lib/catalina
+  jar xf ../catalina.jar
+  sed -i 's@^server.info=.*@server.info=Tomcat@' org/apache/catalina/util/ServerInfo.properties
+  sed -i 's@^server.number=.*@server.number=6@' org/apache/catalina/util/ServerInfo.properties
+  sed -i "s@^server.built=.*@server.built=$(date)@" org/apache/catalina/util/ServerInfo.properties
+  jar cf ../catalina.jar ./*
+  popd
+  rm -rf ${tomcat_install_dir}/lib/catalina
+
+  [ "${OS}" == "CentOS" ] && yum -y install apr apr-devel
+  [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && apt-get -y install libapr1-dev libaprutil1-dev
+  pushd ${tomcat_install_dir}/bin
+  tar xzf tomcat-native.tar.gz
+  pushd tomcat-native-*-src/jni/native/
     rm -rf /usr/local/apr
     ./configure --with-apr=/usr/bin/apr-1-config
     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
-JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms${Xms_Mem}m -Xmx`expr $Mem / 2`m -Dfile.encoding=UTF-8'
+  popd
+  rm -rf tomcat-native-*
+  if [ -d "/usr/local/apr/lib" ]; then
+    [ ${Mem} -le 768 ] && let Xms_Mem="${Mem}/3" || Xms_Mem=256
+    let XmxMem="${Mem}/2"
+    cat > ${tomcat_install_dir}/bin/setenv.sh << EOF
+JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms${Xms_Mem}m -Xmx${XmxMem}m -Dfile.encoding=UTF-8'
 CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"
 # -Djava.rmi.server.hostname=$IPADDR
 # -Dcom.sun.management.jmxremote.password.file=\$CATALINA_BASE/conf/jmxremote.password
 # -Dcom.sun.management.jmxremote.access.file=\$CATALINA_BASE/conf/jmxremote.access
 # -Dcom.sun.management.jmxremote.ssl=false"
 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
+    chmod +x ./*.sh
+    /bin/mv ${tomcat_install_dir}/conf/server.xml{,_bk}
+    popd # goto ${oneinstack_dir}/src
+
+    /bin/cp ${oneinstack_dir}/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
 
-      [ ! -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">
-  <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"
-         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>
 EOF
-      # logrotate tomcat catalina.out
-      cat > /etc/logrotate.d/tomcat << EOF
-$tomcat_install_dir/logs/catalina.out {
-daily
-rotate 5
-missingok
-dateext
-compress
-notifempty
-copytruncate
+    # logrotate tomcat catalina.out
+    cat > /etc/logrotate.d/tomcat << EOF
+${tomcat_install_dir}/logs/catalina.out {
+  daily
+  rotate 5
+  missingok
+  dateext
+  compress
+  notifempty
+  copytruncate
 }
 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
 controlRole   readwrite \
               create javax.management.monitor.*,javax.management.timer.* \
               unregister
 EOF
-      cat > $tomcat_install_dir/conf/jmxremote.password << EOF
-monitorRole  `cat /dev/urandom | head -1 | md5sum | head -c 8`
+    cat > ${tomcat_install_dir}/conf/jmxremote.password << EOF
+monitorRole  $(cat /dev/urandom | head -1 | md5sum | head -c 8)
 # controlRole   R&D
 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}"
-    fi
+    chown -R ${run_user}.${run_user} ${tomcat_install_dir}
+    /bin/cp ${oneinstack_dir}/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}"
+    rm -rf apache-tomcat-${tomcat_6_version}
   else
-    rm -rf $tomcat_install_dir
+    popd
     echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}"
-    kill -9 $$
   fi
   service tomcat start
-  cd ..
+  popd
 }

+ 85 - 77
include/tomcat-7.sh

@@ -9,112 +9,120 @@
 #       https://github.com/lj2007331/oneinstack
 
 Install_tomcat-7() {
-  cd ${oneinstack_dir}/src
+  pushd ${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
-    cd $tomcat_install_dir/lib
-    [ ! -d "$tomcat_install_dir/lib/catalina" ] &&  mkdir $tomcat_install_dir/lib/catalina
-    cd $tomcat_install_dir/lib/catalina
-    jar xf ../catalina.jar
-    sed -i 's@^server.info=.*@server.info=Tomcat@' org/apache/catalina/util/ServerInfo.properties
-    sed -i 's@^server.number=.*@server.number=7@' org/apache/catalina/util/ServerInfo.properties
-    sed -i "s@^server.built=.*@server.built=`date`@" org/apache/catalina/util/ServerInfo.properties
-    jar cf ../catalina.jar ./*
-    cd ../../bin
-    rm -rf $tomcat_install_dir/lib/catalina
-    [ "$OS" == 'CentOS' ] && yum -y install apr apr-devel
-    [[ $OS =~ ^Ubuntu$|^Debian$ ]] && apt-get -y install libapr1-dev libaprutil1-dev
-    tar xzf tomcat-native.tar.gz
-    cd tomcat-native-*-src/jni/native/
+
+  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
+    rm -rf ${tomcat_install_dir}
+    echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}"
+    kill -9 $$
+  fi
+
+  /bin/cp catalina-jmx-remote.jar ${tomcat_install_dir}/lib
+  [ ! -d "${tomcat_install_dir}/lib/catalina" ] &&  mkdir ${tomcat_install_dir}/lib/catalina
+  pushd ${tomcat_install_dir}/lib/catalina
+  jar xf ../catalina.jar
+  sed -i 's@^server.info=.*@server.info=Tomcat@' org/apache/catalina/util/ServerInfo.properties
+  sed -i 's@^server.number=.*@server.number=7@' org/apache/catalina/util/ServerInfo.properties
+  sed -i "s@^server.built=.*@server.built=$(date)@" org/apache/catalina/util/ServerInfo.properties
+  jar cf ../catalina.jar ./*
+  popd
+  rm -rf ${tomcat_install_dir}/lib/catalina
+
+  [ "${OS}" == "CentOS" ] && yum -y install apr apr-devel
+  [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && apt-get -y install libapr1-dev libaprutil1-dev
+  pushd ${tomcat_install_dir}/bin
+  tar xzf tomcat-native.tar.gz
+  pushd tomcat-native-*-src/jni/native/
     rm -rf /usr/local/apr
     ./configure --with-apr=/usr/bin/apr-1-config
     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
-JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms${Xms_Mem}m -Xmx`expr $Mem / 2`m -Dfile.encoding=UTF-8'
+  popd
+  rm -rf tomcat-native-*
+  if [ -d "/usr/local/apr/lib" ]; then
+    [ ${Mem} -le 768 ] && let Xms_Mem="${Mem}/3" || Xms_Mem=256
+    let XmxMem="${Mem}/2"
+    cat > ${tomcat_install_dir}/bin/setenv.sh << EOF
+JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms${Xms_Mem}m -Xmx${XmxMem}m -Dfile.encoding=UTF-8'
 CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"
 # -Djava.rmi.server.hostname=$IPADDR
 # -Dcom.sun.management.jmxremote.password.file=\$CATALINA_BASE/conf/jmxremote.password
 # -Dcom.sun.management.jmxremote.access.file=\$CATALINA_BASE/conf/jmxremote.access
 # -Dcom.sun.management.jmxremote.ssl=false"
 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
+    chmod +x ./*.sh
+    /bin/mv ${tomcat_install_dir}/conf/server.xml{,_bk}
+    popd # goto ${oneinstack_dir}/src
+
+    /bin/cp ${oneinstack_dir}/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
+    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
 
-      [ ! -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">
-  <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"
-         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>
 EOF
-      # logrotate tomcat catalina.out
-      cat > /etc/logrotate.d/tomcat << EOF
-$tomcat_install_dir/logs/catalina.out {
-daily
-rotate 5
-missingok
-dateext
-compress
-notifempty
-copytruncate
+    # logrotate tomcat catalina.out
+    cat > /etc/logrotate.d/tomcat << EOF
+${tomcat_install_dir}/logs/catalina.out {
+  daily
+  rotate 5
+  missingok
+  dateext
+  compress
+  notifempty
+  copytruncate
 }
 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
 controlRole   readwrite \
               create javax.management.monitor.*,javax.management.timer.* \
               unregister
 EOF
-      cat > $tomcat_install_dir/conf/jmxremote.password << EOF
-monitorRole  `cat /dev/urandom | head -1 | md5sum | head -c 8`
+    cat > ${tomcat_install_dir}/conf/jmxremote.password << EOF
+monitorRole  $(cat /dev/urandom | head -1 | md5sum | head -c 8)
 # controlRole   R&D
 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}"
-    fi
+    chown -R ${run_user}.${run_user} ${tomcat_install_dir}
+    /bin/cp ${oneinstack_dir}/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}"
+    rm -rf apache-tomcat-${tomcat_7_version}
   else
-    rm -rf $tomcat_install_dir
+    popd
     echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}"
-    kill -9 $$
   fi
   service tomcat start
-  cd ..
+  popd
 }

+ 85 - 77
include/tomcat-8.sh

@@ -9,112 +9,120 @@
 #       https://github.com/lj2007331/oneinstack
 
 Install_tomcat-8() {
-  cd ${oneinstack_dir}/src
+  pushd ${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
-    cd $tomcat_install_dir/lib
-    [ ! -d "$tomcat_install_dir/lib/catalina" ] &&  mkdir $tomcat_install_dir/lib/catalina
-    cd $tomcat_install_dir/lib/catalina
-    jar xf ../catalina.jar
-    sed -i 's@^server.info=.*@server.info=Tomcat@' org/apache/catalina/util/ServerInfo.properties
-    sed -i 's@^server.number=.*@server.number=8@' org/apache/catalina/util/ServerInfo.properties
-    sed -i "s@^server.built=.*@server.built=`date`@" org/apache/catalina/util/ServerInfo.properties
-    jar cf ../catalina.jar ./*
-    cd ../../bin
-    rm -rf $tomcat_install_dir/lib/catalina
-    [ "$OS" == 'CentOS' ] && yum -y install apr apr-devel
-    [[ $OS =~ ^Ubuntu$|^Debian$ ]] && apt-get -y install libapr1-dev libaprutil1-dev
-    tar xzf tomcat-native.tar.gz
-    cd tomcat-native-*-src/jni/native/
+
+  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
+    rm -rf ${tomcat_install_dir}
+    echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}"
+    kill -9 $$
+  fi
+
+  /bin/cp catalina-jmx-remote.jar ${tomcat_install_dir}/lib
+  [ ! -d "${tomcat_install_dir}/lib/catalina" ] &&  mkdir ${tomcat_install_dir}/lib/catalina
+  pushd ${tomcat_install_dir}/lib/catalina
+  jar xf ../catalina.jar
+  sed -i 's@^server.info=.*@server.info=Tomcat@' org/apache/catalina/util/ServerInfo.properties
+  sed -i 's@^server.number=.*@server.number=8@' org/apache/catalina/util/ServerInfo.properties
+  sed -i "s@^server.built=.*@server.built=$(date)@" org/apache/catalina/util/ServerInfo.properties
+  jar cf ../catalina.jar ./*
+  popd
+  rm -rf ${tomcat_install_dir}/lib/catalina
+
+  [ "${OS}" == "CentOS" ] && yum -y install apr apr-devel
+  [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && apt-get -y install libapr1-dev libaprutil1-dev
+  pushd ${tomcat_install_dir}/bin
+  tar xzf tomcat-native.tar.gz
+  pushd tomcat-native-*-src/jni/native/
     rm -rf /usr/local/apr
     ./configure --with-apr=/usr/bin/apr-1-config
     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
-JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms${Xms_Mem}m -Xmx`expr $Mem / 2`m -Dfile.encoding=UTF-8'
+  popd
+  rm -rf tomcat-native-*
+  if [ -d "/usr/local/apr/lib" ]; then
+    [ ${Mem} -le 768 ] && let Xms_Mem="${Mem}/3" || Xms_Mem=256
+    let XmxMem="${Mem}/2"
+    cat > ${tomcat_install_dir}/bin/setenv.sh << EOF
+JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom -server -Xms${Xms_Mem}m -Xmx${XmxMem}m -Dfile.encoding=UTF-8'
 CATALINA_OPTS="-Djava.library.path=/usr/local/apr/lib"
 # -Djava.rmi.server.hostname=$IPADDR
 # -Dcom.sun.management.jmxremote.password.file=\$CATALINA_BASE/conf/jmxremote.password
 # -Dcom.sun.management.jmxremote.access.file=\$CATALINA_BASE/conf/jmxremote.access
 # -Dcom.sun.management.jmxremote.ssl=false"
 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
+    chmod +x ./*.sh
+    /bin/mv ${tomcat_install_dir}/conf/server.xml{,_bk}
+    popd # goto ${oneinstack_dir}/src
+
+    /bin/cp ${oneinstack_dir}/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
+    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
 
-      [ ! -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">
-  <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"
-         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>
 EOF
-      # logrotate tomcat catalina.out
-      cat > /etc/logrotate.d/tomcat << EOF
-$tomcat_install_dir/logs/catalina.out {
-daily
-rotate 5
-missingok
-dateext
-compress
-notifempty
-copytruncate
+    # logrotate tomcat catalina.out
+    cat > /etc/logrotate.d/tomcat << EOF
+${tomcat_install_dir}/logs/catalina.out {
+  daily
+  rotate 5
+  missingok
+  dateext
+  compress
+  notifempty
+  copytruncate
 }
 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
 controlRole   readwrite \
               create javax.management.monitor.*,javax.management.timer.* \
               unregister
 EOF
-      cat > $tomcat_install_dir/conf/jmxremote.password << EOF
-monitorRole  `cat /dev/urandom | head -1 | md5sum | head -c 8`
+    cat > ${tomcat_install_dir}/conf/jmxremote.password << EOF
+monitorRole  $(cat /dev/urandom | head -1 | md5sum | head -c 8)
 # controlRole   R&D
 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}"
-    fi
+    chown -R ${run_user}.${run_user} ${tomcat_install_dir}
+    /bin/cp ${oneinstack_dir}/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}"
+    rm -rf apache-tomcat-${tomcat_8_version}
   else
-    rm -rf $tomcat_install_dir
+    popd
     echo "${CFAILURE}Tomcat install failed, Please contact the author! ${CEND}"
-    kill -9 $$
   fi
   service tomcat start
-  cd ..
+  popd
 }

+ 1 - 1
include/upgrade_web.sh

@@ -163,7 +163,7 @@ Upgrade_OpenResty() {
     rm -rf $$
     [ -n "`echo $openresty_configure_arguments | grep jemalloc`"] && malloc_module="--with-ld-opt='-ljemalloc'"
     [ -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-http_mp4_module --with-openssl=../openssl-$openssl_version --with-pcre=../pcre-$pcre_version --with-pcre-jit $malloc_module
     make -j ${THREAD}
     if [ -f "build/nginx-$openresty_version_tmp/objs/nginx" ]; then
       /bin/mv $openresty_install_dir/nginx/sbin/nginx{,`date +%m%d`}

+ 8 - 6
include/xcache.sh

@@ -10,7 +10,7 @@
 
 Install_XCache() {
   pushd ${oneinstack_dir}/src
-  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
+  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
@@ -19,8 +19,10 @@ Install_XCache() {
   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
+    chown -R ${run_user}.${run_user} ${wwwroot_dir}/default/xcache
     touch /tmp/xcache;chown ${run_user}.${run_user} /tmp/xcache
+    let xcacheCount="${CPU}+1"
+    let xcacheSize="${Memory_limit}/2"
 
     cat > ${php_install_dir}/etc/php.d/ext-xcache.ini << EOF
 [xcache-common]
@@ -28,16 +30,16 @@ extension=xcache.so
 [xcache.admin]
 xcache.admin.enable_auth=On
 xcache.admin.user=admin
-xcache.admin.pass="$xcache_admin_md5_pass"
+xcache.admin.pass="${xcache_admin_md5_pass}"
 
 [xcache]
-xcache.size=$(expr $Memory_limit / 2)M
-xcache.count=$(expr `cat /proc/cpuinfo | grep -c processor` + 1)
+xcache.size=${xcacheSize}M
+xcache.count=${xcacheCount}
 xcache.slots=8K
 xcache.ttl=3600
 xcache.gc_interval=300
 xcache.var_size=4M
-xcache.var_count=$(expr `cat /proc/cpuinfo | grep -c processor` + 1)
+xcache.var_count=${xcacheCount}
 xcache.var_slots=8K
 xcache.var_ttl=0
 xcache.var_maxttl=0

+ 38 - 6
include/zendopcache.sh

@@ -10,19 +10,30 @@
 
 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
+  phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
+  PHP_detail_version=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
+  PHP_main_version=${PHP_detail_version%.*}
+  if [[ "${PHP_main_version}" =~ ^5.[3-4]$ ]]; then
+    tar xvf zendopcache-${zendopcache_version}.tgz
+    pushd zendopcache-${zendopcache_version}
+  else
+    tar xvf php-${PHP_detail_version}.tar.gz
+    pushd php-${PHP_detail_version}/ext/opcache
+  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}/opcache.so" ]; then
-    cat > ${php_install_dir}/etc/php.d/ext-opcache.ini << EOF
+    # write opcache configs
+    if [[ "${PHP_main_version}" =~ ^5.[3-4]$ ]]; then
+      # For php 5.3 5.4
+      cat > ${php_install_dir}/etc/php.d/ext-opcache.ini << EOF
 [opcache]
 zend_extension=${phpExtensionDir}/opcache.so
 opcache.enable=1
-opcache.memory_consumption=$Memory_limit
+opcache.memory_consumption=${Memory_limit}
 opcache.interned_strings_buffer=8
 opcache.max_accelerated_files=4000
 opcache.revalidate_freq=60
@@ -31,8 +42,29 @@ opcache.fast_shutdown=1
 opcache.enable_cli=1
 ;opcache.optimization_level=0
 EOF
+    else
+      # For php 5.5+
+      cat > ${php_install_dir}/etc/php.d/ext-opcache.ini << EOF
+[opcache]
+zend_extension=opcache.so
+opcache.enable=1
+opcache.enable_cli=1
+opcache.memory_consumption=${Memory_limit}
+opcache.interned_strings_buffer=8
+opcache.max_accelerated_files=100000
+opcache.max_wasted_percentage=5
+opcache.use_cwd=1
+opcache.validate_timestamps=1
+opcache.revalidate_freq=60
+opcache.save_comments=0
+opcache.fast_shutdown=1
+opcache.consistency_checks=0
+;opcache.optimization_level=0
+EOF
+    fi
+
     echo "${CSUCCESS}PHP OPcache module installed successfully! ${CEND}"
-    rm -rf zendopcache-${zendopcache_version}
+    rm -rf zendopcache-${zendopcache_version} php-${PHP_detail_version}
   else
     echo "${CFAILURE}PHP OPcache module install failed, Please contact the author! ${CEND}"
   fi

+ 1 - 1
init.d/Memcached-init-CentOS

@@ -27,7 +27,7 @@ start () {
   echo -n $"Starting $prog: "
   # insure that /var/run/memcached has proper permissions
   mkdir -p /var/run/memcached
-  if [ "`stat -c %U /var/run/memcached`" != "$USER" ]; then
+  if [ "$(stat -c %U /var/run/memcached)" != "$USER" ]; then
     chown $USER /var/run/memcached
   fi
   $DAEMON -d -p $PORT -u $USER  -m $CACHESIZE -c $MAXCONN -P /var/run/memcached/memcached.pid $OPTIONS

+ 19 - 3
init.d/Memcached-init-Ubuntu

@@ -1,4 +1,20 @@
-#! /bin/sh
+#! /bin/bash
+### BEGIN INIT INFO
+# Provides:          memcached
+# Required-Start:    $syslog
+# Required-Stop:     $syslog
+# Should-Start:      $local_fs
+# Should-Stop:       $local_fs
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description:    memcached - Memory caching daemon
+# Description:        memcached - Memory caching daemon
+### END INIT INFO
+#
+# memcached:    MemCached Daemon
+#
+# chkconfig:    - 90 25
+# description:  MemCached Daemon
 #
 
 PORT=11211
@@ -16,7 +32,7 @@ start_instance() {
   RETVAL=$?
   echo
   [ $RETVAL -eq 0 ] && touch /var/lock/memcached.$1
-  PORT=`expr $PORT + 1`
+  let PORT="$PORT+1"
 }
 
 stop_instance() {
@@ -32,7 +48,7 @@ stop_instance() {
 start () {
   # insure that /var/run/memcached has proper permissions
   mkdir -p /var/run/memcached
-  if [ "`stat -c %U /var/run/memcached`" != "$USER" ]; then
+  if [ "$(stat -c %U /var/run/memcached)" != "$USER" ]; then
     chown $USER /var/run/memcached
   fi
 

+ 9 - 1
init.d/Pureftpd-init

@@ -1,5 +1,13 @@
 #!/bin/bash
-#
+### BEGIN INIT INFO
+# Provides:          pureftpd
+# Required-Start:    $local_fs $remote_fs $network $syslog
+# Required-Stop:     $local_fs $remote_fs $network $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Startup script for the pure-ftpd FTP Server
+# Description:       pureftpd daemon
+### END INIT INFO
 # Startup script for the pure-ftpd FTP Server  $Revision: 1.3 $
 #
 # chkconfig: 2345 85 15

+ 0 - 1
init.d/Redis-server-init

@@ -11,7 +11,6 @@
 # Description:      redis-server - Persistent key-value db
 ### END INIT INFO
 
-
 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 DAEMON=/usr/local/redis/bin/redis-server
 DAEMON_ARGS=/usr/local/redis/etc/redis.conf

+ 9 - 0
init.d/Shadowsocks-python-init

@@ -1,6 +1,15 @@
 #!/bin/bash
 # Author:  yeho <lj2007331 AT gmail.com>
 # BLOG:  https://blog.linuxeye.com
+### BEGIN INIT INFO
+# Provides:          shadowsocks
+# Required-Start:    $local_fs $remote_fs $network $syslog
+# Required-Start:    $local_fs $remote_fs $network $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: shadowsocks - Shadowsocks-python starts daemon
+# Description:       shadowsocks - lightweight secured scoks5 proxy
+### END INIT INFO
 #
 # chkconfig: - 90 10
 # description: Shadowsocks start/stop/status/restart script

+ 9 - 0
init.d/Tomcat-init

@@ -1,4 +1,13 @@
 #!/bin/bash
+### BEGIN INIT INFO
+# Provides:          tomcat
+# Required-Start:    $remote_fs $syslog
+# Required-Stop:     $remote_fs $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: tomcat-server daemon
+# Description:       tomcat-server daemon
+### END INIT INFO
 #
 # chkconfig: - 95 15
 # description: Tomcat start/stop/status script

+ 229 - 172
install.sh

@@ -166,21 +166,19 @@ while :; do echo
       [ -d "$db_install_dir/support-files" ] && { echo "${CWARNING}Database already installed! ${CEND}"; DB_yn=Other; break; }
       while :; do echo
         echo 'Please select a version of the Database:'
-        echo -e "\t${CMSG}1${CEND}. Install MySQL-5.7"
-        echo -e "\t${CMSG}2${CEND}. Install MySQL-5.6"
-        echo -e "\t${CMSG}3${CEND}. Install MySQL-5.5"
-        echo -e "\t${CMSG}4${CEND}. Install MariaDB-10.1"
-        echo -e "\t${CMSG}5${CEND}. Install MariaDB-10.0"
-        echo -e "\t${CMSG}6${CEND}. Install MariaDB-5.5"
-        echo -e "\t${CMSG}7${CEND}. Install Percona-5.7"
-        echo -e "\t${CMSG}8${CEND}. Install Percona-5.6"
-        echo -e "\t${CMSG}9${CEND}. Install Percona-5.5"
-        echo -e "\t${CMSG}0${CEND}. Install AliSQL-5.6"
+        echo -e "\t${CMSG} 1${CEND}. Install MySQL-5.7"
+        echo -e "\t${CMSG} 2${CEND}. Install MySQL-5.6"
+        echo -e "\t${CMSG} 3${CEND}. Install MySQL-5.5"
+        echo -e "\t${CMSG} 4${CEND}. Install MariaDB-10.1"
+        echo -e "\t${CMSG} 5${CEND}. Install MariaDB-10.0"
+        echo -e "\t${CMSG} 6${CEND}. Install MariaDB-5.5"
+        echo -e "\t${CMSG} 7${CEND}. Install Percona-5.7"
+        echo -e "\t${CMSG} 8${CEND}. Install Percona-5.6"
+        echo -e "\t${CMSG} 9${CEND}. Install Percona-5.5"
+        echo -e "\t${CMSG}10${CEND}. Install AliSQL-5.6"
         read -p "Please input a number:(Default 2 press Enter) " DB_version
         [ -z "$DB_version" ] && DB_version=2
-        if [[ ! $DB_version =~ ^[0-9]$ ]]; then
-          echo "${CWARNING}input error! Please only input number 1,2,3,4,5,6,7,8,9,0${CEND}"
-        else
+        if [ ${DB_version} -ge 1 >/dev/null 2>&1 -a ${DB_version} -le 10 >/dev/null 2>&1 ]; then
           while :; do
             read -p "Please input the root password of database: " dbrootpwd
             [ -n "`echo $dbrootpwd | grep '[+|&]'`" ] && { echo "${CWARNING}input error,not contain a plus sign (+) and & ${CEND}"; continue; }
@@ -202,6 +200,8 @@ while :; do echo
             done
           fi
           break
+        else
+          echo "${CWARNING}input error! Please only input number 1,2,3,4,5,6,7,8,9,10${CEND}"
         fi
       done
     fi
@@ -474,20 +474,42 @@ IPADDR_COUNTRY_ISP=`./include/get_ipaddr_state.py $PUBLIC_IPADDR`
 IPADDR_COUNTRY=`echo $IPADDR_COUNTRY_ISP | awk '{print $1}'`
 [ "`echo $IPADDR_COUNTRY_ISP | awk '{print $2}'`"x == '1000323'x ] && IPADDR_ISP=aliyun
 
-# check download src
-. ./include/check_download.sh
-checkDownload 2>&1 | tee $oneinstack_dir/install.log
+# Check binary dependencies packages
+. ./include/check_sw.sh
+case "${OS}" in
+  "CentOS")
+    installDepsCentOS 2>&1 | tee ${oneinstack_dir}/install.log
+    ;;
+  "Debian")
+    installDepsDebian 2>&1 | tee ${oneinstack_dir}/install.log
+    ;;
+  "Ubuntu")
+    installDepsUbuntu 2>&1 | tee ${oneinstack_dir}/install.log
+    ;;
+esac
 
 # init
 . ./include/memory.sh
-if [ "$OS" == 'CentOS' ]; then
-  . include/init_CentOS.sh 2>&1 | tee -a $oneinstack_dir/install.log
-  [ -n "`gcc --version | head -n1 | grep '4\.1\.'`" ] && export CC="gcc44" CXX="g++44"
-elif [ "$OS" == 'Debian' ]; then
-  . include/init_Debian.sh 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$OS" == 'Ubuntu' ]; then
-  . include/init_Ubuntu.sh 2>&1 | tee -a $oneinstack_dir/install.log
-fi
+case "${OS}" in
+  "CentOS")
+    . include/init_CentOS.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
+    [ -n "$(gcc --version | head -n1 | grep '4\.1\.')" ] && export CC="gcc44" CXX="g++44"
+    ;;
+  "Debian")
+    . include/init_Debian.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  "Ubuntu")
+    . include/init_Ubuntu.sh 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+esac
+
+# Check download source packages
+. ./include/check_download.sh
+downloadDepsSrc=1
+checkDownload 2>&1 | tee -a ${oneinstack_dir}/install.log
+
+# Install dependencies from source package
+installDepsBySrc 2>&1 | tee -a ${oneinstack_dir}/install.log
 
 # jemalloc or tcmalloc
 if [ "$je_tc_malloc_yn" == 'y' -a "$je_tc_malloc" == '1' -a ! -e "/usr/local/lib/libjemalloc.so" ]; then
@@ -504,49 +526,60 @@ if [ "$je_tc_malloc_yn" == 'y' -a "$je_tc_malloc" == '2' -a ! -e "/usr/local/lib
 fi
 
 # Database
-if [ "$DB_version" == '1' ]; then
-  if [ "${dbInstallMethods}" == "2" ]; then
-    . include/boost.sh
-    installBoost 2>&1 | tee -a $oneinstack_dir/install.log
-  fi
-  . include/mysql-5.7.sh
-  Install_MySQL-5-7 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$DB_version" == '2' ]; then
-  . include/mysql-5.6.sh
-  Install_MySQL-5-6 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$DB_version" == '3' ]; then
-  . include/mysql-5.5.sh
-  Install_MySQL-5-5 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$DB_version" == '4' ]; then
-  if [ "${dbInstallMethods}" == "2" ]; then
-    . include/boost.sh
-    installBoost 2>&1 | tee -a $oneinstack_dir/install.log
-  fi
-  . include/mariadb-10.1.sh
-  Install_MariaDB-10-1 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$DB_version" == '5' ]; then
-  . include/mariadb-10.0.sh
-  Install_MariaDB-10-0 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$DB_version" == '6' ]; then
-  . include/mariadb-5.5.sh
-  Install_MariaDB-5-5 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$DB_version" == '7' ]; then
-  if [ "${dbInstallMethods}" == "2" ]; then
-    . include/boost.sh
-    installBoost 2>&1 | tee -a $oneinstack_dir/install.log
-  fi
-  . include/percona-5.7.sh
-  Install_Percona-5-7 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$DB_version" == '8' ]; then
-  . include/percona-5.6.sh
-  Install_Percona-5-6 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$DB_version" == '9' ]; then
-  . include/percona-5.5.sh
-  Install_Percona-5-5 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$DB_version" == '0' ]; then
-  . include/alisql-5.6.sh
-  Install_AliSQL-5-6 2>&1 | tee -a $oneinstack_dir/install.log
-fi
+case "${DB_version}" in
+  1)
+    if [ "${dbInstallMethods}" == "2" ]; then
+      . include/boost.sh
+      installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
+    fi
+    . include/mysql-5.7.sh
+    Install_MySQL-5-7 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  2)
+    . include/mysql-5.6.sh
+    Install_MySQL-5-6 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  3)
+    . include/mysql-5.5.sh
+    Install_MySQL-5-5 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  4)
+    if [ "${dbInstallMethods}" == "2" ]; then
+      . include/boost.sh
+      installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
+    fi
+    . include/mariadb-10.1.sh
+    Install_MariaDB-10-1 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  5)
+    . include/mariadb-10.0.sh
+    Install_MariaDB-10-0 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  6)
+    . include/mariadb-5.5.sh
+    Install_MariaDB-5-5 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  7)
+    if [ "${dbInstallMethods}" == "2" ]; then
+      . include/boost.sh
+      installBoost 2>&1 | tee -a ${oneinstack_dir}/install.log
+    fi
+    . include/percona-5.7.sh
+    Install_Percona-5-7 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  8)
+    . include/percona-5.6.sh
+    Install_Percona-5-6 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  9)
+    . include/percona-5.5.sh
+    Install_Percona-5-5 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  10)
+    . include/alisql-5.6.sh
+    Install_AliSQL-5-6 2>&1 | tee -a $oneinstack_dir/install.log
+    ;;
+esac
 
 # Apache
 if [ "$Apache_version" == '1' ]; then
@@ -558,22 +591,28 @@ elif [ "$Apache_version" == '2' ]; then
 fi
 
 # PHP
-if [ "$PHP_version" == '1' ]; then
-  . include/php-5.3.sh
-  Install_PHP-5-3 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$PHP_version" == '2' ]; then
-  . include/php-5.4.sh
-  Install_PHP-5-4 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$PHP_version" == '3' ]; then
-  . include/php-5.5.sh
-  Install_PHP-5-5 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$PHP_version" == '4' ]; then
-  . include/php-5.6.sh
-  Install_PHP-5-6 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$PHP_version" == '5' ]; then
-  . include/php-7.0.sh
-  Install_PHP-7-0 2>&1 | tee -a $oneinstack_dir/install.log
-fi
+case "${PHP_version}" in
+  1)
+    . include/php-5.3.sh
+    Install_PHP-5-3 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  2)
+    . include/php-5.4.sh
+    Install_PHP-5-4 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  3)
+    . include/php-5.5.sh
+    Install_PHP-5-5 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  4)
+    . include/php-5.6.sh
+    Install_PHP-5-6 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  5)
+    . include/php-7.0.sh
+    Install_PHP-7-0 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+esac
 
 # ImageMagick or GraphicsMagick
 if [ "$Magick" == '1' ]; then
@@ -593,22 +632,28 @@ if [ "$ionCube_yn" == 'y' ]; then
 fi
 
 # PHP opcode cache
-if [ "$PHP_cache" == '1' ] && [[ "$PHP_version" =~ ^[1,2]$ ]]; then
-  . include/zendopcache.sh
-  Install_ZendOPcache 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$PHP_cache" == '2' ]; then
-  . include/xcache.sh
-  Install_XCache 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$PHP_cache" == '3' ]; then
-  . include/apcu.sh
-  Install_APCU 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$PHP_cache" == '4' -a "$PHP_version" == '2' ]; then
-  . include/eaccelerator-1.0-dev.sh
-  Install_eAccelerator-1-0-dev 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$PHP_cache" == '4' -a "$PHP_version" == '1' ]; then
-  . include/eaccelerator-0.9.sh
-  Install_eAccelerator-0-9 2>&1 | tee -a $oneinstack_dir/install.log
-fi
+case "${PHP_cache}" in
+  1)
+    if [[ "${PHP_version}" =~ ^[1,2]$ ]]; then
+      . include/zendopcache.sh
+      Install_ZendOPcache 2>&1 | tee -a ${oneinstack_dir}/install.log
+    fi
+    ;;
+  2)
+    . include/xcache.sh
+    Install_XCache 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  3)
+    . include/apcu.sh
+    Install_APCU 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  4)
+    if [[ "${PHP_version}" =~ ^[1,2]$ ]]; then
+      . include/eaccelerator.sh
+      Install_eAccelerator 2>&1 | tee -a ${oneinstack_dir}/install.log
+    fi
+    ;;
+esac
 
 # ZendGuardLoader (php <= 5.6)
 if [ "$ZendGuardLoader_yn" == 'y' ]; then
@@ -617,118 +662,130 @@ if [ "$ZendGuardLoader_yn" == 'y' ]; then
 fi
 
 # Web server
-if [ "$Nginx_version" == '1' ]; then
-  . include/nginx.sh
-  Install_Nginx 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$Nginx_version" == '2' ]; then
-  . include/tengine.sh
-  Install_Tengine 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$Nginx_version" == '3' ]; then
-  . include/openresty.sh
-  Install_OpenResty 2>&1 | tee -a $oneinstack_dir/install.log
-fi
+case "${Nginx_version}" in
+  1)
+    . include/nginx.sh
+    Install_Nginx 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  2)
+    . include/tengine.sh
+    Install_Tengine 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  3)
+    . include/openresty.sh
+    Install_OpenResty 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+esac
 
 # JDK
-if [ "$JDK_version" == '1' ]; then
-  . include/jdk-1.8.sh
-  Install-JDK-1-8 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$JDK_version" == '2' ]; then
-  . include/jdk-1.7.sh
-  Install-JDK-1-7 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$JDK_version" == '3' ]; then
-  . include/jdk-1.6.sh
-  Install-JDK-1-6 2>&1 | tee -a $oneinstack_dir/install.log
-fi
-
-if [ "$Tomcat_version" == '1' ]; then
-  . include/tomcat-8.sh
-  Install_tomcat-8 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$Tomcat_version" == '2' ]; then
-  . include/tomcat-7.sh
-  Install_tomcat-7 2>&1 | tee -a $oneinstack_dir/install.log
-elif [ "$Tomcat_version" == '3' ]; then
-  . include/tomcat-6.sh
-  Install_tomcat-6 2>&1 | tee -a $oneinstack_dir/install.log
-fi
+case "${JDK_version}" in
+  1)
+    . include/jdk-1.8.sh
+    Install-JDK-1-8 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  2)
+    . include/jdk-1.7.sh
+    Install-JDK-1-7 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  3)
+    . include/jdk-1.6.sh
+    Install-JDK-1-6 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+esac
+
+case "${Tomcat_version}" in
+  1)
+    . include/tomcat-8.sh
+    Install_tomcat-8 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  2)
+    . include/tomcat-7.sh
+    Install_tomcat-7 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+  3)
+    . include/tomcat-6.sh
+    Install_tomcat-6 2>&1 | tee -a ${oneinstack_dir}/install.log
+    ;;
+esac
 
 # Pure-FTPd
-if [ "$FTP_yn" == 'y' ]; then
+if [ "${FTP_yn}" == 'y' ]; then
   . include/pureftpd.sh
-  Install_PureFTPd 2>&1 | tee -a $oneinstack_dir/install.log
+  Install_PureFTPd 2>&1 | tee -a ${oneinstack_dir}/install.log
 fi
 
 # phpMyAdmin
-if [ "$phpMyAdmin_yn" == 'y' ]; then
+if [ "${phpMyAdmin_yn}" == 'y' ]; then
   . include/phpmyadmin.sh
-  Install_phpMyAdmin 2>&1 | tee -a $oneinstack_dir/install.log
+  Install_phpMyAdmin 2>&1 | tee -a ${oneinstack_dir}/install.log
 fi
 
 # redis
-if [ "$redis_yn" == 'y' ]; then
+if [ "${redis_yn}" == 'y' ]; then
   . include/redis.sh
-  [ ! -d "$redis_install_dir" ] && Install_redis-server 2>&1 | tee -a $oneinstack_dir/install.log
-  [ -e "$php_install_dir/bin/phpize" ] && [ ! -e "`$php_install_dir/bin/php-config --extension-dir`/redis.so" ] && Install_php-redis 2>&1 | tee -a $oneinstack_dir/install.log
+  [ ! -d "${redis_install_dir}" ] && Install_redis-server 2>&1 | tee -a ${oneinstack_dir}/install.log
+  [ -e "${php_install_dir}/bin/phpize" ] && [ ! -e "$(${php_install_dir}/bin/php-config --extension-dir)/redis.so" ] && Install_php-redis 2>&1 | tee -a ${oneinstack_dir}/install.log
 fi
 
 # memcached
-if [ "$memcached_yn" == 'y' ]; then
+if [ "${memcached_yn}" == 'y' ]; then
   . include/memcached.sh
-  [ ! -d "$memcached_install_dir/include/memcached" ] && Install_memcached 2>&1 | tee -a $oneinstack_dir/install.log
-  [ -e "$php_install_dir/bin/phpize" ] && [ ! -e "`$php_install_dir/bin/php-config --extension-dir`/memcache.so" ] && Install_php-memcache 2>&1 | tee -a $oneinstack_dir/install.log
-  [ -e "$php_install_dir/bin/phpize" ] && [ ! -e "`$php_install_dir/bin/php-config --extension-dir`/memcached.so" ] && Install_php-memcached 2>&1 | tee -a $oneinstack_dir/install.log
+  [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached 2>&1 | tee -a ${oneinstack_dir}/install.log
+  [ -e "${php_install_dir}/bin/phpize" ] && [ ! -e "$(${php_install_dir}/bin/php-config --extension-dir)/memcache.so" ] && Install_php-memcache 2>&1 | tee -a ${oneinstack_dir}/install.log
+  [ -e "${php_install_dir}/bin/phpize" ] && [ ! -e "$(${php_install_dir}/bin/php-config --extension-dir)/memcached.so" ] && Install_php-memcached 2>&1 | tee -a ${oneinstack_dir}/install.log
 fi
 
 # index example
-if [ ! -e "$wwwroot_dir/default/index.html" -a "$Web_yn" == 'y' ]; then
+if [ ! -e "${wwwroot_dir}/default/index.html" -a "${Web_yn}" == 'y' ]; then
   . include/demo.sh
-  DEMO 2>&1 | tee -a $oneinstack_dir/install.log
+  DEMO 2>&1 | tee -a ${oneinstack_dir}/install.log
 fi
 
 # get web_install_dir and db_install_dir
 . include/check_dir.sh
 
 # HHVM
-if [ "$HHVM_yn" == 'y' ]; then
+if [ "${HHVM_yn}" == 'y' ]; then
   . include/hhvm_CentOS.sh
-  Install_hhvm_CentOS 2>&1 | tee -a $oneinstack_dir/install.log
+  Install_hhvm_CentOS 2>&1 | tee -a ${oneinstack_dir}/install.log
 fi
 
 # Starting DB
 [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
-[ -d "$db_install_dir/support-files" -a -z "`ps -ef | grep -v grep | grep mysql`" ] && /etc/init.d/mysqld start
+[ -d "${db_install_dir}/support-files" -a -z "$(ps -ef | grep -v grep | grep mysql)" ] && /etc/init.d/mysqld start
 
 echo "####################Congratulations########################"
-[ "$Web_yn" == 'y' -a "$Nginx_version" != '4' -a "$Apache_version" == '3' ] && echo -e "\n`printf "%-32s" "Nginx install dir":`${CMSG}$web_install_dir${CEND}"
-[ "$Web_yn" == 'y' -a "$Nginx_version" != '4' -a "$Apache_version" != '3' ] && echo -e "\n`printf "%-32s" "Nginx install dir":`${CMSG}$web_install_dir${CEND}\n`printf "%-32s" "Apache install  dir":`${CMSG}$apache_install_dir${CEND}"
-[ "$Web_yn" == 'y' -a "$Nginx_version" == '4' -a "$Apache_version" != '3' ] && echo -e "\n`printf "%-32s" "Apache install dir":`${CMSG}$apache_install_dir${CEND}"
-[[ "$Tomcat_version" =~ ^[1,2]$ ]] && echo -e "\n`printf "%-32s" "Tomcat install dir":`${CMSG}$tomcat_install_dir${CEND}"
-[ "$DB_yn" == 'y' ] && echo -e "\n`printf "%-32s" "Database install dir:"`${CMSG}$db_install_dir${CEND}"
-[ "$DB_yn" == 'y' ] && echo "`printf "%-32s" "Database data dir:"`${CMSG}$db_data_dir${CEND}"
-[ "$DB_yn" == 'y' ] && echo "`printf "%-32s" "Database user:"`${CMSG}root${CEND}"
-[ "$DB_yn" == 'y' ] && echo "`printf "%-32s" "Database password:"`${CMSG}${dbrootpwd}${CEND}"
-[ "$PHP_yn" == 'y' ] && echo -e "\n`printf "%-32s" "PHP install dir:"`${CMSG}$php_install_dir${CEND}"
-[ "$PHP_cache" == '1' ] && echo "`printf "%-32s" "Opcache Control Panel url:"`${CMSG}http://$IPADDR/ocp.php${CEND}"
-[ "$PHP_cache" == '2' ] && echo "`printf "%-32s" "xcache Control Panel url:"`${CMSG}http://$IPADDR/xcache${CEND}"
-[ "$PHP_cache" == '2' ] && echo "`printf "%-32s" "xcache user:"`${CMSG}admin${CEND}"
-[ "$PHP_cache" == '2' ] && echo "`printf "%-32s" "xcache password:"`${CMSG}$xcache_admin_pass${CEND}"
-[ "$PHP_cache" == '3' ] && echo "`printf "%-32s" "APC Control Panel url:"`${CMSG}http://$IPADDR/apc.php${CEND}"
-[ "$PHP_cache" == '4' ] && echo "`printf "%-32s" "eAccelerator Control Panel url:"`${CMSG}http://$IPADDR/control.php${CEND}"
-[ "$PHP_cache" == '4' ] && echo "`printf "%-32s" "eAccelerator user:"`${CMSG}admin${CEND}"
-[ "$PHP_cache" == '4' ] && echo "`printf "%-32s" "eAccelerator password:"`${CMSG}eAccelerator${CEND}"
-[ "$FTP_yn" == 'y' ] && echo -e "\n`printf "%-32s" "Pure-FTPd install dir:"`${CMSG}$pureftpd_install_dir${CEND}"
-[ "$FTP_yn" == 'y' ] && echo "`printf "%-32s" "Create FTP virtual script:"`${CMSG}./pureftpd_vhost.sh${CEND}"
-[ "$phpMyAdmin_yn" == 'y' ] && echo -e "\n`printf "%-32s" "phpMyAdmin dir:"`${CMSG}$wwwroot_dir/default/phpMyAdmin${CEND}"
-[ "$phpMyAdmin_yn" == 'y' ] && echo "`printf "%-32s" "phpMyAdmin Control Panel url:"`${CMSG}http://$IPADDR/phpMyAdmin${CEND}"
-[ "$redis_yn" == 'y' ] && echo -e "\n`printf "%-32s" "redis install dir:"`${CMSG}$redis_install_dir${CEND}"
-[ "$memcached_yn" == 'y' ] && echo -e "\n`printf "%-32s" "memcached install dir:"`${CMSG}$memcached_install_dir${CEND}"
-[ "$Web_yn" == 'y' ] && echo -e "\n`printf "%-32s" "index url:"`${CMSG}http://$IPADDR/${CEND}"
+[ "${Web_yn}" == 'y' -a "${Nginx_version}" != '4' -a "${Apache_version}" == '3' ] && echo -e "\n$(printf "%-32s" "Nginx install dir":)${CMSG}${web_install_dir}${CEND}"
+[ "${Web_yn}" == 'y' -a "${Nginx_version}" != '4' -a "${Apache_version}" != '3' ] && echo -e "\n$(printf "%-32s" "Nginx install dir":)${CMSG}${web_install_dir}${CEND}\n$(printf "%-32s" "Apache install  dir":)${CMSG}${apache_install_dir}${CEND}"
+[ "${Web_yn}" == 'y' -a "${Nginx_version}" == '4' -a "${Apache_version}" != '3' ] && echo -e "\n$(printf "%-32s" "Apache install dir":)${CMSG}${apache_install_dir}${CEND}"
+[[ "${Tomcat_version}" =~ ^[1,2]$ ]] && echo -e "\n$(printf "%-32s" "Tomcat install dir":)${CMSG}${tomcat_install_dir}${CEND}"
+[ "${DB_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "Database install dir:")${CMSG}${db_install_dir}${CEND}"
+[ "${DB_yn}" == 'y' ] && echo "$(printf "%-32s" "Database data dir:")${CMSG}${db_data_dir}${CEND}"
+[ "${DB_yn}" == 'y' ] && echo "$(printf "%-32s" "Database user:")${CMSG}root${CEND}"
+[ "${DB_yn}" == 'y' ] && echo "$(printf "%-32s" "Database password:")${CMSG}${dbrootpwd}${CEND}"
+[ "${PHP_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "PHP install dir:")${CMSG}${php_install_dir}${CEND}"
+[ "${PHP_cache}" == '1' ] && echo "$(printf "%-32s" "Opcache Control Panel url:")${CMSG}http://${IPADDR}/ocp.php${CEND}"
+[ "${PHP_cache}" == '2' ] && echo "$(printf "%-32s" "xcache Control Panel url:")${CMSG}http://${IPADDR}/xcache${CEND}"
+[ "${PHP_cache}" == '2' ] && echo "$(printf "%-32s" "xcache user:")${CMSG}admin${CEND}"
+[ "${PHP_cache}" == '2' ] && echo "$(printf "%-32s" "xcache password:")${CMSG}${xcache_admin_pass}${CEND}"
+[ "${PHP_cache}" == '3' ] && echo "$(printf "%-32s" "APC Control Panel url:")${CMSG}http://${IPADDR}/apc.php${CEND}"
+[ "${PHP_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator Control Panel url:")${CMSG}http://${IPADDR}/control.php${CEND}"
+[ "${PHP_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator user:")${CMSG}admin${CEND}"
+[ "${PHP_cache}" == '4' ] && echo "$(printf "%-32s" "eAccelerator password:")${CMSG}eAccelerator${CEND}"
+[ "${FTP_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "Pure-FTPd install dir:")${CMSG}${pureftpd_install_dir}${CEND}"
+[ "${FTP_yn}" == 'y' ] && echo "$(printf "%-32s" "Create FTP virtual script:")${CMSG}./pureftpd_vhost.sh${CEND}"
+[ "${phpMyAdmin_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "phpMyAdmin dir:")${CMSG}${wwwroot_dir}/default/phpMyAdmin${CEND}"
+[ "${phpMyAdmin_yn}" == 'y' ] && echo "$(printf "%-32s" "phpMyAdmin Control Panel url:")${CMSG}http://${IPADDR}/phpMyAdmin${CEND}"
+[ "${redis_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "redis install dir:")${CMSG}${redis_install_dir}${CEND}"
+[ "${memcached_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "memcached install dir:")${CMSG}${memcached_install_dir}${CEND}"
+[ "${Web_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "index url:")${CMSG}http://${IPADDR}/${CEND}"
 while :; do echo
   echo "${CMSG}Please restart the server and see if the services start up fine.${CEND}"
   read -p "Do you want to restart OS ? [y/n]: " restart_yn
-  if [[ ! $restart_yn =~ ^[y,n]$ ]]; then
+  if [[ ! "${restart_yn}" =~ ^[y,n]$ ]]; then
     echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
   else
     break
   fi
 done
-[ "$restart_yn" == 'y' ] && reboot
+[ "${restart_yn}" == 'y' ] && reboot

+ 66 - 65
shadowsocks.sh

@@ -26,11 +26,11 @@ pushd src > /dev/null
 . ../include/download.sh
 
 # Check if user is root
-[ $(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; }
 
-PUBLIC_IPADDR=`../include/get_public_ipaddr.py`
+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() {
   [ -f /usr/local/bin/ss-server ] && SS_version=1
@@ -40,60 +40,61 @@ Check_shadowsocks() {
 AddUser_shadowsocks() {
   while :; do echo
     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}"
   done
 }
 
 Iptables_set() {
   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
-    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
-    Shadowsocks_Default_port=`expr $Shadowsocks_Already_port + 1`
+
+  if [ -n "${Shadowsocks_Already_port}" ]; then
+    let Shadowsocks_Default_port="${Shadowsocks_Already_port}+1"
   else
     Shadowsocks_Default_port=9001
   fi
-  
+
   while :; do echo
-    read -p "Please input Shadowsocks port(Default: $Shadowsocks_Default_port): " Shadowsocks_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}"
+    read -p "Please input Shadowsocks port(Default: ${Shadowsocks_Default_port}): " Shadowsocks_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}"
     else
       echo "${CWARNING}input error! Input range: 1~65535${CEND}"
     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
+
+  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
-  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
+  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
   else
-    echo "${CWARNING}This port is already in iptables! ${CEND}"
+      echo "${CWARNING}This port is already in iptables! ${CEND}"
   fi
+
 }
 
 Def_parameter() {
-  if [ "$OS" == 'CentOS' ]; then
+  if [ "${OS}" == "CentOS" ]; then
     while :; do echo
-      echo 'Please select Shadowsocks server version:'
+      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
+      [ -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
@@ -101,17 +102,17 @@ Def_parameter() {
     done
     AddUser_shadowsocks
     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 pcre-devel
-    do
-      yum -y install $Package
+    pkgList="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 pcre-devel"
+    for Package in ${pkgList}; do
+      yum -y install ${Package}
     done
-  elif [[ $OS =~ ^Ubuntu$|^Debian$ ]]; then
+  elif [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]]; then
     SS_version=2
     AddUser_shadowsocks
     Iptables_set
     apt-get -y update
-    for Package in python-dev python-pip curl wget unzip gcc swig automake make perl cpio git
-    do
+    pkgList="python-dev python-pip curl wget unzip gcc swig automake make perl cpio git"
+    for Package in ${pkgList}; do
       apt-get -y install $Package
     done
   fi
@@ -119,10 +120,10 @@ Def_parameter() {
 
 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; }
-  
+  [ $? -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 greenlet
@@ -131,8 +132,8 @@ Install_shadowsocks-python() {
     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
+      [ "${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
       echo
@@ -151,7 +152,7 @@ Install_shadowsocks-libev() {
   if [ -f  /usr/local/bin/ss-server ]; then
     /bin/cp ../init.d/Shadowsocks-libev-init /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}"
@@ -163,19 +164,19 @@ Install_shadowsocks-libev() {
 Uninstall_shadowsocks(){
   while :; do echo
     read -p "Do you want to uninstall Shadowsocks? [y/n]: " Shadowsocks_yn
-    if [[ ! $Shadowsocks_yn =~ ^[y,n]$ ]]; then
+    if [[ ! "${Shadowsocks_yn}" =~ ^[y,n]$ ]]; then
       echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
     else
       break
     fi
   done
-  
-  if [ "$Shadowsocks_yn" == 'y' ]; then
-    [ -n "`ps -ef | grep -v grep | grep -iE "ssserver|ss-server"`" ] && /etc/init.d/shadowsocks stop
-    [ "$OS" == 'CentOS' ] && chkconfig --del shadowsocks
-    [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d -f shadowsocks remove
+
+  if [ "${Shadowsocks_yn}" == 'y' ]; then
+    [ -n "$(ps -ef | grep -v grep | grep -iE "ssserver|ss-server")" ] && /etc/init.d/shadowsocks stop
+    [ "${OS}" == "CentOS" ] && chkconfig --del shadowsocks
+    [[ "${OS}" =~ ^Ubuntu$|^Debian$ ]] && update-rc.d -f shadowsocks remove
     rm -rf /etc/shadowsocks /var/run/shadowsocks.pid /etc/init.d/shadowsocks
-    if [ "$SS_version" == '1' ]; then
+    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
@@ -192,44 +193,44 @@ Uninstall_shadowsocks(){
       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}"
+        echo "${CSUCCESS}Shadowsocks-libev uninstall successful! ${CEND}"
       else
         echo "${CFAILURE}Shadowsocks-libev uninstall failed! ${CEND}"
       fi
-    elif [ "$SS_version" == '2' ]; then
+    elif [ "${SS_version}" == '2' ]; then
       pip uninstall -y shadowsocks
       if [ $? -eq 0 ]; then
-        echo "${CSUCCESS}Shadowsocks-python uninstall success! ${CEND}"
+        echo "${CSUCCESS}Shadowsocks-python uninstall successful! ${CEND}"
       else
         echo "${CFAILURE}Shadowsocks-python uninstall failed! ${CEND}"
       fi
     fi
   else
-    echo "${CMSG}Shadowsocks uninstall cancelled! ${CEND}"
+    echo "${CMSG}Unknown Shadowsocks version, uninstall failed! ${CEND}"
   fi
 }
 
 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_port":$Shadowsocks_port,
+    "server_port":${Shadowsocks_port},
     "local_address":"127.0.0.1",
     "local_port":1080,
-    "password":"$Shadowsocks_password",
+    "password":"${Shadowsocks_password}",
     "timeout":300,
     "method":"aes-256-cfb",
 }
 EOF
 
-  [ "$SS_version" == '2' ] && cat > /etc/shadowsocks/config.json<<EOF
+  [ "${SS_version}" == '2' ] && cat > /etc/shadowsocks/config.json << EOF
 {
     "server":"0.0.0.0",
     "local_address":"127.0.0.1",
     "local_port":1080,
     "port_password":{
-    "$Shadowsocks_port":"$Shadowsocks_password"
+    "${Shadowsocks_port}":"${Shadowsocks_password}"
     },
     "timeout":300,
     "method":"aes-256-cfb",
@@ -240,14 +241,14 @@ EOF
 
 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; }
+  [ -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(){
   printf "
-Your Server IP: ${CMSG}$PUBLIC_IPADDR${CEND}
-Your Server Port: ${CMSG}$Shadowsocks_port${CEND}
-Your Password: ${CMSG}$Shadowsocks_password${CEND}
+Your Server IP: ${CMSG}${PUBLIC_IPADDR}${CEND}
+Your Server Port: ${CMSG}${Shadowsocks_port}${CEND}
+Your Password: ${CMSG}${Shadowsocks_password}${CEND}
 Your Local IP: ${CMSG}127.0.0.1${CEND}
 Your Local Port: ${CMSG}1080${CEND}
 Your Encryption Method: ${CMSG}aes-256-cfb${CEND}
@@ -257,15 +258,15 @@ Your Encryption Method: ${CMSG}aes-256-cfb${CEND}
 case "$1" in
 install)
   Def_parameter
-  [ "$SS_version" == '1' ] && Install_shadowsocks-libev
-  [ "$SS_version" == '2' ] && Install_shadowsocks-python
+  [ "${SS_version}" == '1' ] && Install_shadowsocks-libev
+  [ "${SS_version}" == '2' ] && Install_shadowsocks-python
   Config_shadowsocks
   service shadowsocks start
   Print_User_shadowsocks
   ;;
 adduser)
   Check_shadowsocks
-  if [ "$SS_version" == '2' ]; then
+  if [ "${SS_version}" == '2' ]; then
     AddUser_shadowsocks
     Iptables_set
     AddUser_Config_shadowsocks
@@ -286,7 +287,7 @@ uninstall)
   ;;
 *)
   echo
-  echo $"Usage: ${CMSG}$0${CEND} { ${CMSG}install${CEND} | ${CMSG}adduser${CEND} | ${CMSG}uninstall${CEND} }"
+  echo "Usage: ${CMSG}$0${CEND} { ${CMSG}install${CEND} | ${CMSG}adduser${CEND} | ${CMSG}uninstall${CEND} }"
   echo
   exit 1
 esac

File diff suppressed because it is too large
+ 324 - 308
vhost.sh


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