Browse Source

Optimization OneinStack

lj2007331@gmail.com 6 years ago
parent
commit
7d41edb625

+ 156 - 586
addons.sh

@@ -23,162 +23,76 @@ printf "
 oneinstack_dir=$(dirname "`readlink -f $0`")
 pushd ${oneinstack_dir} > /dev/null
 
-# get the IP information
-PUBLIC_IPADDR=$(./include/get_public_ipaddr.py)
-IPADDR_COUNTRY=$(./include/get_ipaddr_state.py $PUBLIC_IPADDR)
-
 . ./versions.txt
 . ./options.conf
 . ./include/color.sh
-. ./include/memory.sh
 . ./include/check_os.sh
-. ./include/check_download.sh
 . ./include/download.sh
 . ./include/get_char.sh
 
-. ./include/zendopcache.sh
-. ./include/xcache.sh
-. ./include/apcu.sh
-. ./include/eaccelerator.sh
-
-. ./include/ZendGuardLoader.sh
-. ./include/ioncube.sh
-. ./include/sourceguardian.sh
-
-. ./include/ImageMagick.sh
-. ./include/GraphicsMagick.sh
-
-. ./include/pecl_mongodb.sh
-
-. ./include/memcached.sh
-
-. ./include/redis.sh
+. ./include/composer.sh
 
 . ./include/python.sh
 
-. ./include/ngx_lua_waf.sh
+. ./include/fail2ban.sh
 
-. ./include/panel.sh
+. include/ngx_lua_waf.sh
 
-# Check PHP
-if [ -e "${php_install_dir}/bin/phpize" ]; then
-  phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
-  PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
-  PHP_main_ver=${PHP_detail_ver%.*}
-  case "${PHP_main_ver}" in
-    5.3)
-      php_option=1
-    ;;
-    5.4)
-      php_option=2
-    ;;
-    5.5)
-      php_option=3
-    ;;
-    5.6)
-      php_option=4
-    ;;
-    7.0)
-      php_option=5
-    ;;
-    7.1)
-      php_option=6
-    ;;
-    7.2)
-      php_option=7
-    ;;
-    7.3)
-      php_option=8
-    ;;
-  esac
-fi
-
-# Check PHP Extensions
-Check_PHP_Extension() {
-  [ ! -e "${php_install_dir}/bin/phpize" ] && { echo "${CWARNING}PHP was not exist! ${CEND}"; exit 1; }
-  [ -e "`ls ${php_install_dir}/etc/php.d/0?-${PHP_extension}.ini 2> /dev/null`" ] && { echo "${CWARNING}PHP ${PHP_extension} module already installed! ${CEND}"; exit 1; }
-}
-
-# restart PHP
-Restart_PHP() {
-  [ -e "${apache_install_dir}/conf/httpd.conf" ] && service httpd restart || service php-fpm restart
-}
+. include/panel.sh
 
-# Check succ
-Check_succ() {
-  [ -f "${phpExtensionDir}/${PHP_extension}.so" ] && { Restart_PHP; echo;echo "${CSUCCESS}PHP ${PHP_extension} module installed successfully! ${CEND}"; }
+showhelp() {
+  echo
+  echo "Usage: $0  command ...
+  --help, -h                  Show this help message
+  --install, -i               Install
+  --uninstall, -u             Uninstall
+  --composer                  Composer
+  --fail2ban                  Fail2ban
+  --ngx_lua_waf               Ngx_lua_waf
+  --python                    Python3.6
+  --panel                     OneinStack Panel
+  "
 }
 
-# Uninstall succ
-Uninstall_succ() {
-  [ -e "`ls ${php_install_dir}/etc/php.d/0?-${PHP_extension}.ini 2> /dev/null`" ] && { rm -rf ${php_install_dir}/etc/php.d/0?-${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_fail2ban() {
-  [ ! -e "${python_install_dir}/bin/python" ] && Install_Python
-  pushd ${oneinstack_dir}/src > /dev/null
-  src_url=http://mirrors.linuxeye.com/oneinstack/src/fail2ban-${fail2ban_ver}.tar.gz && Download_src
-  tar xzf fail2ban-${fail2ban_ver}.tar.gz
-  pushd fail2ban-${fail2ban_ver}
-  sed -i 's@for i in xrange(50)@for i in range(50)@' fail2ban/__init__.py
-  ${python_install_dir}/bin/python setup.py install
-  if [ "${PM}" == 'yum' ]; then
-    LOGPATH=/var/log/secure
-    /bin/cp files/redhat-initd /etc/init.d/fail2ban
-    sed -i "s@^FAIL2BAN=.*@FAIL2BAN=${python_install_dir}/bin/fail2ban-client@" /etc/init.d/fail2ban
-    sed -i 's@Starting fail2ban.*@&\n    [ ! -e "/var/run/fail2ban" ] \&\& mkdir /var/run/fail2ban@' /etc/init.d/fail2ban
-    chmod +x /etc/init.d/fail2ban
-    chkconfig --add fail2ban
-    chkconfig fail2ban on
-  fi
-  if [ "${PM}" == 'apt-get' ]; then
-    LOGPATH=/var/log/auth.log
-    /bin/cp files/debian-initd /etc/init.d/fail2ban
-    sed -i 's@2 3 4 5@3 4 5@' /etc/init.d/fail2ban
-    sed -i "s@^DAEMON=.*@DAEMON=${python_install_dir}/bin/\$NAME-client@" /etc/init.d/fail2ban
-    chmod +x /etc/init.d/fail2ban
-    update-rc.d fail2ban defaults
-  fi
-  [ -z "`grep ^Port /etc/ssh/sshd_config`" ] && now_ssh_port=22 || now_ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}' | head -1`
-  cat > /etc/fail2ban/jail.local << EOF
-[DEFAULT]
-ignoreip = 127.0.0.1/8
-bantime  = 86400
-findtime = 600
-maxretry = 5
-[ssh-iptables]
-enabled = true
-filter  = sshd
-action  = iptables[name=SSH, port=$now_ssh_port, protocol=tcp]
-logpath = $LOGPATH
-EOF
-  cat > /etc/logrotate.d/fail2ban << EOF
-/var/log/fail2ban.log {
-    missingok
-    notifempty
-    postrotate
-      ${python_install_dir}/bin/fail2ban-client flushlogs >/dev/null || true
-    endscript
-}
-EOF
-  sed -i 's@^iptables = iptables.*@iptables = iptables@' /etc/fail2ban/action.d/iptables-common.conf
-  kill -9 `ps -ef | grep fail2ban | grep -v grep | awk '{print $2}'` > /dev/null 2>&1
-  service fail2ban start
-  popd > /dev/null
-  if [ -e "${python_install_dir}/bin/fail2ban-python" ]; then
-    echo; echo "${CSUCCESS}fail2ban installed successfully! ${CEND}"
-  else
-    echo; echo "${CFAILURE}fail2ban install failed, Please try again! ${CEND}"
-  fi
-  popd > /dev/null
-}
-
-Uninstall_fail2ban() {
-  service fail2ban stop
-  ${python_install_dir}/bin/pip uninstall -y fail2ban > /dev/null 2>&1
-  rm -rf /etc/init.d/fail2ban /etc/fail2ban /etc/logrotate.d/fail2ban /var/log/fail2ban.* /var/run/fail2ban
-  echo; echo "${CMSG}fail2ban uninstall completed${CEND}";
-}
+ARG_NUM=$#
+TEMP=`getopt -o hiu --long help,install,uninstall,composer,fail2ban,ngx_lua_waf,python,panel -- "$@" 2>/dev/null`
+[ $? != 0 ] && echo "${CWARNING}ERROR: unknown argument! ${CEND}" && showhelp && exit 1
+eval set -- "${TEMP}"
+while :; do
+  [ -z "$1" ] && break;
+  case "$1" in
+    -h|--help)
+      showhelp; exit 0
+      ;;
+    -i|--install)
+      install_yn=y; shift 1
+      ;;
+    -u|--uninstall)
+      uninstall_yn=y; shift 1
+      ;;
+    --composer)
+      composer_yn=y; shift 1
+      ;;
+    --fail2ban)
+      fail2ban_yn=y; shift 1
+      ;;
+    --ngx_lua_waf)
+      ngx_lua_waf_yn=y; shift 1
+      ;;
+    --python)
+      python_yn=y; shift 1
+      ;;
+    --panel)
+      panel_yn=y; shift 1
+      ;;
+    --)
+      shift
+      ;;
+    *)
+      echo "${CWARNING}ERROR: unknown argument! ${CEND}" && showhelp && exit 1
+      ;;
+  esac
+done
 
 ACTION_FUN() {
   while :; do
@@ -191,462 +105,118 @@ ACTION_FUN() {
     if [[ ! "${ACTION}" =~ ^[1,2]$ ]]; then
       echo "${CWARNING}input error! Please only input number 1~2${CEND}"
     else
+      [ "${ACTION}" == '1' ] && install_yn=y
+      [ "${ACTION}" == '2' ] && uninstall_yn=y
       break
     fi
   done
 }
 
-while :;do
-  printf "
+Menu() {
+  while :;do
+    printf "
 What Are You Doing?
-\t${CMSG} 1${CEND}. Install/Uninstall PHP opcode cache
-\t${CMSG} 2${CEND}. Install/Uninstall ZendGuardLoader/ionCube/SourceGuardian PHP Extension
-\t${CMSG} 3${CEND}. Install/Uninstall ImageMagick/GraphicsMagick PHP Extension
-\t${CMSG} 4${CEND}. Install/Uninstall fileinfo/imap/phalcon/mongodb PHP Extension
-\t${CMSG} 5${CEND}. Install/Uninstall memcached/memcache
-\t${CMSG} 6${CEND}. Install/Uninstall Redis
-\t${CMSG} 7${CEND}. Install/Uninstall swoole PHP Extension
-\t${CMSG} 8${CEND}. Install/Uninstall xdebug PHP Extension
-\t${CMSG} 9${CEND}. Install/Uninstall PHP Composer
-\t${CMSG}10${CEND}. Install/Uninstall fail2ban
-\t${CMSG}11${CEND}. Install/Uninstall ngx_lua_waf
-\t${CMSG} q${CEND}. Exit
+\t${CMSG}1${CEND}. Install/Uninstall PHP Composer
+\t${CMSG}2${CEND}. Install/Uninstall fail2ban
+\t${CMSG}3${CEND}. Install/Uninstall ngx_lua_waf
+\t${CMSG}4${CEND}. Install/Uninstall Python3.6
+\t${CMSG}q${CEND}. Exit
 "
-  read -e -p "Please input the correct option: " Number
-  if [[ ! "${Number}" =~ ^[1-9,q]$|^1[0-2]$ ]]; then
-    echo "${CFAILURE}input error! Please only input 1~11 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 -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
-          phpcache_option=${phpcache_option:-1}
-          if [[ ! "${phpcache_option}" =~ ^[1-4]$ ]]; then
-            echo "${CWARNING}input error! Please only input number 1~4${CEND}"
-          else
-            case "${phpcache_option}" 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
-          case "${phpcache_option}" in
-            1)
-              pushd ${oneinstack_dir}/src > /dev/null
-              if [[ "${PHP_main_ver}" =~ ^5.[3-4]$ ]]; then
-                src_url=https://pecl.php.net/get/zendopcache-${zendopcache_ver}.tgz && Download_src
-                Install_ZendOPcache
-              else
-                src_url=http://www.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src
-                Install_ZendOPcache
-              fi
-              popd > /dev/null
-              Check_succ
-              ;;
-            2)
-              if [[ "${PHP_main_ver}" =~ ^5.[3-6]$ ]]; then
-                while :; do
-                  read -e -p "Please input xcache admin password: " xcachepwd
-                  (( ${#xcachepwd} >= 5 )) && { xcachepwd_md5=$(echo -n "${xcachepwd}" | 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_ver}" =~ ^5.[3-6]$|^7.[0-3]$ ]]; then
-                checkDownload
-                Install_APCU
-                Check_succ
-              else
-                echo "${CWARNING}Your php does not support APCU! ${CEND}"; exit 1
-              fi
-              ;;
-            4)
-              if [[ "${PHP_main_ver}" =~ ^5.[3-4]$ ]]; then
-                checkDownload
-                Install_eAccelerator
-                Check_succ
-              else
-                echo "${CWARNING}Your php does not support eAccelerator! ${CEND}"; exit 1
-              fi
-              ;;
-          esac
-        else
-          Uninstall_succ
-        fi
-        ;;
-      2)
-        ACTION_FUN
-        while :; do echo
-          echo "Please select ZendGuardLoader/ionCube/SourceGuardian:"
-          echo -e "\t${CMSG}1${CEND}. ZendGuardLoader"
-          echo -e "\t${CMSG}2${CEND}. ionCube Loader"
-          echo -e "\t${CMSG}3${CEND}. SourceGuardian"
-          read -e -p "Please input a number:(Default 1 press Enter) " Loader
-          Loader=${Loader:-1}
-          if [[ ! "${Loader}" =~ ^[1-3]$ ]]; then
-            echo "${CWARNING}input error! Please only input number 1~3${CEND}"
-          else
-            [ "${Loader}" = '1' ] && PHP_extension=ZendGuardLoader
-            [ "${Loader}" = '2' ] && PHP_extension=ioncube
-            [ "${Loader}" = '3' ] && PHP_extension=sourceguardian
-            break
+    read -e -p "Please input the correct option: " Number
+    if [[ ! "${Number}" =~ ^[1-5,q]$ ]]; then
+      echo "${CFAILURE}input error! Please only input 1~4 and q${CEND}"
+    else
+      case "${Number}" in
+        1)
+          ACTION_FUN
+          if [ "${install_yn}" = 'y' ]; then
+            Install_composer
+          elif [ "${uninstall_yn}" = 'y' ]; then
+            Uninstall_composer
           fi
-        done
-        if [ "${ACTION}" = '1' ]; then
-          Check_PHP_Extension
-          if [ "${Loader}" = '1' ]; then
-            if [[ "${PHP_main_ver}" =~ ^5.[3-6]$ ]] && [ "${armplatform}" != 'y' ]; then
-              zendguardloader_yn='y' && checkDownload
-              Install_ZendGuardLoader
-              Check_succ
-            else
-              echo; echo "${CWARNING}Your php ${PHP_detail_ver} or platform ${TARGET_ARCH} does not support ${PHP_extension}! ${CEND}";
-            fi
-          elif [ "${Loader}" = '2' ]; then
-            if [[ "${PHP_main_ver}" =~ ^5.[3-6]$|^7.[0-2]$ ]] || [ "${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_ver} or platform ${TARGET_ARCH} does not support ${PHP_extension}! ${CEND}";
-            fi
-          elif [ "${Loader}" = '3' ]; then
-            if [[ "${PHP_main_ver}" =~ ^5.[3-6]$|^7.[0-2]$ ]] || [ "${TARGET_ARCH}" != "armv8" ]; then
-              sourceguardian_yn='y' && checkDownload
-              Install_SourceGuardian
-              Restart_PHP; echo "${CSUCCESS}PHP SourceGuardian module installed successfully! ${CEND}";
-            else
-              echo; echo "${CWARNING}Your php ${PHP_detail_ver} or platform ${TARGET_ARCH} does not support ${PHP_extension}! ${CEND}";
-            fi
+          ;;
+        2)
+          ACTION_FUN
+          if [ "${install_yn}" = 'y' ]; then
+            Install_fail2ban
+          elif [ "${uninstall_yn}" = 'y' ]; then
+            Uninstall_fail2ban
           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 -e -p "Please input a number:(Default 1 press Enter) " magick_option
-          magick_option=${magick_option:-1}
-          if [[ ! "${magick_option}" =~ ^[1,2]$ ]]; then
-            echo "${CWARNING}input error! Please only input number 1~2${CEND}"
-          else
-            [ "${magick_option}" = '1' ] && PHP_extension=imagick
-            [ "${magick_option}" = '2' ] && PHP_extension=gmagick
-            break
+          ;;
+        3)
+          ACTION_FUN
+          if [ "${install_yn}" = 'y' ]; then
+            [ -e "${nginx_install_dir}/sbin/nginx" ] && Nginx_lua_waf
+            [ -e "${tengine_install_dir}/sbin/nginx" ] && Tengine_lua_waf
+            enable_lua_waf
+          elif [ "${uninstall_yn}" = 'y' ]; then
+            disable_lua_waf
           fi
-        done
-        if [ "${ACTION}" = '1' ]; then
-          Check_PHP_Extension
-          magick_yn=y && checkDownload
-          if [ "${magick_option}" = '1' ]; then
-            [ ! -d "${imagick_install_dir}" ] && Install_ImageMagick
-            Install_pecl-imagick
-            Check_succ
-          elif [ "${magick_option}" = '2' ]; then
-            [ ! -d "${gmagick_install_dir}" ] && Install_GraphicsMagick
-            Install_pecl-gmagick
-            Check_succ
+          ;;
+        4)
+          ACTION_FUN
+          if [ "${install_yn}" = 'y' ]; then
+            Install_Python
+          elif [ "${uninstall_yn}" = 'y' ]; then
+            Uninstall_Python
           fi
-        else
-          Uninstall_succ
-          [ -d "${imagick_install_dir}" ] && rm -rf ${imagick_install_dir}
-          [ -d "${gmagick_install_dir}" ] && rm -rf ${gmagick_install_dir}
-        fi
-        ;;
-      4)
-        ACTION_FUN
-        while :; do echo
-          echo "Please select fileinfo/imap/phalcon/mongodb:"
-          echo -e "\t${CMSG}1${CEND}. fileinfo"
-          echo -e "\t${CMSG}2${CEND}. imap"
-          echo -e "\t${CMSG}3${CEND}. phalcon"
-          echo -e "\t${CMSG}4${CEND}. mongodb"
-          read -e -p "Please input a number:(Default 1 press Enter) " phpext_option
-          phpext_option=${phpext_option:-1}
-          if [[ ! "${phpext_option}" =~ ^[1-4]$ ]]; then
-            echo "${CWARNING}input error! Please only input number 1~4${CEND}"
-          else
-            if [ "${phpext_option}" = '1' ]; then
-              PHP_extension=fileinfo
-            elif [ "${phpext_option}" = '2' ]; then
-              PHP_extension=imap
-              IMAP_ARGS='--with-kerberos --with-imap --with-imap-ssl'
-              if [ "${PM}" == 'yum' ]; then
-                yum -y install libc-client-devel
-                [ "${OS_BIT}" == '64' -a ! -e /usr/lib/libc-client.so ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so
-              else
-                apt-get -y install libc-client2007e-dev
-              fi
-            elif [ "${phpext_option}" = '3' ]; then
-              PHP_extension=phalcon
-            elif [ "${phpext_option}" = '4' ]; then
-              if [[ "${PHP_main_ver}" =~ ^5.[3-4]$ ]]; then
-                PHP_extension=mongo
-              else
-                PHP_extension=mongodb
-              fi
-            fi
-            break
+          ;;
+        5)
+          ACTION_FUN
+          if [ "${install_yn}" = 'y' ]; then
+            Install_Python
+            Install_Panel
+          elif [ "${uninstall_yn}" = 'y' ]; then
+            Uninstall_Panel
           fi
-        done
+          ;;
+        q)
+          exit
+          ;;
+      esac
+    fi
+  done
+}
 
-        if [ "${ACTION}" = '1' ]; then
-          Check_PHP_Extension
-          pushd ${oneinstack_dir}/src > /dev/null
-          if [[ "${phpext_option}" =~ ^[1-2]$ ]]; then
-            src_url=http://www.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src
-            tar xzf php-${PHP_detail_ver}.tar.gz
-            pushd php-${PHP_detail_ver}/ext/${PHP_extension}
-            ${php_install_dir}/bin/phpize
-            ./configure --with-php-config=${php_install_dir}/bin/php-config ${IMAP_ARGS}
-            make -j ${THREAD} && make install
-            [ -f "${phpExtensionDir}/${PHP_extension}.so" ] && echo "extension=${PHP_extension}.so" > ${php_install_dir}/etc/php.d/04-${PHP_extension}.ini
-            popd > /dev/null
-            rm -rf php-${PHP_detail_ver}
-          elif [ "${phpext_option}" = '3' ]; then
-            if [[ "${PHP_main_ver}" =~ ^5.[5-6]$|^7.[0-2]$ ]]; then
-              src_url=http://mirrors.linuxeye.com/oneinstack/src/cphalcon-${phalcon_ver}.tar.gz && Download_src
-              tar xzf cphalcon-${phalcon_ver}.tar.gz
-              pushd cphalcon-${phalcon_ver}/build
-              ./install --phpize ${php_install_dir}/bin/phpize --php-config ${php_install_dir}/bin/php-config --arch ${OS_BIT}bits
-              [ -f "${phpExtensionDir}/${PHP_extension}.so" ] && echo "extension=${PHP_extension}.so" > ${php_install_dir}/etc/php.d/04-${PHP_extension}.ini
-              popd > /dev/null
-              rm -rf cphalcon-${phalcon_ver}
-            else
-              echo; echo "${CWARNING}Your php ${PHP_detail_ver} does not support ${PHP_extension}! ${CEND}";
-            fi
-          elif [ "${phpext_option}" = '4' ]; then
-            if [ "${PHP_extension}" == 'mongo' ]; then
-              echo "Download pecl mongo for php..."
-              src_url=https://pecl.php.net/get/mongo-${pecl_mongo_ver}.tgz && Download_src
-            elif [ "${PHP_extension}" == 'mongo' ]; then
-              echo "Download pecl mongodb for php..."
-              src_url=https://pecl.php.net/get/mongodb-${pecl_mongodb_ver}.tgz && Download_src
-            fi
-            Install_pecl-mongodb
-          fi
-          popd > /dev/null
-          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 -e -p "Please input a number:(Default 1 press Enter) " Memcache
-          Memcache=${Memcache:-1}
-          if [[ ! "${Memcache}" =~ ^[1-3]$ ]]; then
-            echo "${CWARNING}input error! Please only input number 1~3${CEND}"
-          else
-            [ "${Memcache}" = '1' ] && PHP_extension=memcache
-            [ "${Memcache}" = '2' ] && PHP_extension=memcached
-            break
-          fi
-        done
-        if [ "${ACTION}" = '1' ]; then
-          memcached_yn=y && checkDownload
-          case "${Memcache}" in
-            1)
-              [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached
-              Check_PHP_Extension
-              Install_pecl-memcache
-              Check_succ
-              ;;
-            2)
-              [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached
-              Check_PHP_Extension
-              Install_pecl-memcached
-              Check_succ
-              ;;
-            3)
-              [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached
-              PHP_extension=memcache && Check_PHP_Extension
-              Install_pecl-memcache
-              PHP_extension=memcached && Check_PHP_Extension
-              Install_pecl-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
-        ;;
-      6)
-        ACTION_FUN
-        PHP_extension=redis
-        redis_yn=y && checkDownload
-        if [ "${ACTION}" = '1' ]; then
-          [ ! -d "${redis_install_dir}" ] && Install_redis-server
-          Check_PHP_Extension
-          Install_pecl-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
-        PHP_extension=swoole
-        if [ "${ACTION}" = '1' ]; then
-          Check_PHP_Extension
-          pushd ${oneinstack_dir}/src > /dev/null
-          if [[ "${PHP_main_ver}" =~ ^5\.[3-6]$ ]]; then
-            src_url=https://pecl.php.net/get/swoole-1.10.5.tgz && Download_src
-            tar xzf swoole-1.10.5.tgz
-            pushd swoole-1.10.5
-          else
-            src_url=https://pecl.php.net/get/swoole-${swoole_ver}.tgz && Download_src
-            tar xzf swoole-${swoole_ver}.tgz
-            pushd swoole-${swoole_ver}
-          fi
-          ${php_install_dir}/bin/phpize
-          ./configure --with-php-config=${php_install_dir}/bin/php-config --enable-openssl --with-openssl-dir=${openssl_install_dir}
-          make -j ${THREAD} && make install
-          popd > /dev/null
-          rm -rf swoole-${swoole_ver}
-          popd > /dev/null
-          echo 'extension=swoole.so' > ${php_install_dir}/etc/php.d/06-swoole.ini
-          Check_succ
-        else
-          Uninstall_succ
-        fi
-        ;;
-      8)
-        ACTION_FUN
-        PHP_extension=xdebug
-        if [ "${ACTION}" = '1' ]; then
-          Check_PHP_Extension
-          pushd ${oneinstack_dir}/src > /dev/null
-          if [[ "${PHP_main_ver}" =~ ^7\.[0-3]$ ]]; then
-            src_url=https://pecl.php.net/get/xdebug-${xdebug_ver}.tgz && Download_src
-            src_url=http://mirrors.linuxeye.com/oneinstack/src/webgrind-master.zip && Download_src
-            tar xzf xdebug-${xdebug_ver}.tgz
-            unzip -q webgrind-master.zip
-            /bin/mv webgrind-master ${wwwroot_dir}/default/webgrind
-            pushd xdebug-${xdebug_ver}
-          elif [[ "${PHP_main_ver}" =~ ^5\.[5-6]$ ]]; then
-            src_url=https://pecl.php.net/get/xdebug-2.5.5.tgz && Download_src
-            src_url=http://mirrors.linuxeye.com/oneinstack/src/webgrind-master.zip && Download_src
-            tar xzf xdebug-2.5.5.tgz
-            unzip -q webgrind-master.zip
-            /bin/mv webgrind-master ${wwwroot_dir}/default/webgrind
-            pushd xdebug-2.5.5
-          else
-            echo "${CWARNING}Need a PHP version >= 5.5.0 and <= 7.2.0${CEND}"
-            exit 1
-          fi
-          ${php_install_dir}/bin/phpize
-          ./configure --with-php-config=${php_install_dir}/bin/php-config
-          make -j ${THREAD} && make install
-          popd > /dev/null
-          rm -rf xdebug-${xdebug_ver}
-          popd > /dev/null
-          [ ! -e /tmp/xdebug ] && { mkdir /tmp/xdebug; chown ${run_user}.${run_user} /tmp/xdebug; }
-          [ ! -e /tmp/webgrind ] && { mkdir /tmp/webgrind; chown ${run_user}.${run_user} /tmp/webgrind; }
-          chown -R ${run_user}.${run_user} ${wwwroot_dir}/default/webgrind
-          sed -i 's@static $storageDir.*@static $storageDir = "/tmp/webgrind";@' ${wwwroot_dir}/default/webgrind/config.php
-          sed -i 's@static $profilerDir.*@static $profilerDir = "/tmp/xdebug";@' ${wwwroot_dir}/default/webgrind/config.php
-          cat > ${php_install_dir}/etc/php.d/08-xdebug.ini << EOF
-[xdebug]
-zend_extension=xdebug.so
-xdebug.trace_output_dir=/tmp/xdebug
-xdebug.profiler_output_dir = /tmp/xdebug
-xdebug.profiler_enable = On
-xdebug.profiler_enable_trigger = 1
-EOF
-          Check_succ
-          echo; echo "Webgrind URL: ${CMSG}http://{Public IP}/webgrind ${CEND}"
-        else
-          rm -rf /tmp/{xdebug,webgrind} ${wwwroot_dir}/default/webgrind
-          Uninstall_succ
-        fi
-        ;;
-      9)
-        ACTION_FUN
-        if [ "${ACTION}" = '1' ]; then
-          [ -e "/usr/local/bin/composer" ] && { echo "${CWARNING}PHP Composer already installed! ${CEND}"; exit 1; }
-          if [ "$IPADDR_COUNTRY"x == "CN"x ]; then
-            wget -c https://dl.laravel-china.org/composer.phar -O /usr/local/bin/composer > /dev/null 2>&1
-            ${php_install_dir}/bin/php /usr/local/bin/composer config -g repo.packagist composer https://packagist.phpcomposer.com
-          else
-            wget -c https://getcomposer.org/composer.phar -O /usr/local/bin/composer > /dev/null 2>&1
-          fi
-          chmod +x /usr/local/bin/composer
-          if [ -e "/usr/local/bin/composer" ]; then
-            echo; echo "${CSUCCESS}Composer installed successfully! ${CEND}"
-          else
-            echo; echo "${CFAILURE}Composer install failed, Please try again! ${CEND}"
-          fi
-        else
-          rm -rf /usr/local/bin/composer
-          echo; echo "${CMSG}composer uninstall completed${CEND}";
-        fi
-        ;;
-      10)
-        ACTION_FUN
-        if [ "${ACTION}" = '1' ]; then
-          Install_fail2ban
-        else
-          Uninstall_fail2ban
-        fi
-        ;;
-      11)
-        ACTION_FUN
-        if [ "${ACTION}" = '1' ]; then
-          [ -e "${nginx_install_dir}/sbin/nginx" ] && Nginx_lua_waf
-          [ -e "${tengine_install_dir}/sbin/nginx" ] && Tengine_lua_waf
-          enable_lua_waf
-        else
-          disable_lua_waf
-        fi
-        ;;
-      12)
-        ACTION_FUN
-        if [ "${ACTION}" = '1' ]; then
-          [ ! -e "${python_install_dir}/bin/python" ] && Install_Python
-          Install_Panel
-        else
-          Uninstall_Panel
-        fi
-        ;;
-      q)
-        exit
-        ;;
-    esac
+if [ ${ARG_NUM} == 0 ]; then
+  Menu
+else
+  if [ "${composer_yn}" == 'y' ]; then
+    if [ "${install_yn}" = 'y' ]; then
+      Install_composer
+    elif [ "${uninstall_yn}" = 'y' ]; then
+      Uninstall_composer
+    fi
   fi
-done
+  if [ "${fail2ban_yn}" == 'y' ]; then
+    if [ "${install_yn}" = 'y' ]; then
+      Install_fail2ban
+    elif [ "${uninstall_yn}" = 'y' ]; then
+      Uninstall_fail2ban
+    fi
+  fi
+  if [ "${ngx_lua_waf_yn}" == 'y' ]; then
+    if [ "${install_yn}" = 'y' ]; then
+      [ -e "${nginx_install_dir}/sbin/nginx" ] && Nginx_lua_waf
+      [ -e "${tengine_install_dir}/sbin/nginx" ] && Tengine_lua_waf
+      enable_lua_waf
+    elif [ "${uninstall_yn}" = 'y' ]; then
+      disable_lua_waf
+    fi
+  fi
+  if [ "${python_yn}" == 'y' ]; then
+    if [ "${install_yn}" = 'y' ]; then
+      Install_Python
+    elif [ "${uninstall_yn}" = 'y' ]; then
+      Uninstall_Python
+    fi
+  fi
+  if [ "${panel_yn}" == 'y' ]; then
+    if [ "${install_yn}" = 'y' ]; then
+      Install_Python
+      Install_Panel
+    elif [ "${uninstall_yn}" = 'y' ]; then
+      Uninstall_Panel
+    fi
+  fi
+fi

+ 21 - 14
backup_setup.sh

@@ -38,23 +38,30 @@ while :; do echo
   echo -e "\t${CMSG}4${CEND}. Qcloud COS"
   echo -e "\t${CMSG}5${CEND}. UPYUN"
   echo -e "\t${CMSG}6${CEND}. QINIU"
-  read -e -p "Please input a number:(Default 1 press Enter) " desc_bk
-  desc_bk=${desc_bk:-1}
-  ary=(1 2 3 4 5 6 12 13 14 15 16 23 24 25 26 34 35 36 45 46 56 123 124 125 126 134 135 136 145 146 156 234 235 236 245 246 256 345 346 456 1234 1235 1236 2345 2346 3456 12345 12346 13456 23456 123456)
-  if [[ "${ary[@]}" =~ "${desc_bk}" ]]; then
-    break
+  read -e -p "Please input numbers:(Default 1 press Enter) " desc_bk
+  desc_bk=${desc_bk:-'1'}
+  array_desc=(${desc_bk})
+  array_all=(1 2 3 4 5 6)
+  for v in ${array_desc[@]}
+  do
+    [ -z "`echo ${array_all[@]} | grep -w ${v}`" ] && desc_flag=1
+  done
+  if [ "${desc_flag}" == '1' ]; then
+    unset desc_flag
+    echo; echo "${CWARNING}input error! Please only input number 1 3 4 and so on${CEND}"; echo
+    continue
   else
-    echo "${CWARNING}input error! Please only input number 1,2,12,23,234 and so on${CEND}"
+    break
   fi
 done
 
 sed -i 's@^backup_destination=.*@backup_destination=@' ./options.conf
-[ `echo ${desc_bk} | grep -e 1` ] && sed -i 's@^backup_destination=.*@backup_destination=local@' ./options.conf
-[ `echo ${desc_bk} | grep -e 2` ] && sed -i 's@^backup_destination=.*@&,remote@' ./options.conf
-[ `echo ${desc_bk} | grep -e 3` ] && sed -i 's@^backup_destination=.*@&,oss@' ./options.conf
-[ `echo ${desc_bk} | grep -e 4` ] && sed -i 's@^backup_destination=.*@&,cos@' ./options.conf
-[ `echo ${desc_bk} | grep -e 5` ] && sed -i 's@^backup_destination=.*@&,upyun@' ./options.conf
-[ `echo ${desc_bk} | grep -e 6` ] && sed -i 's@^backup_destination=.*@&,qiniu@' ./options.conf
+[ `echo ${desc_bk} | grep -w 1` ] && sed -i 's@^backup_destination=.*@backup_destination=local@' ./options.conf
+[ `echo ${desc_bk} | grep -w 2` ] && sed -i 's@^backup_destination=.*@&,remote@' ./options.conf
+[ `echo ${desc_bk} | grep -w 3` ] && sed -i 's@^backup_destination=.*@&,oss@' ./options.conf
+[ `echo ${desc_bk} | grep -w 4` ] && sed -i 's@^backup_destination=.*@&,cos@' ./options.conf
+[ `echo ${desc_bk} | grep -w 5` ] && sed -i 's@^backup_destination=.*@&,upyun@' ./options.conf
+[ `echo ${desc_bk} | grep -w 6` ] && sed -i 's@^backup_destination=.*@&,qiniu@' ./options.conf
 sed -i 's@^backup_destination=,@backup_destination=@' ./options.conf
 
 while :; do echo
@@ -233,7 +240,7 @@ if [ `echo ${desc_bk} | grep -e 3` ]; then
 fi
 
 if [ `echo ${desc_bk} | grep -e 4` ]; then
-  [ ! -e "${python_install_dir}/bin/python" ] && Install_Python
+  Install_Python
   [ ! -e "${python_install_dir}/lib/coscmd" ] && ${python_install_dir}/bin/pip install coscmd >/dev/null 2>&1
   while :; do echo
     echo 'Please select your backup qcloud datacenter:'
@@ -282,7 +289,7 @@ if [ `echo ${desc_bk} | grep -e 4` ]; then
     [ -z "${SECRET_KEY}" ] && continue
     echo
     read -e -p "Please enter the Qcloud COS BUCKET: " BUCKET
-    if [[ ${BUCKET} =~ "-${APPID}"$ ]]; then 
+    if [[ ${BUCKET} =~ "-${APPID}"$ ]]; then
       Bucket=${BUCKET}
     else
       [ -z "${BUCKET}" ] && continue

+ 36 - 16
include/GraphicsMagick.sh

@@ -9,39 +9,59 @@
 #       https://github.com/oneinstack/oneinstack
 
 Install_GraphicsMagick() {
-  pushd ${oneinstack_dir}/src > /dev/null
-  tar xzf GraphicsMagick-${graphicsmagick_ver}.tar.gz
-  pushd GraphicsMagick-${graphicsmagick_ver}
-  ./configure --prefix=${gmagick_install_dir} --enable-shared --enable-static
-  make -j ${THREAD} && make install
-  popd
-  rm -rf GraphicsMagick-${graphicsmagick_ver}
-  popd
+  if [ -d "${gmagick_install_dir}" ]; then
+    echo "${CWARNING}GraphicsMagick already installed! ${CEND}"
+  else
+    pushd ${oneinstack_dir}/src > /dev/null
+    tar xzf GraphicsMagick-${graphicsmagick_ver}.tar.gz
+    pushd GraphicsMagick-${graphicsmagick_ver} > /dev/null
+    ./configure --prefix=${gmagick_install_dir} --enable-shared --enable-static
+    make -j ${THREAD} && make install
+    popd > /dev/null
+    rm -rf GraphicsMagick-${graphicsmagick_ver}
+    popd > /dev/null
+  fi
+}
+
+Uninstall_GraphicsMagick() {
+  if [ -d "${gmagick_install_dir}" ]; then
+    rm -rf ${gmagick_install_dir}
+    echo; echo "${CMSG}GraphicsMagick uninstall completed${CEND}"
+  fi
 }
 
 Install_pecl-gmagick() {
-  pushd ${oneinstack_dir}/src > /dev/null
   if [ -e "${php_install_dir}/bin/phpize" ]; then
+    pushd ${oneinstack_dir}/src > /dev/null
     phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
     if [ "`${php_install_dir}/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}'`" == '7' ]; then
-      tar xzf gmagick-${gmagick_for_php7_ver}.tgz
-      pushd gmagick-${gmagick_for_php7_ver}
-    else
       tar xzf gmagick-${gmagick_ver}.tgz
-      pushd gmagick-${gmagick_ver}
+      pushd gmagick-${gmagick_ver} > /dev/null
+    else
+      tar xzf gmagick-${gmagick_oldver}.tgz
+      pushd gmagick-${gmagick_oldver} > /dev/null
     fi
     export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
     ${php_install_dir}/bin/phpize
     ./configure --with-php-config=${php_install_dir}/bin/php-config --with-gmagick=${gmagick_install_dir}
     make -j ${THREAD} && make install
-    popd
+    popd > /dev/null
     if [ -f "${phpExtensionDir}/gmagick.so" ]; then
       echo 'extension=gmagick.so' > ${php_install_dir}/etc/php.d/03-gmagick.ini
       echo "${CSUCCESS}PHP gmagick module installed successfully! ${CEND}"
-      rm -rf gmagick-${gmagick_for_php7_ver} gmagick-${gmagick_ver}
+      rm -rf gmagick-${gmagick_ver} gmagick-${gmagick_oldver}
     else
       echo "${CFAILURE}PHP gmagick module install failed, Please contact the author! ${CEND}"
     fi
+    popd > /dev/null
+  fi
+}
+
+Uninstall_pecl-gmagick() {
+  if [ -e "${php_install_dir}/etc/php.d/03-gmagick.ini" ]; then
+    rm -f ${php_install_dir}/etc/php.d/03-gmagick.ini
+    echo; echo "${CMSG}PHP gmagick module uninstall completed${CEND}"
+  else
+    echo; echo "${CWARNING}PHP gmagick module does not exist! ${CEND}"
   fi
-  popd
 }

+ 32 - 12
include/ImageMagick.sh

@@ -9,27 +9,38 @@
 #       https://github.com/oneinstack/oneinstack
 
 Install_ImageMagick() {
-  pushd ${oneinstack_dir}/src > /dev/null
-  tar xzf ImageMagick-${imagemagick_ver}.tar.gz
-  pushd ImageMagick-${imagemagick_ver}
-  ./configure --prefix=${imagick_install_dir} --enable-shared --enable-static
-  make -j ${THREAD} && make install
-  popd
-  rm -rf ImageMagick-${imagemagick_ver}
-  popd
+  if [ -d "${imagick_install_dir}" ]; then
+    echo "${CWARNING}ImageMagick already installed! ${CEND}"
+  else
+    pushd ${oneinstack_dir}/src > /dev/null
+    tar xzf ImageMagick-${imagemagick_ver}.tar.gz
+    pushd ImageMagick-${imagemagick_ver} > /dev/null
+    ./configure --prefix=${imagick_install_dir} --enable-shared --enable-static
+    make -j ${THREAD} && make install
+    popd > /dev/null
+    rm -rf ImageMagick-${imagemagick_ver}
+    popd > /dev/null
+  fi
+}
+
+Uninstall_ImageMagick() {
+  if [ -d "${imagick_install_dir}" ]; then
+    rm -rf ${imagick_install_dir} 
+    echo; echo "${CMSG}ImageMagick uninstall completed${CEND}"
+  fi
 }
 
 Install_pecl-imagick() {
-  pushd ${oneinstack_dir}/src > /dev/null
   if [ -e "${php_install_dir}/bin/phpize" ]; then
+    pushd ${oneinstack_dir}/src > /dev/null
     phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
     tar xzf imagick-${imagick_ver}.tgz
-    pushd imagick-${imagick_ver}
+    pushd imagick-${imagick_ver} > /dev/null
     export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
     ${php_install_dir}/bin/phpize
     ./configure --with-php-config=${php_install_dir}/bin/php-config --with-imagick=${imagick_install_dir}
     make -j ${THREAD} && make install
-    popd
+    popd > /dev/null
     if [ -f "${phpExtensionDir}/imagick.so" ]; then
       echo 'extension=imagick.so' > ${php_install_dir}/etc/php.d/03-imagick.ini
       echo "${CSUCCESS}PHP imagick module installed successfully! ${CEND}"
@@ -37,6 +48,15 @@ Install_pecl-imagick() {
     else
       echo "${CFAILURE}PHP imagick module install failed, Please contact the author! ${CEND}"
     fi
+    popd > /dev/null
+  fi
+}
+
+Uninstall_pecl-imagick() {
+  if [ -e "${php_install_dir}/etc/php.d/03-imagick.ini" ]; then
+    rm -f ${php_install_dir}/etc/php.d/03-imagick.ini
+    echo; echo "${CMSG}PHP imagick module uninstall completed${CEND}"
+  else
+    echo; echo "${CWARNING}PHP imagick module does not exist! ${CEND}"
   fi
-  popd
 }

+ 47 - 36
include/ZendGuardLoader.sh

@@ -9,50 +9,61 @@
 #       https://github.com/oneinstack/oneinstack
 
 Install_ZendGuardLoader() {
-  pushd ${oneinstack_dir}/src > /dev/null
-  PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
-  PHP_main_ver=${PHP_detail_ver%.*}
-  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
-  [ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir}
-  if [ -n "`echo $phpExtensionDir | grep 'non-zts'`" ]; then
-    case "${PHP_main_ver}" in
-      5.6)
-        tar xzf zend-loader-php5.6-linux-${SYS_BIT_c}.tar.gz
-        /bin/cp zend-loader-php5.6-linux-${SYS_BIT_c}/ZendGuardLoader.so ${phpExtensionDir}
-        rm -rf zend-loader-php5.6-linux-${SYS_BIT_c}
-        ;;
-      5.5)
-        tar xzf zend-loader-php5.5-linux-${SYS_BIT_c}.tar.gz
-        /bin/cp zend-loader-php5.5-linux-${SYS_BIT_c}/ZendGuardLoader.so ${phpExtensionDir}
-        rm -rf zend-loader-php5.5-linux-${SYS_BIT_c}
-        ;;
-      5.4)
-        tar xzf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-${SYS_BIT_c}.tar.gz
-        /bin/cp ZendGuardLoader-70429-PHP-5.4-linux-glibc23-${SYS_BIT_c}/php-5.4.x/ZendGuardLoader.so ${phpExtensionDir}
-        rm -rf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-${SYS_BIT_c}
-        ;;
-      5.3)
-        tar xzf ZendGuardLoader-php-5.3-linux-glibc23-${SYS_BIT_c}.tar.gz
-        /bin/cp ZendGuardLoader-php-5.3-linux-glibc23-${SYS_BIT_c}/php-5.3.x/ZendGuardLoader.so ${phpExtensionDir}
-        rm -rf ZendGuardLoader-php-5.3-linux-glibc23-${SYS_BIT_c}
-        ;;
-      *)
-        echo "Error! Your PHP ${PHP_detail_ver} does not support ZendGuardLoader!"
-        ;;
-    esac
+  if [ -e "${php_install_dir}/bin/phpize" ]; then
+    pushd ${oneinstack_dir}/src > /dev/null
+    PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
+    PHP_main_ver=${PHP_detail_ver%.*}
+    phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
+    [ -e "${php_install_dir}/bin/phpize" ] && [ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir}
+    if [ -n "`echo $phpExtensionDir | grep 'non-zts'`" ] && [ "${armplatform}" != 'y' ]; then
+      case "${PHP_main_ver}" in
+        5.6)
+          tar xzf zend-loader-php5.6-linux-${SYS_BIT_c}.tar.gz
+          /bin/mv zend-loader-php5.6-linux-${SYS_BIT_c}/ZendGuardLoader.so ${phpExtensionDir}
+          rm -rf zend-loader-php5.6-linux-${SYS_BIT_c}
+          ;;
+        5.5)
+          tar xzf zend-loader-php5.5-linux-${SYS_BIT_c}.tar.gz
+          /bin/mv zend-loader-php5.5-linux-${SYS_BIT_c}/ZendGuardLoader.so ${phpExtensionDir}
+          rm -rf zend-loader-php5.5-linux-${SYS_BIT_c}
+          ;;
+        5.4)
+          tar xzf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-${SYS_BIT_c}.tar.gz
+          /bin/mv ZendGuardLoader-70429-PHP-5.4-linux-glibc23-${SYS_BIT_c}/php-5.4.x/ZendGuardLoader.so ${phpExtensionDir}
+          rm -rf ZendGuardLoader-70429-PHP-5.4-linux-glibc23-${SYS_BIT_c}
+          ;;
+        5.3)
+          tar xzf ZendGuardLoader-php-5.3-linux-glibc23-${SYS_BIT_c}.tar.gz
+          /bin/mv ZendGuardLoader-php-5.3-linux-glibc23-${SYS_BIT_c}/php-5.3.x/ZendGuardLoader.so ${phpExtensionDir}
+          rm -rf ZendGuardLoader-php-5.3-linux-glibc23-${SYS_BIT_c}
+          ;;
+        *)
+          echo "${CWARNING}Your php ${PHP_detail_ver} does not support ZendGuardLoader! ${CEND}";
+          ;;
+      esac
 
-    if [ -f "${phpExtensionDir}/ZendGuardLoader.so" ]; then
-      cat > ${php_install_dir}/etc/php.d/01-ZendGuardLoader.ini<< EOF
+      if [ -f "${phpExtensionDir}/ZendGuardLoader.so" ]; then
+        cat > ${php_install_dir}/etc/php.d/01-ZendGuardLoader.ini<< EOF
 [Zend Guard Loader]
 zend_extension=${phpExtensionDir}/ZendGuardLoader.so
 zend_loader.enable=1
 zend_loader.disable_licensing=0
 zend_loader.obfuscation_level_support=3
 EOF
-      echo "${CSUCCESS}PHP ZendGuardLoader module installed successfully! ${CEND}"
+        echo "${CSUCCESS}PHP ZendGuardLoader module installed successfully! ${CEND}"
+      fi
+    else
+      echo "Error! Your Apache's prefork or PHP already enable thread safety! "
     fi
+    popd > /dev/null
+  fi
+}
+
+Uninstall_ZendGuardLoader() {
+  if [ -e "${php_install_dir}/etc/php.d/01-ZendGuardLoader.ini" ]; then
+    rm -f ${php_install_dir}/etc/php.d/01-ZendGuardLoader.ini
+    echo; echo "${CMSG}PHP ZendGuardLoader module uninstall completed${CEND}"
   else
-    echo "Error! Your Apache's prefork or PHP already enable thread safety! "
+    echo; echo "${CWARNING}PHP ZendGuardLoader module does not exist! ${CEND}"
   fi
-  popd
 }

+ 4 - 4
include/apache-2.2.sh

@@ -13,15 +13,15 @@ Install_Apache22() {
   id -u ${run_user} >/dev/null 2>&1
   [ $? -ne 0 ] && useradd -M -s /sbin/nologin ${run_user}
   tar xzf httpd-${apache22_ver}.tar.gz
-  pushd httpd-${apache22_ver}
+  pushd httpd-${apache22_ver} > /dev/null
   [ ! -d "${apache_install_dir}" ] && mkdir -p ${apache_install_dir}
   [ "${Ubuntu_ver}" == "12" ] && sed -i '@SSL_PROTOCOL_SSLV2@d' modules/ssl/ssl_engine_io.c
   LDFLAGS=-ldl ./configure --prefix=${apache_install_dir} --with-mpm=prefork --enable-mpms-shared=all --with-included-apr --enable-headers --enable-mime-magic --enable-deflate --enable-proxy --enable-so --enable-dav --enable-rewrite --enable-expires --enable-static-support --enable-suexec --with-expat=builtin --enable-mods-shared=most --enable-ssl --with-ssl=${openssl_install_dir}
   make -j ${THREAD} && make install
   unset LDFLAGS
-  if [ -e "${apache_install_dir}/conf/httpd.conf" ]; then
+  if [ -e "${apache_install_dir}/bin/httpd" ]; then
     echo "${CSUCCESS}Apache installed successfully! ${CEND}"
-    popd
+    popd > /dev/null
     rm -rf httpd-${apache22_ver}
   else
     rm -rf ${apache_install_dir}
@@ -133,5 +133,5 @@ EOF
   fi
   ldconfig
   service httpd start
-  popd
+  popd > /dev/null
 }

+ 1 - 1
include/apache-2.4.sh

@@ -41,7 +41,7 @@ Install_Apache24() {
   make -j ${THREAD} && make install
   popd > /dev/null
   unset LDFLAGS
-  if [ -e "${apache_install_dir}/conf/httpd.conf" ]; then
+  if [ -e "${apache_install_dir}/bin/httpd" ]; then
     echo "${CSUCCESS}Apache installed successfully! ${CEND}"
     rm -rf httpd-${apache24_ver} pcre-${pcre_ver} apr-${apr_ver} apr-util-${apr_util_ver}
   else

+ 31 - 21
include/apcu.sh

@@ -9,21 +9,21 @@
 #       https://github.com/oneinstack/oneinstack
 
 Install_APCU() {
-  pushd ${oneinstack_dir}/src > /dev/null
-  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
-  if [ "`${php_install_dir}/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}'`" == '7' ]; then
-    tar xzf apcu-${apcu_for_php7_ver}.tgz
-    pushd apcu-${apcu_for_php7_ver}
-  else
-    tar xzf apcu-${apcu_ver}.tgz
-    pushd apcu-${apcu_ver}
-  fi
-
-  ${php_install_dir}/bin/phpize
-  ./configure --with-php-config=${php_install_dir}/bin/php-config
-  make -j ${THREAD} && make install
-  if [ -f "${phpExtensionDir}/apcu.so" ]; then
-    cat > ${php_install_dir}/etc/php.d/02-apcu.ini << EOF
+  if [ -e "${php_install_dir}/bin/phpize" ]; then
+    pushd ${oneinstack_dir}/src > /dev/null
+    phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
+    if [ "`${php_install_dir}/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}'`" == '7' ]; then
+      tar xzf apcu-${apcu_ver}.tgz
+      pushd apcu-${apcu_ver} > /dev/null
+    else
+      tar xzf apcu-${apcu_oldver}.tgz
+      pushd apcu-${apcu_oldver} > /dev/null
+    fi
+    ${php_install_dir}/bin/phpize
+    ./configure --with-php-config=${php_install_dir}/bin/php-config
+    make -j ${THREAD} && make install
+    if [ -f "${phpExtensionDir}/apcu.so" ]; then
+      cat > ${php_install_dir}/etc/php.d/02-apcu.ini << EOF
 [apcu]
 extension=apcu.so
 apc.enabled=1
@@ -31,12 +31,22 @@ apc.shm_size=32M
 apc.ttl=7200
 apc.enable_cli=1
 EOF
-    /bin/cp apc.php ${wwwroot_dir}/default
-    echo "${CSUCCESS}APCU module installed successfully! ${CEND}"
-    popd
-    rm -rf apcu-${apcu_for_php7_ver} apcu-${apcu_ver} package.xml
+      /bin/cp apc.php ${wwwroot_dir}/default
+      popd > /dev/null
+      echo "${CSUCCESS}PHP apcu module installed successfully! ${CEND}"
+      rm -rf apcu-${apcu_ver} apcu-${apcu_oldver} package.xml
+    else
+      echo "${CFAILURE}PHP apcu module install failed, Please contact the author! ${CEND}"
+    fi
+    popd > /dev/null
+  fi
+}
+
+Uninstall_APCU() {
+  if [ -e "${php_install_dir}/etc/php.d/02-apcu.ini" ]; then
+    rm -rf ${php_install_dir}/etc/php.d/02-apcu.ini ${wwwroot_dir}/default/apc.php
+    echo; echo "${CMSG}PHP apcu module uninstall completed${CEND}"
   else
-    echo "${CFAILURE}APCU module install failed, Please contact the author! ${CEND}"
+    echo; echo "${CWARNING}PHP apcu module does not exist! ${CEND}"
   fi
-  popd
 }

+ 50 - 31
include/check_download.sh

@@ -11,10 +11,12 @@ checkDownload() {
   mirrorLink=http://mirrors.linuxeye.com/oneinstack/src
   pushd ${oneinstack_dir}/src > /dev/null
   # General system utils
-  echo "Download openSSL..."
-  src_url=https://www.openssl.org/source/openssl-${openssl_ver}.tar.gz && Download_src
-  echo "Download cacert.pem..."
-  src_url=https://curl.haxx.se/ca/cacert.pem && Download_src
+  if [[ ${tomcat_option} =~ ^[1-4]$ ]] || [[ ${apache_option} =~ ^[1-2]$ ]] || [[ ${php_option} =~ ^[1-8]$ ]]; then
+    echo "Download openSSL..."
+    src_url=https://www.openssl.org/source/openssl-${openssl_ver}.tar.gz && Download_src
+    echo "Download cacert.pem..."
+    src_url=https://curl.haxx.se/ca/cacert.pem && Download_src
+  fi
 
   # jemalloc
   if [[ ${nginx_option} =~ ^[1-3]$ ]] || [ "${db_yn}" == 'y' ]; then
@@ -685,9 +687,9 @@ checkDownload() {
       # php 5.3 5.4 5.5 5.6 7.0 7.1 7.2
       echo "Download apcu..."
       if [[ "${php_option}" =~ ^[1-4]$ ]]; then
-        src_url=https://pecl.php.net/get/apcu-${apcu_ver}.tgz && Download_src
+        src_url=https://pecl.php.net/get/apcu-${apcu_oldver}.tgz && Download_src
       else
-        src_url=https://pecl.php.net/get/apcu-${apcu_for_php7_ver}.tgz && Download_src
+        src_url=https://pecl.php.net/get/apcu-${apcu_ver}.tgz && Download_src
       fi
       ;;
     4)
@@ -703,7 +705,7 @@ checkDownload() {
   esac
 
   # Zend Guard Loader
-  if [ "${zendguardloader_yn}" == 'y' -a "${armplatform}" != 'y' ]; then
+  if [ "${pecl_zendguardloader}" == '1' -a "${armplatform}" != 'y' ]; then
     case "${php_option}" in
       4)
         echo "Download zend loader for php 5.6..."
@@ -725,7 +727,7 @@ checkDownload() {
   fi
 
   # ioncube
-  if [ "${ioncube_yn}" == 'y' ]; then
+  if [ "${pecl_ioncube}" == '1' ]; then
     echo "Download ioncube..."
     if [ "${TARGET_ARCH}" == "armv7" ]; then
       src_url=https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_armv7l.tar.gz && Download_src
@@ -735,7 +737,7 @@ checkDownload() {
   fi
 
   # SourceGuardian
-  if [ "${sourceguardian_yn}" == 'y' ]; then
+  if [ "${pecl_sourceguardian}" == '1' ]; then
     echo "Download SourceGuardian..."
     if [ "${TARGET_ARCH}" == "armv8" ]; then
       src_url=https://www.sourceguardian.com/loaders/download/loaders.linux-aarch64.tar.gz && Download_src
@@ -744,60 +746,77 @@ checkDownload() {
     fi
   fi
 
-  # ImageMagick graphicsmagick
-  if [ "${magick_option}" == '1' ]; then
+  # imageMagick
+  if [ "${pecl_imagick}" == '1' ]; then
     echo "Download ImageMagick..."
     src_url=${mirrorLink}/ImageMagick-${imagemagick_ver}.tar.gz && Download_src
     echo "Download imagick..."
     src_url=https://pecl.php.net/get/imagick-${imagick_ver}.tgz && Download_src
-  elif [ "${magick_option}" == '2' ]; then
+  fi
+
+  # graphicsmagick
+  if [ "${pecl_gmagick}" == '1' ]; then
     echo "Download graphicsmagick..."
     src_url=http://downloads.sourceforge.net/project/graphicsmagick/graphicsmagick/${graphicsmagick_ver}/GraphicsMagick-${graphicsmagick_ver}.tar.gz && Download_src
     if [[ "${php_option}" =~ ^[1-4]$ ]]; then
       echo "Download gmagick for php..."
-      src_url=https://pecl.php.net/get/gmagick-${gmagick_ver}.tgz && Download_src
+      src_url=https://pecl.php.net/get/gmagick-${gmagick_oldver}.tgz && Download_src
     else
       echo "Download gmagick for php 7.x..."
-      src_url=https://pecl.php.net/get/gmagick-${gmagick_for_php7_ver}.tgz && Download_src
+      src_url=https://pecl.php.net/get/gmagick-${gmagick_ver}.tgz && Download_src
     fi
   fi
 
-  # redis-server pecl_redis
-  if [ "${redis_yn}" == 'y' -o "${pecl_redis}" == '1' ]; then
-    echo "Download redis..."
+  # redis-server
+  if [ "${redis_yn}" == 'y' ]; then
+    echo "Download redis-server..."
     src_url=http://download.redis.io/releases/redis-${redis_ver}.tar.gz && Download_src
-    echo "Download pecl_redis..."
-    src_url=https://pecl.php.net/get/redis-${pecl_redis_ver}.tgz && Download_src
     if [ "${PM}" == 'yum' ]; then
       echo "Download start-stop-daemon.c for CentOS..."
       src_url=${mirrorLink}/start-stop-daemon.c && Download_src
     fi
   fi
 
-  # memcached-server pecl_memcached pecl_memcache
-  if [ "${memcached_yn}" == 'y' -o "${pecl_memcached}" == '1' -o "${pecl_memcache}" == '1' ]; then
-    echo "Download memcached..."
-    [ "$IPADDR_COUNTRY"x == "CN"x ] && DOWN_ADDR=${mirrorLink} || DOWN_ADDR=http://www.memcached.org/files
+  # pecl_redis
+  if [ "${pecl_redis}" == '1' ]; then
+    echo "Download pecl_redis..."
+    src_url=https://pecl.php.net/get/redis-${pecl_redis_ver}.tgz && Download_src
+  fi
+
+  # memcached-server
+  if [ "${memcached_yn}" == 'y' ]; then
+    echo "Download memcached-server..."
+    [ "${IPADDR_COUNTRY}"x == "CN"x ] && DOWN_ADDR=${mirrorLink} || DOWN_ADDR=http://www.memcached.org/files
     src_url=${DOWN_ADDR}/memcached-${memcached_ver}.tar.gz && Download_src
+  fi
+
+  # pecl_memcached
+  if [ "${pecl_memcached}" == '1' ]; then
+    echo "Download libmemcached..."
+    src_url=https://launchpad.net/libmemcached/1.0/${libmemcached_ver}/+download/libmemcached-${libmemcached_ver}.tar.gz && Download_src
     if [[ "${php_option}" =~ ^[1-4]$ ]]; then
-      echo "Download pecl_memcache for php..."
-      src_url=https://pecl.php.net/get/memcache-${pecl_memcache_ver}.tgz && Download_src
       echo "Download pecl_memcached for php..."
+      src_url=https://pecl.php.net/get/memcached-${pecl_memcached_oldver}.tgz && Download_src
+    else
+      echo "Download pecl_memcached for php 7.x..."
       src_url=https://pecl.php.net/get/memcached-${pecl_memcached_ver}.tgz && Download_src
+    fi
+  fi
+
+  # memcached-server pecl_memcached pecl_memcache
+  if [ "${pecl_memcache}" == '1' ]; then
+    if [[ "${php_option}" =~ ^[1-4]$ ]]; then
+      echo "Download pecl_memcache for php..."
+      src_url=https://pecl.php.net/get/memcache-${pecl_memcache_ver}.tgz && Download_src
     else
       echo "Download pecl_memcache for php 7.x..."
       # src_url=https://codeload.github.com/websupport-sk/pecl-memcache/zip/php7 && Download_src
       src_url=${mirrorLink}/pecl-memcache-php7.tgz && Download_src
-      echo "Download pecl_memcached for php 7.x..."
-      src_url=https://pecl.php.net/get/memcached-${pecl_memcached_php7_ver}.tgz && Download_src
     fi
-
-    echo "Download libmemcached..."
-    src_url=https://launchpad.net/libmemcached/1.0/${libmemcached_ver}/+download/libmemcached-${libmemcached_ver}.tar.gz && Download_src
   fi
 
   # pecl_mongodb
-  if [ -e "${mongo_install_dir}/bin/mongo" -o "${db_option}" == '14' -o "${pecl_mongodb}" == '1' ]; then
+  if [ "${pecl_mongodb}" == '1' ]; then
     echo "Download pecl mongo for php..."
     src_url=https://pecl.php.net/get/mongo-${pecl_mongo_ver}.tgz && Download_src
     echo "Download pecl mongodb for php..."

+ 44 - 0
include/composer.sh

@@ -0,0 +1,44 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.cn
+#
+# Notes: OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+
+#
+# Project home page:
+#       https://oneinstack.com
+#       https://github.com/oneinstack/oneinstack
+
+Install_composer() {
+  if [ -e "${php_install_dir}/bin/phpize" ]; then
+    if [ -e "/usr/local/bin/composer" ]; then
+      echo "${CWARNING}PHP Composer already installed! ${CEND}"
+    else
+      pushd ${oneinstack_dir}/src > /dev/null
+      # get the IP information
+      PUBLIC_IPADDR=$(../include/get_public_ipaddr.py)
+      IPADDR_COUNTRY=$(../include/get_ipaddr_state.py ${PUBLIC_IPADDR})
+      if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
+        wget -c https://dl.laravel-china.org/composer.phar -O /usr/local/bin/composer > /dev/null 2>&1
+        ${php_install_dir}/bin/php /usr/local/bin/composer config -g repo.packagist composer https://packagist.phpcomposer.com
+      else
+        wget -c https://getcomposer.org/composer.phar -O /usr/local/bin/composer > /dev/null 2>&1
+      fi
+      chmod +x /usr/local/bin/composer
+      if [ -e "/usr/local/bin/composer" ]; then
+        echo; echo "${CSUCCESS}PHP Composer installed successfully! ${CEND}"
+      else
+        echo; echo "${CFAILURE}PHP Composer install failed, Please try again! ${CEND}"
+      fi
+      popd > /dev/null
+    fi
+  fi
+}
+
+Uninstall_composer() {
+  if [ -e "/usr/local/bin/composer" ]; then
+    rm -f /usr/local/bin/composer
+    echo; echo "${CMSG}Composer uninstall completed${CEND}";
+  else
+    echo; echo "${CWARNING}Composer does not exist! ${CEND}"
+  fi
+}

+ 40 - 31
include/eaccelerator.sh

@@ -9,31 +9,27 @@
 #       https://github.com/oneinstack/oneinstack
 
 Install_eAccelerator() {
-  pushd ${oneinstack_dir}/src > /dev/null
-  PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
-  PHP_main_ver=${PHP_detail_ver%.*}
-  phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
-  case "${PHP_main_ver}" in
-    5.3)
-      tar jxf eaccelerator-${eaccelerator_ver}.tar.bz2
-      pushd eaccelerator-${eaccelerator_ver}
-      ;;
-    5.4)
-      /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
-  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/02-eaccelerator.ini << EOF
+  if [ -e "${php_install_dir}/bin/phpize" ]; then
+    pushd ${oneinstack_dir}/src > /dev/null
+    PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
+    PHP_main_ver=${PHP_detail_ver%.*}
+    phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
+    if [[ "${PHP_main_ver}" =~ ^5.[3-4]$ ]]; then
+      if [ "${PHP_main_ver}" == '5.3' ]; then
+        tar jxf eaccelerator-${eaccelerator_ver}.tar.bz2
+        pushd eaccelerator-${eaccelerator_ver} > /dev/null
+      elif [ "${PHP_main_ver}" == '5.4' ]; then
+        /bin/mv master eaccelerator-eaccelerator-42067ac.tar.gz
+        tar xzf eaccelerator-eaccelerator-42067ac.tar.gz
+        pushd eaccelerator-eaccelerator-42067ac > /dev/null
+      fi
+      ${php_install_dir}/bin/phpize
+      ./configure --enable-eaccelerator=shared --with-php-config=${php_install_dir}/bin/php-config
+      make -j ${THREAD} && make install
+      popd > /dev/null
+      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/02-eaccelerator.ini << EOF
 [eaccelerator]
 zend_extension=${phpExtensionDir}/eaccelerator.so
 eaccelerator.shm_size=64
@@ -53,12 +49,25 @@ eaccelerator.keys=disk_only
 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
-    sysctl -p
-    rm -rf eaccelerator-${eaccelerator_ver} eaccelerator-eaccelerator-42067ac
+        [ -z "$(grep 'kernel.shmmax = 67108864' /etc/sysctl.conf)" ] && echo "kernel.shmmax = 67108864" >> /etc/sysctl.conf
+        sysctl -p
+        echo "${CSUCCESS}PHP eaccelerator module installed successfully! ${CEND}"
+        rm -rf eaccelerator-${eaccelerator_ver} eaccelerator-eaccelerator-42067ac
+      else
+        echo "${CFAILURE}PHP eaccelerator module install failed, Please contact the author! ${CEND}"
+      fi
+    else
+      echo; echo "${CWARNING}Your php ${PHP_detail_ver} does not support eAccelerator! ${CEND}";
+    fi
+    popd > /dev/null
+  fi
+}
+
+Uninstall_eAccelerator() {
+  if [ -e "${php_install_dir}/etc/php.d/02-eaccelerator.ini" ]; then
+    rm -rf ${php_install_dir}/etc/php.d/02-eaccelerator.ini /var/eaccelerator_cache
+    echo; echo "${CMSG}PHP eaccelerator module uninstall completed${CEND}"
   else
-    echo "${CFAILURE}Accelerator module install failed, Please contact the author! ${CEND}"
+    echo; echo "${CWARNING}PHP eaccelerator module does not exist! ${CEND}"
   fi
-  popd
 }

+ 78 - 0
include/fail2ban.sh

@@ -0,0 +1,78 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.cn
+#
+# Notes: OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+
+#
+# Project home page:
+#       https://oneinstack.com
+#       https://github.com/oneinstack/oneinstack
+
+Install_fail2ban() {
+  pushd ${oneinstack_dir}/src > /dev/null
+  src_url=http://mirrors.linuxeye.com/oneinstack/src/fail2ban-${fail2ban_ver}.tar.gz && Download_src
+  tar xzf fail2ban-${fail2ban_ver}.tar.gz
+  pushd fail2ban-${fail2ban_ver} > /dev/null
+  sed -i 's@for i in xrange(50)@for i in range(50)@' fail2ban/__init__.py
+  ${python_install_dir}/bin/python setup.py install
+  if [ -e /bin/systemctl ]; then
+    /bin/cp build/fail2ban.service /lib/systemd/system/
+    systemctl enable fail2ban
+  else
+    if [ "${PM}" == 'yum' ]; then
+      /bin/cp files/redhat-initd /etc/init.d/fail2ban
+      sed -i "s@^FAIL2BAN=.*@FAIL2BAN=${python_install_dir}/bin/fail2ban-client@" /etc/init.d/fail2ban
+      sed -i 's@Starting fail2ban.*@&\n    [ ! -e "/var/run/fail2ban" ] \&\& mkdir /var/run/fail2ban@' /etc/init.d/fail2ban
+      chmod +x /etc/init.d/fail2ban
+      chkconfig --add fail2ban
+      chkconfig fail2ban on
+    elif [ "${PM}" == 'apt-get' ]; then
+      /bin/cp files/debian-initd /etc/init.d/fail2ban
+      sed -i 's@2 3 4 5@3 4 5@' /etc/init.d/fail2ban
+      sed -i "s@^DAEMON=.*@DAEMON=${python_install_dir}/bin/\$NAME-client@" /etc/init.d/fail2ban
+      chmod +x /etc/init.d/fail2ban
+      update-rc.d fail2ban defaults
+    fi
+  fi
+  [ -z "`grep ^Port /etc/ssh/sshd_config`" ] && now_ssh_port=22 || now_ssh_port=`grep ^Port /etc/ssh/sshd_config | awk '{print $2}' | head -1`
+  [ "${PM}" == 'yum' ] && LOGPATH=/var/log/secure
+  [ "${PM}" == 'apt-get' ] && LOGPATH=/var/log/auth.log
+  cat > /etc/fail2ban/jail.local << EOF
+[DEFAULT]
+ignoreip = 127.0.0.1/8
+bantime  = 86400
+findtime = 600
+maxretry = 5
+[ssh-iptables]
+enabled = true
+filter  = sshd
+action  = iptables[name=SSH, port=${now_ssh_port}, protocol=tcp]
+logpath = ${LOGPATH}
+EOF
+  cat > /etc/logrotate.d/fail2ban << EOF
+/var/log/fail2ban.log {
+    missingok
+    notifempty
+    postrotate
+      ${python_install_dir}/bin/fail2ban-client flushlogs >/dev/null || true
+    endscript
+}
+EOF
+  sed -i 's@^iptables = iptables.*@iptables = iptables@' /etc/fail2ban/action.d/iptables-common.conf
+  kill -9 `ps -ef | grep fail2ban | grep -v grep | awk '{print $2}'` > /dev/null 2>&1
+  service fail2ban start
+  popd > /dev/null
+  if [ -e "${python_install_dir}/bin/fail2ban-server" ]; then
+    echo; echo "${CSUCCESS}fail2ban installed successfully! ${CEND}"
+  else
+    echo; echo "${CFAILURE}fail2ban install failed, Please try again! ${CEND}"
+  fi
+  popd > /dev/null
+}
+
+Uninstall_fail2ban() {
+  service fail2ban stop
+  ${python_install_dir}/bin/pip uninstall -y fail2ban > /dev/null 2>&1
+  rm -rf /etc/init.d/fail2ban /etc/fail2ban /etc/logrotate.d/fail2ban /var/log/fail2ban.* /var/run/fail2ban
+  echo; echo "${CMSG}fail2ban uninstall completed${CEND}";
+}

+ 9 - 7
include/get_ipaddr_state.py

@@ -1,15 +1,17 @@
 #!/usr/bin/env python
 #coding:utf-8
-import sys,urllib2,socket
+import sys,urllib2,socket,json
 try:
   socket.setdefaulttimeout(5)
-  apiurl = "http://ip.taobao.com/service/getIpInfo.php?ip=%s" % sys.argv[1]
+  if len(sys.argv) == 1:
+    apiurl = "http://ip-api.com/json"
+  elif len(sys.argv) == 2:
+    apiurl = "http://ip-api.com/json/%s" % sys.argv[1]
   content = urllib2.urlopen(apiurl).read()
-  data = eval(content)['data']
-  code = eval(content)['code']
-  if code == 0:
-    print(data['country_id'])
+  content = json.JSONDecoder().decode(content)
+  if content['status'] == 'success':
+    print(content['countryCode'])
   else:
-    print(data)
+    print("CN")
 except:
   print("Usage:%s IP" % sys.argv[0])

+ 1 - 1
include/get_public_ipaddr.py

@@ -4,7 +4,7 @@ class Get_public_ip:
   socket.setdefaulttimeout(5)
   def getip(self):
     try:
-      myip = self.visit("http://ip.taobao.com/ipSearch.html")
+      myip = self.visit("http://ip-api.com/json")
     except:
       try:
         myip = self.visit("http://ipv4.icanhazip.com/")

+ 1 - 1
include/init_CentOS.sh

@@ -144,7 +144,7 @@ EOF
   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
   /bin/cp /etc/sysconfig/{iptables,ip6tables}
-  sed -i 's@icmp@icmpv6@g' /etc/sysconfig/ip6tables 
+  sed -i 's@icmp@icmpv6@g' /etc/sysconfig/ip6tables
   iptables-restore < /etc/sysconfig/iptables
   ip6tables-restore < /etc/sysconfig/ip6tables
   service iptables save

+ 104 - 82
include/ioncube.sh

@@ -9,88 +9,110 @@
 #       https://github.com/oneinstack/oneinstack
 
 Install_ionCube() {
-  pushd ${oneinstack_dir}/src > /dev/null
-  PHP_detail_ver=`${php_install_dir}/bin/php -r 'echo PHP_VERSION;'`
-  PHP_main_ver=${PHP_detail_ver%.*}
-  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
-  if  [ "${TARGET_ARCH}" == "armv7" ]; then
-    tar xzf ioncube_loaders_lin_armv7l.tar.gz
-  else
-    tar xzf ioncube_loaders_lin_${SYS_BIT_d}.tar.gz
-  fi
+  if [ -e "${php_install_dir}/bin/phpize" ]; then
+    pushd ${oneinstack_dir}/src > /dev/null
+    PHP_detail_ver=`${php_install_dir}/bin/php -r 'echo PHP_VERSION;'`
+    PHP_main_ver=${PHP_detail_ver%.*}
+    phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
+    if  [ "${TARGET_ARCH}" == "armv7" ]; then
+      tar xzf ioncube_loaders_lin_armv7l.tar.gz
+    else
+      tar xzf ioncube_loaders_lin_${SYS_BIT_d}.tar.gz
+    fi
 
-  [ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir}
-  case "${PHP_main_ver}" in
-    7.2)
-      if [ -z "`echo $phpExtensionDir | grep 'non-zts'`" ]; then
-        /bin/cp ioncube/ioncube_loader_lin_7.2_ts.so ${phpExtensionDir}
-        zend_extension="${phpExtensionDir}/ioncube_loader_lin_7.2_ts.so"
-      else
-        /bin/cp ioncube/ioncube_loader_lin_7.2.so ${phpExtensionDir}
-        zend_extension="${phpExtensionDir}/ioncube_loader_lin_7.2.so"
-      fi
-      ;;
-    7.1)
-      if [ -z "`echo $phpExtensionDir | grep 'non-zts'`" ]; then
-        /bin/cp ioncube/ioncube_loader_lin_7.1_ts.so ${phpExtensionDir}
-        zend_extension="${phpExtensionDir}/ioncube_loader_lin_7.1_ts.so"
-      else
-        /bin/cp ioncube/ioncube_loader_lin_7.1.so ${phpExtensionDir}
-        zend_extension="${phpExtensionDir}/ioncube_loader_lin_7.1.so"
-      fi
-      ;;
-    7.0)
-      if [ -z "`echo $phpExtensionDir | grep 'non-zts'`" ]; then
-        /bin/cp ioncube/ioncube_loader_lin_7.0_ts.so ${phpExtensionDir}
-        zend_extension="${phpExtensionDir}/ioncube_loader_lin_7.0_ts.so"
-      else
-        /bin/cp ioncube/ioncube_loader_lin_7.0.so ${phpExtensionDir}
-        zend_extension="${phpExtensionDir}/ioncube_loader_lin_7.0.so"
-      fi
-      ;;
-    5.6)
-      if [ -z "`echo $phpExtensionDir | grep 'non-zts'`" ]; then
-        /bin/cp ioncube/ioncube_loader_lin_5.6_ts.so ${phpExtensionDir}
-        zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.6_ts.so"
-      else
-        /bin/cp ioncube/ioncube_loader_lin_5.6.so ${phpExtensionDir}
-        zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.6.so"
-      fi
-      ;;
-    5.5)
-      if [ -z "`echo $phpExtensionDir | grep 'non-zts'`" ]; then
-        /bin/cp ioncube/ioncube_loader_lin_5.5_ts.so ${phpExtensionDir}
-        zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.5_ts.so"
-      else
-        /bin/cp ioncube/ioncube_loader_lin_5.5.so ${phpExtensionDir}
-        zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.5.so"
-      fi
-     ;;
-    5.4)
-      if [ -z "`echo $phpExtensionDir | grep 'non-zts'`" ]; then
-        /bin/cp ioncube/ioncube_loader_lin_5.4_ts.so ${phpExtensionDir}
-        zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.4_ts.so"
-      else
-        /bin/cp ioncube/ioncube_loader_lin_5.4.so ${phpExtensionDir}
-        zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.4.so"
-      fi
-      ;;
-    5.3)
-      if [ -z "`echo $phpExtensionDir | grep 'non-zts'`" ]; then
-        /bin/cp ioncube/ioncube_loader_lin_5.3_ts.so ${phpExtensionDir}
-        zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.3_ts.so"
-      else
-        /bin/cp ioncube/ioncube_loader_lin_5.3.so ${phpExtensionDir}
-        zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.3.so"
-      fi
-      ;;
-    *)
-      echo "Error! Your PHP ${PHP_detail_ver} does not support ionCube!"
-      exit 1
-      ;;
-  esac
+    [ -e "${php_install_dir}/bin/phpize" ] && [ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir}
+    case "${PHP_main_ver}" in
+      7.3)
+        if [ -z "`echo $phpExtensionDir | grep 'non-zts'`" ]; then
+          /bin/mv ioncube/ioncube_loader_lin_7.3_ts.so ${phpExtensionDir}
+          zend_extension="${phpExtensionDir}/ioncube_loader_lin_7.3_ts.so"
+        else
+          /bin/mv ioncube/ioncube_loader_lin_7.3.so ${phpExtensionDir}
+          zend_extension="${phpExtensionDir}/ioncube_loader_lin_7.3.so"
+        fi
+        ;;
+      7.2)
+        if [ -z "`echo $phpExtensionDir | grep 'non-zts'`" ]; then
+          /bin/mv ioncube/ioncube_loader_lin_7.2_ts.so ${phpExtensionDir}
+          zend_extension="${phpExtensionDir}/ioncube_loader_lin_7.2_ts.so"
+        else
+          /bin/mv ioncube/ioncube_loader_lin_7.2.so ${phpExtensionDir}
+          zend_extension="${phpExtensionDir}/ioncube_loader_lin_7.2.so"
+        fi
+        ;;
+      7.1)
+        if [ -z "`echo $phpExtensionDir | grep 'non-zts'`" ]; then
+          /bin/mv ioncube/ioncube_loader_lin_7.1_ts.so ${phpExtensionDir}
+          zend_extension="${phpExtensionDir}/ioncube_loader_lin_7.1_ts.so"
+        else
+          /bin/mv ioncube/ioncube_loader_lin_7.1.so ${phpExtensionDir}
+          zend_extension="${phpExtensionDir}/ioncube_loader_lin_7.1.so"
+        fi
+        ;;
+      7.0)
+        if [ -z "`echo $phpExtensionDir | grep 'non-zts'`" ]; then
+          /bin/mv ioncube/ioncube_loader_lin_7.0_ts.so ${phpExtensionDir}
+          zend_extension="${phpExtensionDir}/ioncube_loader_lin_7.0_ts.so"
+        else
+          /bin/mv ioncube/ioncube_loader_lin_7.0.so ${phpExtensionDir}
+          zend_extension="${phpExtensionDir}/ioncube_loader_lin_7.0.so"
+        fi
+        ;;
+      5.6)
+        if [ -z "`echo $phpExtensionDir | grep 'non-zts'`" ]; then
+          /bin/mv ioncube/ioncube_loader_lin_5.6_ts.so ${phpExtensionDir}
+          zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.6_ts.so"
+        else
+          /bin/mv ioncube/ioncube_loader_lin_5.6.so ${phpExtensionDir}
+          zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.6.so"
+        fi
+        ;;
+      5.5)
+        if [ -z "`echo $phpExtensionDir | grep 'non-zts'`" ]; then
+          /bin/mv ioncube/ioncube_loader_lin_5.5_ts.so ${phpExtensionDir}
+          zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.5_ts.so"
+        else
+          /bin/mv ioncube/ioncube_loader_lin_5.5.so ${phpExtensionDir}
+          zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.5.so"
+        fi
+       ;;
+      5.4)
+        if [ -z "`echo $phpExtensionDir | grep 'non-zts'`" ]; then
+          /bin/mv ioncube/ioncube_loader_lin_5.4_ts.so ${phpExtensionDir}
+          zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.4_ts.so"
+        else
+          /bin/mv ioncube/ioncube_loader_lin_5.4.so ${phpExtensionDir}
+          zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.4.so"
+        fi
+        ;;
+      5.3)
+        if [ -z "`echo $phpExtensionDir | grep 'non-zts'`" ]; then
+          /bin/mv ioncube/ioncube_loader_lin_5.3_ts.so ${phpExtensionDir}
+          zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.3_ts.so"
+        else
+          /bin/mv ioncube/ioncube_loader_lin_5.3.so ${phpExtensionDir}
+          zend_extension="${phpExtensionDir}/ioncube_loader_lin_5.3.so"
+        fi
+        ;;
+      *)
+        echo "${CWARNING}Your php ${PHP_detail_ver} does not support ionCube! ${CEND}";
+        ;;
+    esac
 
-  echo "zend_extension=${zend_extension}" > ${php_install_dir}/etc/php.d/00-ioncube.ini
-  rm -rf ioncube
-  popd > /dev/null
+    if [ -f "${zend_extension}" ]; then
+      echo "zend_extension=${zend_extension}" > ${php_install_dir}/etc/php.d/00-ioncube.ini
+      echo "${CSUCCESS}PHP ionCube module installed successfully! ${CEND}"
+      rm -rf ioncube
+    fi
+    popd > /dev/null
+  fi
+}
+
+Uninstall_ionCube() {
+  if [ -e "${php_install_dir}/etc/php.d/00-ioncube.ini" ]; then
+    rm -f ${php_install_dir}/etc/php.d/00-ioncube.ini
+    echo; echo "${CMSG}PHP ionCube module uninstall completed${CEND}"
+  else
+    echo; echo "${CWARNING}PHP ionCube module does not exist! ${CEND}"
+  fi
 }

+ 56 - 33
include/memcached.sh

@@ -8,20 +8,20 @@
 #       https://oneinstack.com
 #       https://github.com/oneinstack/oneinstack
 
-Install_memcached() {
+Install_memcached-server() {
   pushd ${oneinstack_dir}/src > /dev/null
   # memcached server
   id -u memcached >/dev/null 2>&1
   [ $? -ne 0 ] && useradd -M -s /sbin/nologin memcached
 
   tar xzf memcached-${memcached_ver}.tar.gz
-  pushd memcached-${memcached_ver}
+  pushd memcached-${memcached_ver} > /dev/null
   [ ! -d "${memcached_install_dir}" ] && mkdir -p ${memcached_install_dir}
   [ "${PM}" == 'yum' ] && libevent_arg='--with-libevent=/usr/local'
   ./configure --prefix=${memcached_install_dir} ${libevent_arg}
   make -j ${THREAD} && make install
-  popd
-  if [ -d "${memcached_install_dir}/include/memcached" ]; then
+  popd > /dev/null
+  if [ -f "${memcached_install_dir}/bin/memcached" ]; then
     echo "${CSUCCESS}memcached installed successfully! ${CEND}"
     rm -rf memcached-${memcached_ver}
     ln -s ${memcached_install_dir}/bin/memcached /usr/bin/memcached
@@ -31,49 +31,54 @@ Install_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
-    [ -e /usr/bin/systemctl ] && systemctl daemon-reload
+    [ -e /bin/systemctl ] && systemctl daemon-reload
     service memcached start
     rm -rf memcached-${memcached_ver}
   else
     rm -rf ${memcached_install_dir}
-    echo "${CFAILURE}memcached install failed, Please contact the author! ${CEND}"
+    echo "${CFAILURE}memcached-server install failed, Please contact the author! ${CEND}"
     kill -9 $$
   fi
-  popd
+  popd > /dev/null
 }
 
 Install_pecl-memcache() {
-  pushd ${oneinstack_dir}/src > /dev/null
   if [ -e "${php_install_dir}/bin/phpize" ]; then
+    pushd ${oneinstack_dir}/src > /dev/null
     phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
-    # php memcache extension
-    if [ "$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}')" == '7' ]; then
-      #git clone https://github.com/websupport-sk/pecl-memcache.git
-      #cd pecl-memcache
-      tar xzf pecl-memcache-php7.tgz
-      pushd pecl-memcache-php7 > /dev/null
+    PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
+    PHP_main_ver=${PHP_detail_ver%.*}
+    if [[ "${PHP_main_ver}" =~ ^5.[3-6]$|^7.[0-2]$ ]]; then
+      if [[ "${PHP_main_ver}" =~ ^7.[0-2]$ ]]; then
+        #git clone https://github.com/websupport-sk/pecl-memcache.git
+        #cd pecl-memcache
+        tar xzf pecl-memcache-php7.tgz
+        pushd pecl-memcache-php7 > /dev/null
+      else
+        tar xzf memcache-${pecl_memcache_ver}.tgz
+        pushd memcache-${pecl_memcache_ver} > /dev/null
+      fi
+      ${php_install_dir}/bin/phpize
+      ./configure --with-php-config=${php_install_dir}/bin/php-config
+      make -j ${THREAD} && make install
+      popd > /dev/null
+      if [ -f "${phpExtensionDir}/memcache.so" ]; then
+        echo "extension=memcache.so" > ${php_install_dir}/etc/php.d/05-memcache.ini
+        echo "${CSUCCESS}PHP memcache module installed successfully! ${CEND}"
+        rm -rf pecl-memcache-php7 memcache-${pecl_memcache_ver}
+      else
+        echo "${CFAILURE}PHP memcache module install failed, Please contact the author! ${CEND}"
+      fi
     else
-      tar xzf memcache-${pecl_memcache_ver}.tgz
-      pushd memcache-${pecl_memcache_ver} > /dev/null
+      echo; echo "${CWARNING}Your php ${PHP_detail_ver} does not support pecl_memcache! ${CEND}";
     fi
-    ${php_install_dir}/bin/phpize
-    ./configure --with-php-config=${php_install_dir}/bin/php-config
-    make -j ${THREAD} && make install
     popd > /dev/null
-    if [ -f "${phpExtensionDir}/memcache.so" ]; then
-      echo "extension=memcache.so" > ${php_install_dir}/etc/php.d/05-memcache.ini
-      echo "${CSUCCESS}PHP memcache module installed successfully! ${CEND}"
-      rm -rf pecl-memcache-php7 memcache-${pecl_memcache_ver}
-    else
-      echo "${CFAILURE}PHP memcache module install failed, Please contact the author! ${CEND}"
-    fi
   fi
-  popd > /dev/null
 }
 
 Install_pecl-memcached() {
-  pushd ${oneinstack_dir}/src > /dev/null
   if [ -e "${php_install_dir}/bin/phpize" ]; then
+    pushd ${oneinstack_dir}/src > /dev/null
     phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
     # php memcached extension
     tar xzf libmemcached-${libmemcached_ver}.tar.gz
@@ -87,11 +92,11 @@ Install_pecl-memcached() {
     rm -rf libmemcached-${libmemcached_ver}
 
     if [ "$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1}')" == '7' ]; then
-      tar xzf memcached-${pecl_memcached_php7_ver}.tgz
-      pushd memcached-${pecl_memcached_php7_ver} > /dev/null
-    else
       tar xzf memcached-${pecl_memcached_ver}.tgz
       pushd memcached-${pecl_memcached_ver} > /dev/null
+    else
+      tar xzf memcached-${pecl_memcached_oldver}.tgz
+      pushd memcached-${pecl_memcached_oldver} > /dev/null
     fi
     ${php_install_dir}/bin/phpize
     ./configure --with-php-config=${php_install_dir}/bin/php-config
@@ -103,10 +108,28 @@ extension=memcached.so
 memcached.use_sasl=1
 EOF
       echo "${CSUCCESS}PHP memcached module installed successfully! ${CEND}"
-      rm -rf memcached-${pecl_memcached_ver} memcached-${pecl_memcached_php7_ver}
+      rm -rf memcached-${pecl_memcached_oldver} memcached-${pecl_memcached_ver}
     else
       echo "${CFAILURE}PHP memcached module install failed, Please contact the author! ${CEND}"
     fi
+    popd > /dev/null
+  fi
+}
+
+Uninstall_pecl-memcache() {
+  if [ -e "${php_install_dir}/etc/php.d/05-memcache.ini" ]; then
+    rm -f ${php_install_dir}/etc/php.d/05-memcache.ini
+    echo; echo "${CMSG}PHP memcache module uninstall completed${CEND}"
+  else
+    echo; echo "${CWARNING}PHP memcache module does not exist! ${CEND}"
+  fi
+}
+
+Uninstall_pecl-memcached() {
+  if [ -e "${php_install_dir}/etc/php.d/05-memcached.ini" ]; then
+    rm -f ${php_install_dir}/etc/php.d/05-memcached.ini
+    echo; echo "${CMSG}PHP memcached module uninstall completed${CEND}"
+  else
+    echo; echo "${CWARNING}PHP memcached module does not exist! ${CEND}"
   fi
-  popd > /dev/null
 }

+ 7 - 5
include/openssl.sh

@@ -9,23 +9,25 @@
 #       https://github.com/oneinstack/oneinstack
 
 Install_openSSL() {
-  if [ ! -e "${openssl_install_dir}/lib/libcrypto.a" ]; then
+  if [ -e "${openssl_install_dir}/lib/libssl.a" ]; then
+    echo "${CWARNING}openSSL already installed! ${CEND}"
+  else
     pushd ${oneinstack_dir}/src > /dev/null
     tar xzf openssl-${openssl_ver}.tar.gz
-    pushd openssl-${openssl_ver}
+    pushd openssl-${openssl_ver} > /dev/null
     make clean
     ./config -Wl,-rpath=${openssl_install_dir}/lib -fPIC --prefix=${openssl_install_dir} --openssldir=${openssl_install_dir}
     make depend
     make -j ${THREAD} && make install
-    popd
+    popd > /dev/null
     if [ -f "${openssl_install_dir}/lib/libcrypto.a" ]; then
       echo "${CSUCCESS}openssl installed successfully! ${CEND}"
       /bin/cp cacert.pem ${openssl_install_dir}/cert.pem
       rm -rf openssl-${openssl_ver}
     else
-      echo "${CFAILURE}openssl failed, Please contact the author! ${CEND}"
+      echo "${CFAILURE}openSSL install failed, Please contact the author! ${CEND}"
       kill -9 $$
     fi
-    popd
+    popd > /dev/null
   fi
 }

+ 31 - 0
include/panel.sh

@@ -19,12 +19,43 @@ Install_Panel() {
   if [ -e /bin/systemctl ]; then
     /bin/cp ${oneinstack_dir}/init.d/panel.service /lib/systemd/system/
     sed -i "s@/root/git/repo/panel@`pwd`@g" /lib/systemd/system/panel.service
+    systemctl enable panel
   else
     /bin/cp ${oneinstack_dir}/init.d/Panel-init /etc/init.d/panel
     sed -i "s@/root/git/repo/panel@`pwd`@g" /etc/init.d/panel
     [ "${PM}" == 'yum' ] && { chkconfig --add panel; chkconfig panel on; }
     [ "${PM}" == 'apt-get' ] && update-rc.d panel defaults
   fi
+
+  # Panel iptables
+  Panel_port=`cat data/port.conf`
+  if [ "${PM}" == 'yum' ]; then
+    if [ -n "`grep 'dport 80 ' /etc/sysconfig/iptables`" ] && [ -z "$(grep -w ${Panel_port} /etc/sysconfig/iptables)" ]; then
+      iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport ${Panel_port} -j ACCEPT
+      service iptables save
+      /bin/cp /etc/sysconfig/{iptables,ip6tables}
+      sed -i 's@icmp@icmpv6@g' /etc/sysconfig/ip6tables
+      ip6tables-restore < /etc/sysconfig/ip6tables
+      service ip6tables save
+    fi
+  elif [ "${PM}" == 'apt-get' ]; then
+    if [ -e '/etc/iptables/rules.v4' ]; then
+      if [ -n "`grep 'dport 80 ' /etc/iptables/rules.v4`" ] && [ -z "$(grep -w ${Panel_port} /etc/iptables/rules.v4)" ]; then
+        iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport ${Panel_port} -j ACCEPT
+        iptables-save > /etc/iptables/rules.v4
+        /bin/cp /etc/iptables/rules.v{4,6}
+        sed -i 's@icmp@icmpv6@g' /etc/iptables/rules.v6
+        ip6tables-restore < /etc/iptables/rules.v6
+        ip6tables-save > /etc/iptables/rules.v6
+      fi
+    elif [ -e '/etc/iptables.up.rules' ]; then
+      if [ -n "`grep 'dport 80 ' /etc/iptables.up.rules`" ] && [ -z "$(grep -w ${Panel_port} /etc/iptables.up.rules)" ]; then
+        iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport ${Panel_port} -j ACCEPT
+        iptables-save > /etc/iptables.up.rules
+      fi
+    fi
+  fi
+
   popd > /dev/null
   popd > /dev/null
   service panel start

+ 41 - 0
include/pecl_fileinfo.sh

@@ -0,0 +1,41 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.cn
+#
+# Notes: OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+
+#
+# Project home page:
+#       https://oneinstack.com
+#       https://github.com/oneinstack/oneinstack
+
+Install_pecl-fileinfo() {
+  if [ -e "${php_install_dir}/bin/phpize" ]; then
+    pushd ${oneinstack_dir}/src > /dev/null
+    phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
+    PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
+    src_url=http://www.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src
+    tar xzf php-${PHP_detail_ver}.tar.gz
+    pushd php-${PHP_detail_ver}/ext/fileinfo > /dev/null
+    ${php_install_dir}/bin/phpize
+    ./configure --with-php-config=${php_install_dir}/bin/php-config
+    make -j ${THREAD} && make install
+    popd > /dev/null
+    if [ -f "${phpExtensionDir}/fileinfo.so" ]; then
+      echo 'extension=fileinfo.so' > ${php_install_dir}/etc/php.d/04-fileinfo.ini
+      echo "${CSUCCESS}PHP fileinfo module installed successfully! ${CEND}"
+      rm -rf php-${PHP_detail_ver}
+    else
+      echo "${CFAILURE}PHP fileinfo module install failed, Please contact the author! ${CEND}"
+    fi
+    popd > /dev/null
+  fi
+}
+
+Uninstall_pecl-fileinfo() {
+  if [ -e "${php_install_dir}/etc/php.d/04-fileinfo.ini" ]; then
+    rm -f ${php_install_dir}/etc/php.d/04-fileinfo.ini
+    echo; echo "${CMSG}PHP fileinfo module uninstall completed${CEND}"
+  else
+    echo; echo "${CWARNING}PHP fileinfo module does not exist! ${CEND}"
+  fi
+}

+ 47 - 0
include/pecl_imap.sh

@@ -0,0 +1,47 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.cn
+#
+# Notes: OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+
+#
+# Project home page:
+#       https://oneinstack.com
+#       https://github.com/oneinstack/oneinstack
+
+Install_pecl-imap() {
+  if [ -e "${php_install_dir}/bin/phpize" ]; then
+    pushd ${oneinstack_dir}/src > /dev/null
+    if [ "${PM}" == 'yum' ]; then
+      yum -y install libc-client-devel
+      [ "${OS_BIT}" == '64' -a ! -e /usr/lib/libc-client.so ] && ln -s /usr/lib64/libc-client.so /usr/lib/libc-client.so
+    else
+      apt-get -y install libc-client2007e-dev
+    fi
+    phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
+    PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
+    src_url=http://www.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src
+    tar xzf php-${PHP_detail_ver}.tar.gz
+    pushd php-${PHP_detail_ver}/ext/imap > /dev/null
+    ${php_install_dir}/bin/phpize
+    ./configure --with-php-config=${php_install_dir}/bin/php-config --with-kerberos --with-imap --with-imap-ssl
+    make -j ${THREAD} && make install
+    popd > /dev/null
+    if [ -f "${phpExtensionDir}/imap.so" ]; then
+      echo 'extension=imap.so' > ${php_install_dir}/etc/php.d/04-imap.ini
+      echo "${CSUCCESS}PHP imap module installed successfully! ${CEND}"
+      rm -rf php-${PHP_detail_ver}
+    else
+      echo "${CFAILURE}PHP imap module install failed, Please contact the author! ${CEND}"
+    fi
+    popd > /dev/null
+  fi
+}
+
+Uninstall_pecl-imap() {
+  if [ -e "${php_install_dir}/etc/php.d/04-imap.ini" ]; then
+    rm -f ${php_install_dir}/etc/php.d/04-imap.ini
+    echo; echo "${CMSG}PHP imap module uninstall completed${CEND}"
+  else
+    echo; echo "${CWARNING}PHP imap module does not exist! ${CEND}"
+  fi
+}

+ 20 - 3
include/pecl_mongodb.sh

@@ -9,10 +9,11 @@
 #       https://github.com/oneinstack/oneinstack
 
 Install_pecl-mongodb() {
-  pushd ${oneinstack_dir}/src > /dev/null
   if [ -e "${php_install_dir}/bin/phpize" ]; then
+    pushd ${oneinstack_dir}/src > /dev/null
     phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
     if [[ "$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;' | awk -F. '{print $1$2}')" =~ ^5[3-4]$ ]]; then
+      src_url=https://pecl.php.net/get/mongo-${pecl_mongo_ver}.tgz && Download_src
       tar xzf mongo-${pecl_mongo_ver}.tgz
       pushd mongo-${pecl_mongo_ver} > /dev/null
       ${php_install_dir}/bin/phpize
@@ -27,6 +28,7 @@ Install_pecl-mongodb() {
         echo "${CFAILURE}PHP mongo module install failed, Please contact the author! ${CEND}"
       fi
     else
+      src_url=https://pecl.php.net/get/mongodb-${pecl_mongodb_ver}.tgz && Download_src
       tar xzf mongodb-${pecl_mongodb_ver}.tgz
       pushd mongodb-${pecl_mongodb_ver} > /dev/null
       ${php_install_dir}/bin/phpize
@@ -35,12 +37,27 @@ Install_pecl-mongodb() {
       popd > /dev/null
       if [ -f "${phpExtensionDir}/mongodb.so" ]; then
         echo 'extension=mongodb.so' > ${php_install_dir}/etc/php.d/07-mongodb.ini
-        rm -rf mongodb-${pecl_mongodb_ver}
         echo "${CSUCCESS}PHP mongodb module installed successfully! ${CEND}"
+        rm -rf mongodb-${pecl_mongodb_ver}
       else
         echo "${CFAILURE}PHP mongodb module install failed, Please contact the author! ${CEND}"
       fi
     fi
+    popd > /dev/null
+  fi
+}
+
+Uninstall_pecl-mongodb() {
+  if [ -e "${php_install_dir}/etc/php.d/07-mongo.ini" ]; then
+    rm -f ${php_install_dir}/etc/php.d/07-mongo.ini
+    echo; echo "${CMSG}PHP mongo module uninstall completed${CEND}"
+  else
+    echo; echo "${CWARNING}PHP mongo module does not exist! ${CEND}"
+  fi
+  if [ -e "${php_install_dir}/etc/php.d/07-mongodb.ini" ]; then
+    rm -f ${php_install_dir}/etc/php.d/07-mongodb.ini
+    echo; echo "${CMSG}PHP mongodb module uninstall completed${CEND}"
+  else
+    echo; echo "${CWARNING}PHP mongodb module does not exist! ${CEND}"
   fi
-  popd > /dev/null
 }

+ 11 - 2
include/pecl_pgsql.sh

@@ -9,8 +9,8 @@
 #       https://github.com/oneinstack/oneinstack
 
 Install_pecl-pgsql() {
-  pushd ${oneinstack_dir}/src > /dev/null
   if [ -e "${php_install_dir}/bin/phpize" ]; then
+    pushd ${oneinstack_dir}/src > /dev/null
     phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
     PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
     tar xzf php-${PHP_detail_ver}.tar.gz
@@ -32,6 +32,15 @@ Install_pecl-pgsql() {
     else
       echo "${CFAILURE}PHP pgsql module install failed, Please contact the author! ${CEND}"
     fi
+    popd > /dev/null
+  fi
+}
+
+Uninstall_pecl-pgsql() {
+  if [ -e "${php_install_dir}/etc/php.d/07-pgsql.ini" ]; then
+    rm -f ${php_install_dir}/etc/php.d/07-pgsql.ini
+    echo; echo "${CMSG}PHP pgsql module uninstall completed${CEND}"
+  else
+    echo; echo "${CWARNING}PHP pgsql module does not exist! ${CEND}"
   fi
-  popd > /dev/null
 }

+ 45 - 0
include/pecl_phalcon.sh

@@ -0,0 +1,45 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.cn
+#
+# Notes: OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+
+#
+# Project home page:
+#       https://oneinstack.com
+#       https://github.com/oneinstack/oneinstack
+
+Install_pecl-phalcon() {
+  if [ -e "${php_install_dir}/bin/phpize" ]; then
+    pushd ${oneinstack_dir}/src > /dev/null
+    PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
+    PHP_main_ver=${PHP_detail_ver%.*}
+    if [[ "${PHP_main_ver}" =~ ^5.[5-6]$|^7.[0-3]$ ]]; then
+      phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
+      src_url=http://mirrors.linuxeye.com/oneinstack/src/cphalcon-${phalcon_ver}.tar.gz && Download_src
+      tar xzf cphalcon-${phalcon_ver}.tar.gz
+      pushd cphalcon-${phalcon_ver}/build > /dev/null
+      echo "${CMSG}It may take a few minutes... ${CEND}"
+      ./install --phpize ${php_install_dir}/bin/phpize --php-config ${php_install_dir}/bin/php-config --arch ${OS_BIT}bits
+      popd > /dev/null
+      if [ -f "${phpExtensionDir}/phalcon.so" ]; then
+        echo 'extension=phalcon.so' > ${php_install_dir}/etc/php.d/04-phalcon.ini
+        echo "${CSUCCESS}PHP phalcon module installed successfully! ${CEND}"
+        rm -rf cphalcon-${phalcon_ver}
+      else
+        echo "${CFAILURE}PHP phalcon module install failed, Please contact the author! ${CEND}"
+      fi
+    else
+      echo "${CWARNING}Your php ${PHP_detail_ver} does not support phalcon! ${CEND}";
+    fi
+    popd > /dev/null
+  fi
+}
+
+Uninstall_pecl-phalcon() {
+  if [ -e "${php_install_dir}/etc/php.d/04-phalcon.ini" ]; then
+    rm -f ${php_install_dir}/etc/php.d/04-phalcon.ini
+    echo; echo "${CMSG}PHP phalcon module uninstall completed${CEND}"
+  else
+    echo; echo "${CWARNING}PHP phalcon module does not exist! ${CEND}"
+  fi
+}

+ 48 - 0
include/pecl_swoole.sh

@@ -0,0 +1,48 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.cn
+#
+# Notes: OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+
+#
+# Project home page:
+#       https://oneinstack.com
+#       https://github.com/oneinstack/oneinstack
+
+Install_pecl-swoole() {
+  if [ -e "${php_install_dir}/bin/phpize" ]; then
+    pushd ${oneinstack_dir}/src > /dev/null
+    phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
+    PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
+    PHP_main_ver=${PHP_detail_ver%.*}
+    if [[ "${PHP_main_ver}" =~ ^5.[3-6]$ ]]; then
+      src_url=https://pecl.php.net/get/swoole-${swoole_oldver}.tgz && Download_src
+      tar xzf swoole-${swoole_oldver}.tgz
+      pushd swoole-${swoole_oldver} > /dev/null
+    else
+      src_url=https://pecl.php.net/get/swoole-${swoole_ver}.tgz && Download_src
+      tar xzf swoole-${swoole_ver}.tgz
+      pushd swoole-${swoole_ver} > /dev/null
+    fi
+    ${php_install_dir}/bin/phpize
+    ./configure --with-php-config=${php_install_dir}/bin/php-config --enable-openssl --with-openssl-dir=${openssl_install_dir}
+    make -j ${THREAD} && make install
+    popd > /dev/null
+    if [ -f "${phpExtensionDir}/swoole.so" ]; then
+      echo 'extension=swoole.so' > ${php_install_dir}/etc/php.d/06-swoole.ini
+      echo "${CSUCCESS}PHP swoole module installed successfully! ${CEND}"
+      rm -rf swoole-${swoole_ver} swoole-${swoole_oldver}
+    else
+      echo "${CFAILURE}PHP swoole module install failed, Please contact the author! ${CEND}"
+    fi
+    popd > /dev/null
+  fi
+}
+
+Uninstall_pecl-swoole() {
+  if [ -e "${php_install_dir}/etc/php.d/06-swoole.ini" ]; then
+    rm -f ${php_install_dir}/etc/php.d/06-swoole.ini
+    echo; echo "${CMSG}PHP swoole module uninstall completed${CEND}"
+  else
+    echo; echo "${CWARNING}PHP swoole module does not exist! ${CEND}"
+  fi
+}

+ 67 - 0
include/pecl_xdebug.sh

@@ -0,0 +1,67 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.cn
+#
+# Notes: OneinStack for CentOS/RedHat 6+ Debian 7+ and Ubuntu 12+
+#
+# Project home page:
+#       https://oneinstack.com
+#       https://github.com/oneinstack/oneinstack
+
+Install_pecl-xdebug() {
+  if [ -e "${php_install_dir}/bin/phpize" ]; then
+    pushd ${oneinstack_dir}/src > /dev/null
+    PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
+    PHP_main_ver=${PHP_detail_ver%.*}
+    if [[ "${PHP_main_ver}" =~ ^5.[5-6]$|^7.[0-2]$ ]]; then
+      if [[ "${PHP_main_ver}" =~ ^7.[0-2]$ ]]; then
+        src_url=https://pecl.php.net/get/xdebug-${xdebug_ver}.tgz && Download_src
+        tar xzf xdebug-${xdebug_ver}.tgz
+        pushd xdebug-${xdebug_ver} > /dev/null
+      elif [[ "${PHP_main_ver}" =~ ^5.[5-6]$ ]]; then
+        src_url=https://pecl.php.net/get/xdebug-${xdebug_oldver}.tgz && Download_src
+        tar xzf xdebug-${xdebug_oldver}.tgz
+        pushd xdebug-${xdebug_oldver} > /dev/null
+      fi
+      ${php_install_dir}/bin/phpize
+      ./configure --with-php-config=${php_install_dir}/bin/php-config
+      make -j ${THREAD} && make install
+      popd > /dev/null
+      if [ -f "${phpExtensionDir}/xdebug.so" ]; then
+        src_url=http://mirrors.linuxeye.com/oneinstack/src/webgrind-master.zip && Download_src
+        unzip -q webgrind-master.zip
+        /bin/mv webgrind-master ${wwwroot_dir}/default/webgrind
+        [ ! -e /tmp/xdebug ] && { mkdir /tmp/xdebug; chown ${run_user}.${run_user} /tmp/xdebug; }
+        [ ! -e /tmp/webgrind ] && { mkdir /tmp/webgrind; chown ${run_user}.${run_user} /tmp/webgrind; }
+        chown -R ${run_user}.${run_user} ${wwwroot_dir}/default/webgrind
+        sed -i 's@static $storageDir.*@static $storageDir = "/tmp/webgrind";@' ${wwwroot_dir}/default/webgrind/config.php
+        sed -i 's@static $profilerDir.*@static $profilerDir = "/tmp/xdebug";@' ${wwwroot_dir}/default/webgrind/config.php
+        cat > ${php_install_dir}/etc/php.d/08-xdebug.ini << EOF
+[xdebug]
+zend_extension=xdebug.so
+xdebug.trace_output_dir=/tmp/xdebug
+xdebug.profiler_output_dir = /tmp/xdebug
+xdebug.profiler_enable = On
+xdebug.profiler_enable_trigger = 1
+EOF
+        echo "${CSUCCESS}PHP xdebug module installed successfully! ${CEND}"
+        echo; echo "Webgrind URL: ${CMSG}http://{Public IP}/webgrind ${CEND}"
+        rm -rf xdebug-${xdebug_ver} xdebug-${xdebug_oldver}
+      else
+        echo "${CFAILURE}PHP xdebug module install failed, Please contact the author! ${CEND}"
+      fi
+    else
+      echo "${CWARNING}Your php ${PHP_detail_ver} does not support xdebug! ${CEND}";
+    fi
+    popd > /dev/null
+  fi
+}
+
+Uninstall_pecl-xdebug() {
+  if [ -e "${php_install_dir}/etc/php.d/08-xdebug.ini" ]; then
+    rm -rf ${php_install_dir}/etc/php.d/08-xdebug.ini /tmp/{xdebug,webgrind} ${wwwroot_dir}/default/webgrind
+    echo; echo "${CMSG}PHP xdebug module uninstall completed${CEND}"
+  else
+    echo; echo "${CWARNING}PHP xdebug module does not exist! ${CEND}"
+  fi
+}

+ 26 - 28
include/pureftpd.sh

@@ -14,11 +14,11 @@ Install_PureFTPd() {
   [ $? -ne 0 ] && useradd -M -s /sbin/nologin ${run_user}
 
   tar xzf pure-ftpd-${pureftpd_ver}.tar.gz
-  pushd pure-ftpd-${pureftpd_ver}
+  pushd pure-ftpd-${pureftpd_ver} > /dev/null
   [ ! -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 --with-tls
   make -j ${THREAD} && make install
-  popd
+  popd > /dev/null
   if [ -e "${pureftpd_install_dir}/sbin/pure-ftpwho" ]; then
     if [ -e /bin/systemctl ]; then
       /bin/cp ../init.d/pureftpd.service /lib/systemd/system/
@@ -49,34 +49,32 @@ Install_PureFTPd() {
     service pureftpd start
 
     # iptables Ftp
-    if [ "${iptables_yn}" == 'y' ]; then
-      if [ "${PM}" == 'yum' ]; then
-        if [ -z "$(grep '20000:30000' /etc/sysconfig/iptables)" ]; then
+    if [ "${PM}" == 'yum' ]; then
+      if [ -n "`grep 'dport 80 ' /etc/sysconfig/iptables`" ] && [ -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
+        /bin/cp /etc/sysconfig/{iptables,ip6tables}
+        sed -i 's@icmp@icmpv6@g' /etc/sysconfig/ip6tables
+        ip6tables-restore < /etc/sysconfig/ip6tables
+        service ip6tables save
+      fi
+    elif [ "${PM}" == 'apt-get' ]; then
+      if [ -e '/etc/iptables/rules.v4' ]; then
+        if [ -n "`grep 'dport 80 ' /etc/iptables/rules.v4`" ] && [ -z "$(grep '20000:30000' /etc/iptables/rules.v4)" ]; 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
-          /bin/cp /etc/sysconfig/{iptables,ip6tables}
-          sed -i 's@icmp@icmpv6@g' /etc/sysconfig/ip6tables
-          ip6tables-restore < /etc/sysconfig/ip6tables
-          service ip6tables save
+          iptables-save > /etc/iptables/rules.v4
+          /bin/cp /etc/iptables/rules.v{4,6}
+          sed -i 's@icmp@icmpv6@g' /etc/iptables/rules.v6
+          ip6tables-restore < /etc/iptables/rules.v6
+          ip6tables-save > /etc/iptables/rules.v6
         fi
-      elif [ "${PM}" == 'apt-get' ]; then
-        if [ -e '/etc/iptables/rules.v4' ]; then
-          if [ -z "$(grep '20000:30000' /etc/iptables/rules.v4)" ]; 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/rules.v4
-            /bin/cp /etc/iptables/rules.v{4,6}
-            sed -i 's@icmp@icmpv6@g' /etc/iptables/rules.v6
-            ip6tables-restore < /etc/iptables/rules.v6
-            ip6tables-save > /etc/iptables/rules.v6
-          fi
-        elif [ -e '/etc/iptables.up.rules' ]; 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
+      elif [ -e '/etc/iptables.up.rules' ]; then
+        if [ -n "`grep 'dport 80 ' /etc/iptables.up.rules`" ] && [ -z "$(grep '20000:30000' /etc/iptables.up.rules)" ]; then
+          iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
+          iptables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT
+          iptables-save > /etc/iptables.up.rules
         fi
       fi
     fi
@@ -88,5 +86,5 @@ Install_PureFTPd() {
     echo "${CFAILURE}Pure-Ftpd install failed, Please contact the author! ${CEND}"
     kill -9 $$
   fi
-  popd
+  popd > /dev/null
 }

+ 53 - 36
include/python.sh

@@ -9,9 +9,12 @@
 #       https://github.com/oneinstack/oneinstack
 
 Install_Python() {
-  pushd ${oneinstack_dir}/src > /dev/null
-  if [ "${CentOS_ver}" == '7' ]; then
-    [ ! -e /etc/yum.repos.d/epel.repo ] && cat > /etc/yum.repos.d/epel.repo << EOF
+  if [ -e "${python_install_dir}/bin/python" ]; then
+    echo "${CWARNING}Python already installed! ${CEND}"
+  else
+    pushd ${oneinstack_dir}/src > /dev/null
+    if [ "${CentOS_ver}" == '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
 #baseurl=http://download.fedoraproject.org/pub/epel/7/\$basearch
@@ -20,8 +23,8 @@ failovermethod=priority
 enabled=1
 gpgcheck=0
 EOF
-  elif [ "${CentOS_ver}" == '6' ]; then
-    [ ! -e /etc/yum.repos.d/epel.repo ] && cat > /etc/yum.repos.d/epel.repo << EOF
+    elif [ "${CentOS_ver}" == '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
 #baseurl=http://download.fedoraproject.org/pub/epel/6/\$basearch
@@ -30,41 +33,55 @@ failovermethod=priority
 enabled=1
 gpgcheck=0
 EOF
-  fi
+    fi
 
-  if [ "${PM}" == 'yum' ]; then
-    pkgList="gcc dialog augeas-libs openssl openssl-devel libffi-devel redhat-rpm-config ca-certificates"
-    for Package in ${pkgList}; do
-      yum -y install ${Package}
-    done
-  elif [ "${PM}" == 'apt-get' ]; then
-    pkgList="gcc dialog libaugeas0 augeas-lenses libssl-dev libffi-dev ca-certificates"
-    for Package in ${pkgList}; do
-      apt-get -y install $Package
-    done
-  fi
+    if [ "${PM}" == 'yum' ]; then
+      pkgList="gcc dialog augeas-libs openssl openssl-devel libffi-devel redhat-rpm-config ca-certificates"
+      for Package in ${pkgList}; do
+        yum -y install ${Package}
+      done
+    elif [ "${PM}" == 'apt-get' ]; then
+      pkgList="gcc dialog libaugeas0 augeas-lenses libssl-dev libffi-dev ca-certificates"
+      for Package in ${pkgList}; do
+        apt-get -y install $Package
+      done
+    fi
+
+    # Install Python3
+    if [ ! -e "${python_install_dir}/bin/python" -a ! -e "${python_install_dir}/bin/python3" ] ;then
+      src_url=http://mirrors.linuxeye.com/oneinstack/src/Python-${python_ver}.tgz && Download_src
+      tar xzf Python-${python_ver}.tgz
+      pushd Python-${python_ver} > /dev/null
+      ./configure --prefix=${python_install_dir}
+      make && make install
+      [ ! -e "${python_install_dir}/bin/python" -a -e "${python_install_dir}/bin/python3" ] && ln -s ${python_install_dir}/bin/python{3,}
+      [ ! -e "${python_install_dir}/bin/pip" -a -e "${python_install_dir}/bin/pip3" ] && ln -s ${python_install_dir}/bin/pip{3,}
+      popd > /dev/null
+    fi
 
-  # Install Python3
-  if [ ! -e "${python_install_dir}/bin/python" -a ! -e "${python_install_dir}/bin/python3" ] ;then
-    src_url=http://mirrors.linuxeye.com/oneinstack/src/Python-${python_ver}.tgz && Download_src
-    tar xzf Python-${python_ver}.tgz
-    pushd Python-${python_ver} > /dev/null
-    ./configure --prefix=${python_install_dir}
-    make && make install
-    [ ! -e "${python_install_dir}/bin/python" -a -e "${python_install_dir}/bin/python3" ] && ln -s ${python_install_dir}/bin/python{3,}
-    [ ! -e "${python_install_dir}/bin/pip" -a -e "${python_install_dir}/bin/pip3" ] && ln -s ${python_install_dir}/bin/pip{3,}
+    if [ ! -e "/root/.pip/pip.conf" ] ;then
+      # get the IP information
+      PUBLIC_IPADDR=$(../include/get_public_ipaddr.py)
+      IPADDR_COUNTRY=$(../include/get_ipaddr_state.py ${PUBLIC_IPADDR})
+      if [ "${IPADDR_COUNTRY}"x == "CN"x ]; then
+        [ ! -d "/root/.pip" ] && mkdir /root/.pip
+        echo -e "[global]\nindex-url = https://pypi.tuna.tsinghua.edu.cn/simple" > /root/.pip/pip.conf
+      fi
+    fi
+
+    if [ -e "${python_install_dir}/bin/python3" ]; then
+      echo "${CSUCCESS}Python ${python_ver} installed successfully! ${CEND}"
+      rm -rf Python-${python_ver}
+    fi
     popd > /dev/null
-    rm -rf Python-${python_ver}
   fi
+}
 
-  if [ ! -e "/root/.pip/pip.conf" ] ;then
-    # get the IP information
-    PUBLIC_IPADDR=$(../include/get_public_ipaddr.py)
-    IPADDR_COUNTRY=$(../include/get_ipaddr_state.py $PUBLIC_IPADDR)
-    if [ "$IPADDR_COUNTRY"x == "CN"x ]; then
-      [ ! -d "/root/.pip" ] && mkdir /root/.pip
-      echo -e "[global]\nindex-url = https://pypi.tuna.tsinghua.edu.cn/simple" > /root/.pip/pip.conf
-    fi
+Uninstall_Python() {
+  if [ -e "${python_install_dir}/bin/python" ]; then
+    echo; echo "${CMSG}Python uninstall completed${CEND}"
+    rm -rf ${python_install_dir}
+  else
+    echo; echo "${CWARNING}Python does not exist! ${CEND}"
   fi
-  popd > /dev/null
 }

+ 14 - 5
include/redis.sh

@@ -11,7 +11,7 @@
 Install_redis-server() {
   pushd ${oneinstack_dir}/src > /dev/null
   tar xzf redis-${redis_ver}.tar.gz
-  pushd redis-${redis_ver}
+  pushd redis-${redis_ver} > /dev/null
   if [ "${OS_BIT}" == '32' -a "${armplatform}" != 'y' ]; then
     sed -i '1i\CFLAGS= -march=i686' src/Makefile
     sed -i 's@^OPT=.*@OPT=-O2 -march=i686@' src/.make-settings
@@ -30,7 +30,7 @@ Install_redis-server() {
     redis_maxmemory=`expr $Mem / 8`000000
     [ -z "`grep ^maxmemory ${redis_install_dir}/etc/redis.conf`" ] && sed -i "s@maxmemory <bytes>@maxmemory <bytes>\nmaxmemory `expr $Mem / 8`000000@" ${redis_install_dir}/etc/redis.conf
     echo "${CSUCCESS}Redis-server installed successfully! ${CEND}"
-    popd
+    popd > /dev/null
     rm -rf redis-${redis_ver}
     id -u redis >/dev/null 2>&1
     [ $? -ne 0 ] && useradd -M -s /sbin/nologin redis
@@ -54,12 +54,12 @@ Install_redis-server() {
     echo "${CFAILURE}Redis-server install failed, Please contact the author! ${CEND}"
     kill -9 $$
   fi
-  popd
+  popd > /dev/null
 }
 
 Install_pecl-redis() {
-  pushd ${oneinstack_dir}/src > /dev/null
   if [ -e "${php_install_dir}/bin/phpize" ]; then
+    pushd ${oneinstack_dir}/src > /dev/null
     phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
     tar xzf redis-${pecl_redis_ver}.tgz
     pushd redis-${pecl_redis_ver} > /dev/null
@@ -74,6 +74,15 @@ Install_pecl-redis() {
     else
       echo "${CFAILURE}PHP Redis module install failed, Please contact the author! ${CEND}"
     fi
+    popd > /dev/null
+  fi
+}
+
+Uninstall_pecl-redis() {
+  if [ -e "${php_install_dir}/etc/php.d/05-redis.ini" ]; then
+    rm -f ${php_install_dir}/etc/php.d/05-redis.ini
+    echo; echo "${CMSG}PHP redis module uninstall completed${CEND}"
+  else
+    echo; echo "${CWARNING}PHP redis module does not exist! ${CEND}"
   fi
-  popd > /dev/null
 }

+ 37 - 21
include/sourceguardian.sh

@@ -9,28 +9,44 @@
 #       https://github.com/oneinstack/oneinstack
 
 Install_SourceGuardian() {
-  pushd ${oneinstack_dir}/src > /dev/null
-  PHP_detail_ver=`${php_install_dir}/bin/php -r 'echo PHP_VERSION;'`
-  PHP_main_ver=${PHP_detail_ver%.*}
-  phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
-  [ ! -e sourceguardian ] && mkdir sourceguardian
-  if  [ "${TARGET_ARCH}" == "armv8" ]; then
-    tar xzf loaders.linux-aarch64.tar.gz -C sourceguardian
-  else
-    tar xzf loaders.linux-${SYS_BIT_c}.tar.gz -C sourceguardian
-  fi
-  [ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir}
-  if [ -z "`echo ${phpExtensionDir} | grep 'non-zts'`" ]; then
-    /bin/cp sourceguardian/ixed.${PHP_main_ver}ts.lin ${phpExtensionDir}
-    extension="ixed.${PHP_main_ver}ts.lin"
-  else
-    /bin/cp sourceguardian/ixed.${PHP_main_ver}.lin ${phpExtensionDir}
-    extension="ixed.${PHP_main_ver}.lin"
+  if [ -e "${php_install_dir}/bin/phpize" ]; then
+    pushd ${oneinstack_dir}/src > /dev/null
+    PHP_detail_ver=`${php_install_dir}/bin/php -r 'echo PHP_VERSION;'`
+    PHP_main_ver=${PHP_detail_ver%.*}
+    phpExtensionDir=`${php_install_dir}/bin/php-config --extension-dir`
+    if [[ "${PHP_main_ver}" =~ ^5.[3-6]$|^7.[0-2]$ ]] || [ "${TARGET_ARCH}" == "armv8" ]; then
+      [ ! -e sourceguardian ] && mkdir sourceguardian
+      if  [ "${TARGET_ARCH}" == "armv8" ]; then
+        tar xzf loaders.linux-aarch64.tar.gz -C sourceguardian
+      else
+        tar xzf loaders.linux-${SYS_BIT_c}.tar.gz -C sourceguardian
+      fi
+      [ -e "${php_install_dir}/bin/phpize" ] && [ ! -d "${phpExtensionDir}" ] && mkdir -p ${phpExtensionDir}
+      if [ -z "`echo ${phpExtensionDir} | grep 'non-zts'`" ]; then
+        /bin/mv sourceguardian/ixed.${PHP_main_ver}ts.lin ${phpExtensionDir}
+        extension="ixed.${PHP_main_ver}ts.lin"
+      else
+        /bin/mv sourceguardian/ixed.${PHP_main_ver}.lin ${phpExtensionDir}
+        extension="ixed.${PHP_main_ver}.lin"
+      fi
+
+      if [ -f "${phpExtensionDir}/ixed.${PHP_main_ver}.lin" ]; then
+        echo "extension=${extension}" > ${php_install_dir}/etc/php.d/02-sourceguardian.ini
+        echo "${CSUCCESS}PHP SourceGuardian module installed successfully! ${CEND}"
+        rm -rf sourceguardian
+      fi
+    else
+      echo; echo "${CWARNING}Your php ${PHP_detail_ver} or platform ${TARGET_ARCH} does not support SourceGuardian! ${CEND}";
+    fi
+    popd > /dev/null
   fi
+}
 
-  if [ -f "${phpExtensionDir}/ixed.${PHP_main_ver}.lin" ]; then
-    echo "extension=${extension}" > ${php_install_dir}/etc/php.d/02-sourceguardian.ini
-    rm -rf sourceguardian
+Uninstall_SourceGuardian() {
+  if [ -e "${php_install_dir}/etc/php.d/02-sourceguardian.ini" ]; then
+    rm -f ${php_install_dir}/etc/php.d/02-sourceguardian.ini
+    echo; echo "${CMSG}PHP SourceGuardian module uninstall completed${CEND}"
+  else
+    echo; echo "${CWARNING}PHP SourceGuardian module does not exist! ${CEND}"
   fi
-  popd > /dev/null
 }

+ 22 - 24
include/tomcat-6.sh

@@ -70,32 +70,30 @@ EOF
     /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 "${openresty_install_dir}/nginx/sbin/nginx" -a ! -e "${apache_install_dir}/conf/httpd.conf" ]; then
-      if [ "${iptables_yn}" == 'y' ]; then
-        if [ "${PM}" == 'yum' ]; then
-          if [ -z "$(grep -w '8080' /etc/sysconfig/iptables)" ]; then
+    if [ ! -e "${nginx_install_dir}/sbin/nginx" -a ! -e "${tengine_install_dir}/sbin/nginx" -a ! -e "${openresty_install_dir}/nginx/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then
+      if [ "${PM}" == 'yum' ]; then
+        if [ -n "`grep 'dport 80 ' /etc/sysconfig/iptables`" ] && [ -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
+          /bin/cp /etc/sysconfig/{iptables,ip6tables}
+          sed -i 's@icmp@icmpv6@g' /etc/sysconfig/ip6tables
+          ip6tables-restore < /etc/sysconfig/ip6tables
+          service ip6tables save
+        fi
+      elif [ "${PM}" == 'apt-get' ]; then
+        if [ -e '/etc/iptables/rules.v4' ]; then
+          if [ -n "`grep 'dport 80 ' /etc/iptables/rules.v4`" ] && [ -z "$(grep -w '8080' /etc/iptables/rules.v4)" ]; then
             iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-            service iptables save
-            /bin/cp /etc/sysconfig/{iptables,ip6tables}
-            sed -i 's@icmp@icmpv6@g' /etc/sysconfig/ip6tables
-            ip6tables-restore < /etc/sysconfig/ip6tables
-            service ip6tables save
+            iptables-save > /etc/iptables/rules.v4
+            /bin/cp /etc/iptables/rules.v{4,6}
+            sed -i 's@icmp@icmpv6@g' /etc/iptables/rules.v6
+            ip6tables-restore < /etc/iptables/rules.v6
+            ip6tables-save > /etc/iptables/rules.v6
           fi
-        elif [ "${PM}" == 'apt-get' ]; then
-          if [ -e '/etc/iptables/rules.v4' ]; then
-            if [ -z "$(grep -w '8080' /etc/iptables/rules.v4)" ]; then
-              iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-              iptables-save > /etc/iptables/rules.v4
-              /bin/cp /etc/iptables/rules.v{4,6}
-              sed -i 's@icmp@icmpv6@g' /etc/iptables/rules.v6
-              ip6tables-restore < /etc/iptables/rules.v6
-              ip6tables-save > /etc/iptables/rules.v6
-            fi
-          elif [ -e '/etc/iptables.up.rules' ]; 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
+        elif [ -e '/etc/iptables.up.rules' ]; then
+          if [ -n "`grep 'dport 80 ' /etc/iptables.up.rules`" ] && [ -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

+ 22 - 24
include/tomcat-7.sh

@@ -70,32 +70,30 @@ EOF
     /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 "${openresty_install_dir}/nginx/sbin/nginx" -a ! -e "${apache_install_dir}/conf/httpd.conf" ]; then
-      if [ "${iptables_yn}" == 'y' ]; then
-        if [ "${PM}" == 'yum' ]; then
-          if [ -z "$(grep -w '8080' /etc/sysconfig/iptables)" ]; then
+    if [ ! -e "${nginx_install_dir}/sbin/nginx" -a ! -e "${tengine_install_dir}/sbin/nginx" -a ! -e "${openresty_install_dir}/nginx/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then
+      if [ "${PM}" == 'yum' ]; then
+        if [ -n "`grep 'dport 80 ' /etc/sysconfig/iptables`" ] && [ -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
+          /bin/cp /etc/sysconfig/{iptables,ip6tables}
+          sed -i 's@icmp@icmpv6@g' /etc/sysconfig/ip6tables
+          ip6tables-restore < /etc/sysconfig/ip6tables
+          service ip6tables save
+        fi
+      elif [ "${PM}" == 'apt-get' ]; then
+        if [ -e '/etc/iptables/rules.v4' ]; then
+          if [ -n "`grep 'dport 80 ' /etc/iptables/rules.v4`" ] && [ -z "$(grep -w '8080' /etc/iptables/rules.v4)" ]; then
             iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-            service iptables save
-            /bin/cp /etc/sysconfig/{iptables,ip6tables}
-            sed -i 's@icmp@icmpv6@g' /etc/sysconfig/ip6tables
-            ip6tables-restore < /etc/sysconfig/ip6tables
-            service ip6tables save
+            iptables-save > /etc/iptables/rules.v4
+            /bin/cp /etc/iptables/rules.v{4,6}
+            sed -i 's@icmp@icmpv6@g' /etc/iptables/rules.v6
+            ip6tables-restore < /etc/iptables/rules.v6
+            ip6tables-save > /etc/iptables/rules.v6
           fi
-        elif [ "${PM}" == 'apt-get' ]; then
-          if [ -e '/etc/iptables/rules.v4' ]; then
-            if [ -z "$(grep -w '8080' /etc/iptables/rules.v4)" ]; then
-              iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-              iptables-save > /etc/iptables/rules.v4
-              /bin/cp /etc/iptables/rules.v{4,6}
-              sed -i 's@icmp@icmpv6@g' /etc/iptables/rules.v6
-              ip6tables-restore < /etc/iptables/rules.v6
-              ip6tables-save > /etc/iptables/rules.v6
-            fi
-          elif [ -e '/etc/iptables.up.rules' ]; 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
+        elif [ -e '/etc/iptables.up.rules' ]; then
+          if [ -n "`grep 'dport 80 ' /etc/iptables.up.rules`" ] && [ -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

+ 22 - 24
include/tomcat-8.sh

@@ -70,32 +70,30 @@ EOF
     /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 "${openresty_install_dir}/nginx/sbin/nginx" -a ! -e "${apache_install_dir}/conf/httpd.conf" ]; then
-      if [ "${iptables_yn}" == 'y' ]; then
-        if [ "${PM}" == 'yum' ]; then
-          if [ -z "$(grep -w '8080' /etc/sysconfig/iptables)" ]; then
+    if [ ! -e "${nginx_install_dir}/sbin/nginx" -a ! -e "${tengine_install_dir}/sbin/nginx" -a ! -e "${openresty_install_dir}/nginx/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then
+      if [ "${PM}" == 'yum' ]; then
+        if [ -n "`grep 'dport 80 ' /etc/sysconfig/iptables`" ] && [ -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
+          /bin/cp /etc/sysconfig/{iptables,ip6tables}
+          sed -i 's@icmp@icmpv6@g' /etc/sysconfig/ip6tables
+          ip6tables-restore < /etc/sysconfig/ip6tables
+          service ip6tables save
+        fi
+      elif [ "${PM}" == 'apt-get' ]; then
+        if [ -e '/etc/iptables/rules.v4' ]; then
+          if [ -n "`grep 'dport 80 ' /etc/iptables/rules.v4`" ] && [ -z "$(grep -w '8080' /etc/iptables/rules.v4)" ]; then
             iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-            service iptables save
-            /bin/cp /etc/sysconfig/{iptables,ip6tables}
-            sed -i 's@icmp@icmpv6@g' /etc/sysconfig/ip6tables
-            ip6tables-restore < /etc/sysconfig/ip6tables
-            service ip6tables save
+            iptables-save > /etc/iptables/rules.v4
+            /bin/cp /etc/iptables/rules.v{4,6}
+            sed -i 's@icmp@icmpv6@g' /etc/iptables/rules.v6
+            ip6tables-restore < /etc/iptables/rules.v6
+            ip6tables-save > /etc/iptables/rules.v6
           fi
-        elif [ "${PM}" == 'apt-get' ]; then
-          if [ -e '/etc/iptables/rules.v4' ]; then
-            if [ -z "$(grep -w '8080' /etc/iptables/rules.v4)" ]; then
-              iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-              iptables-save > /etc/iptables/rules.v4
-              /bin/cp /etc/iptables/rules.v{4,6}
-              sed -i 's@icmp@icmpv6@g' /etc/iptables/rules.v6
-              ip6tables-restore < /etc/iptables/rules.v6
-              ip6tables-save > /etc/iptables/rules.v6
-            fi
-          elif [ -e '/etc/iptables.up.rules' ]; 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
+        elif [ -e '/etc/iptables.up.rules' ]; then
+          if [ -n "`grep 'dport 80 ' /etc/iptables.up.rules`" ] && [ -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

+ 22 - 24
include/tomcat-9.sh

@@ -70,32 +70,30 @@ EOF
     /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 "${openresty_install_dir}/nginx/sbin/nginx" -a ! -e "${apache_install_dir}/conf/httpd.conf" ]; then
-      if [ "${iptables_yn}" == 'y' ]; then
-        if [ "${PM}" == 'yum' ]; then
-          if [ -z "$(grep -w '8080' /etc/sysconfig/iptables)" ]; then
+    if [ ! -e "${nginx_install_dir}/sbin/nginx" -a ! -e "${tengine_install_dir}/sbin/nginx" -a ! -e "${openresty_install_dir}/nginx/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then
+      if [ "${PM}" == 'yum' ]; then
+        if [ -n "`grep 'dport 80 ' /etc/sysconfig/iptables`" ] && [ -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
+          /bin/cp /etc/sysconfig/{iptables,ip6tables}
+          sed -i 's@icmp@icmpv6@g' /etc/sysconfig/ip6tables
+          ip6tables-restore < /etc/sysconfig/ip6tables
+          service ip6tables save
+        fi
+      elif [ "${PM}" == 'apt-get' ]; then
+        if [ -e '/etc/iptables/rules.v4' ]; then
+          if [ -n "`grep 'dport 80 ' /etc/iptables/rules.v4`" ] && [ -z "$(grep -w '8080' /etc/iptables/rules.v4)" ]; then
             iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-            service iptables save
-            /bin/cp /etc/sysconfig/{iptables,ip6tables}
-            sed -i 's@icmp@icmpv6@g' /etc/sysconfig/ip6tables
-            ip6tables-restore < /etc/sysconfig/ip6tables
-            service ip6tables save
+            iptables-save > /etc/iptables/rules.v4
+            /bin/cp /etc/iptables/rules.v{4,6}
+            sed -i 's@icmp@icmpv6@g' /etc/iptables/rules.v6
+            ip6tables-restore < /etc/iptables/rules.v6
+            ip6tables-save > /etc/iptables/rules.v6
           fi
-        elif [ "${PM}" == 'apt-get' ]; then
-          if [ -e '/etc/iptables/rules.v4' ]; then
-            if [ -z "$(grep -w '8080' /etc/iptables/rules.v4)" ]; then
-              iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
-              iptables-save > /etc/iptables/rules.v4
-              /bin/cp /etc/iptables/rules.v{4,6}
-              sed -i 's@icmp@icmpv6@g' /etc/iptables/rules.v6
-              ip6tables-restore < /etc/iptables/rules.v6
-              ip6tables-save > /etc/iptables/rules.v6
-            fi
-          elif [ -e '/etc/iptables.up.rules' ]; 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
+        elif [ -e '/etc/iptables.up.rules' ]; then
+          if [ -n "`grep 'dport 80 ' /etc/iptables.up.rules`" ] && [ -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

+ 1 - 1
include/upgrade_memcached.sh

@@ -19,7 +19,7 @@ Upgrade_Memcached() {
     [ "${memcached_quiet}" != 'y' ] && read -e -p "Please input upgrade Memcached Version(default: ${Latest_memcached_ver}): " NEW_memcached_ver
     NEW_memcached_ver=${NEW_memcached_ver:-${Latest_memcached_ver}}
     if [ "${NEW_memcached_ver}" != "${OLD_memcached_ver}" ]; then
-      [ "$IPADDR_COUNTRY"x == "CN"x ] && DOWN_ADDR=http://mirrors.linuxeye.com/oneinstack/src || DOWN_ADDR=http://www.memcached.org/files
+      [ "${IPADDR_COUNTRY}"x == "CN"x ] && DOWN_ADDR=http://mirrors.linuxeye.com/oneinstack/src || DOWN_ADDR=http://www.memcached.org/files
       [ ! -e "memcached-${NEW_memcached_ver}.tar.gz" ] && wget --no-check-certificate -c ${DOWN_ADDR}/memcached-${NEW_memcached_ver}.tar.gz > /dev/null 2>&1
       if [ -e "memcached-${NEW_memcached_ver}.tar.gz" ]; then
         echo "Download [${CMSG}memcached-${NEW_memcached_ver}.tar.gz${CEND}] successfully! "

+ 36 - 19
include/xcache.sh

@@ -9,21 +9,25 @@
 #       https://github.com/oneinstack/oneinstack
 
 Install_XCache() {
-  pushd ${oneinstack_dir}/src > /dev/null
-  phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
-  tar xzf xcache-${xcache_ver}.tar.gz
-  pushd xcache-${xcache_ver} > /dev/null
-  ${php_install_dir}/bin/phpize
-  ./configure --enable-xcache --enable-xcache-coverager --enable-xcache-optimizer --with-php-config=${php_install_dir}/bin/php-config
-  make -j ${THREAD} && make install
-  if [ -f "${phpExtensionDir}/xcache.so" ]; then
-    /bin/cp -R htdocs ${wwwroot_dir}/default/xcache
-    popd > /dev/null
-    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/04-xcache.ini << EOF
+  if [ -e "${php_install_dir}/bin/phpize" ]; then
+    pushd ${oneinstack_dir}/src > /dev/null
+    phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
+    PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
+    PHP_main_ver=${PHP_detail_ver%.*}
+    if [[ "${PHP_main_ver}" =~ ^5.[3-6]$ ]]; then
+      tar xzf xcache-${xcache_ver}.tar.gz
+      pushd xcache-${xcache_ver} > /dev/null
+      ${php_install_dir}/bin/phpize
+      ./configure --enable-xcache --enable-xcache-coverager --enable-xcache-optimizer --with-php-config=${php_install_dir}/bin/php-config
+      make -j ${THREAD} && make install
+      if [ -f "${phpExtensionDir}/xcache.so" ]; then
+        /bin/cp -R htdocs ${wwwroot_dir}/default/xcache
+        popd > /dev/null
+        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/04-xcache.ini << EOF
 [xcache-common]
 extension=xcache.so
 [xcache.admin]
@@ -60,10 +64,23 @@ xcache.coverager = Off
 xcache.coverager_autostart = On
 xcache.coveragedump_directory = ""
 EOF
-    echo "${CSUCCESS}Xcache module installed successfully! ${CEND}"
-    rm -rf xcache-${xcache_ver}
+        echo "${CSUCCESS}PHP xcache module installed successfully! ${CEND}"
+        rm -rf xcache-${xcache_ver}
+      else
+        echo "${CFAILURE}PHP xcache module install failed, Please contact the author! ${CEND}"
+      fi
+    else
+      echo; echo "${CWARNING}Your php ${PHP_detail_ver} does not support XCache! ${CEND}";
+    fi
+    popd > /dev/null
+  fi
+}
+
+Uninstall_XCache() {
+  if [ -e "${php_install_dir}/etc/php.d/04-xcache.ini" ]; then
+    rm -rf ${php_install_dir}/etc/php.d/04-xcache.ini ${wwwroot_dir}/default/xcache /tmp/xcache
+    echo; echo "${CMSG}PHP xcache module uninstall completed${CEND}"
   else
-    echo "${CFAILURE}Xcache module install failed, Please contact the author! ${CEND}"
+    echo; echo "${CWARNING}PHP xcache module does not exist! ${CEND}"
   fi
-  popd > /dev/null 
 }

+ 40 - 27
include/zendopcache.sh

@@ -9,27 +9,29 @@
 #       https://github.com/oneinstack/oneinstack
 
 Install_ZendOPcache() {
-  pushd ${oneinstack_dir}/src > /dev/null
-  phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
-  PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
-  PHP_main_ver=${PHP_detail_ver%.*}
-  if [[ "${PHP_main_ver}" =~ ^5.[3-4]$ ]]; then
-    tar xzf zendopcache-${zendopcache_ver}.tgz
-    pushd zendopcache-${zendopcache_ver}
-  else
-    tar xzf php-${PHP_detail_ver}.tar.gz
-    pushd php-${PHP_detail_ver}/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
-    # write opcache configs
+  if [ -e "${php_install_dir}/bin/phpize" ]; then
+    pushd ${oneinstack_dir}/src > /dev/null
+    phpExtensionDir=$(${php_install_dir}/bin/php-config --extension-dir)
+    PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
+    PHP_main_ver=${PHP_detail_ver%.*}
     if [[ "${PHP_main_ver}" =~ ^5.[3-4]$ ]]; then
-      # For php 5.3 5.4
-      cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF
+      tar xzf zendopcache-${zendopcache_ver}.tgz
+      pushd zendopcache-${zendopcache_ver} > /dev/null
+    else
+      src_url=http://www.php.net/distributions/php-${PHP_detail_ver}.tar.gz && Download_src
+      tar xzf php-${PHP_detail_ver}.tar.gz
+      pushd php-${PHP_detail_ver}/ext/opcache > /dev/null
+    fi
+
+    ${php_install_dir}/bin/phpize
+    ./configure --with-php-config=${php_install_dir}/bin/php-config
+    make -j ${THREAD} && make install
+    popd > /dev/null
+    if [ -f "${phpExtensionDir}/opcache.so" ]; then
+      # write opcache configs
+      if [[ "${PHP_main_ver}" =~ ^5.[3-4]$ ]]; then
+        # For php 5.3 5.4
+        cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF
 [opcache]
 zend_extension=${phpExtensionDir}/opcache.so
 opcache.enable=1
@@ -42,9 +44,10 @@ 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/02-opcache.ini << EOF
+        rm -rf zendopcache-${zendopcache_ver}
+      else
+        # For php 5.5+
+        cat > ${php_install_dir}/etc/php.d/02-opcache.ini << EOF
 [opcache]
 zend_extension=opcache.so
 opcache.enable=1
@@ -61,12 +64,22 @@ opcache.fast_shutdown=1
 opcache.consistency_checks=0
 ;opcache.optimization_level=0
 EOF
+      fi
+
+      echo "${CSUCCESS}PHP opcache module installed successfully! ${CEND}"
+      rm -rf php-${PHP_detail_ver}
+    else
+      echo "${CFAILURE}PHP opcache module install failed, Please contact the author! ${CEND}"
     fi
+    popd > /dev/null
+  fi
+}
 
-    echo "${CSUCCESS}PHP OPcache module installed successfully! ${CEND}"
-    rm -rf zendopcache-${zendopcache_ver} php-${PHP_detail_ver}
+Uninstall_ZendOPcache() {
+  if [ -e "${php_install_dir}/etc/php.d/02-opcache.ini" ]; then
+    rm -f ${php_install_dir}/etc/php.d/02-opcache.ini
+    echo; echo "${CMSG}PHP opcache module uninstall completed${CEND}"
   else
-    echo "${CFAILURE}PHP OPcache module install failed, Please contact the author! ${CEND}"
+    echo; echo "${CWARNING}PHP opcache module does not exist! ${CEND}"
   fi
-  popd
 }

+ 2 - 2
init.d/nginx.service

@@ -9,8 +9,8 @@ PIDFile=/var/run/nginx.pid
 ExecStartPost=/bin/sleep 0.1
 ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
 ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
-ExecReload=/usr/local/nginx/sbin/nginx -s reload
-ExecStop=/usr/local/nginx/sbin/nginx -s stop
+ExecReload=/bin/kill -s HUP $MAINPID
+ExecStop=/bin/kill -s QUIT $MAINPID
 LimitNOFILE=1000000
 LimitNPROC=1000000
 LimitCORE=1000000

+ 1 - 1
init.d/panel.service

@@ -3,7 +3,7 @@ Description=OneinStack Panel daemon
 After=network.target
 
 [Service]
-PIDFile=/root/git/repo/panel/logs/runconfig.py.pid
+PIDFile=/var/run/panel.pid
 WorkingDirectory=/root/git/repo/panel
 ExecStart=/usr/local/python/bin/gunicorn -c runconfig.py panel.wsgi:application
 ExecReload=/bin/kill -s HUP $MAINPID

+ 246 - 189
install.sh

@@ -50,7 +50,9 @@ showhelp() {
   --apache_option [1-2]       Install Apache server version
   --php_option [1-8]          Install PHP version
   --phpcache_option [1-4]     Install PHP opcode cache, default: 1 opcache
-  --php_extensions [ext name] Install PHP extension, include zendguardloader,ioncube,sourceguardian,imagick,gmagick,redis,memcached,memcache,mongodb
+  --php_extensions [ext name] Install PHP extensions, include zendguardloader,ioncube,
+                              sourceguardian,imagick,gmagick,fileinfo,imap,phalcon,
+                              redis,memcached,memcache,mongodb,swoole,xdebug
   --tomcat_option [1-4]       Install Tomcat version
   --jdk_option [1-4]          Install JDK version
   --db_option [1-15]          Install DB version
@@ -91,7 +93,7 @@ while :; do
       apache_option=$2; shift 2
       [[ ! ${apache_option} =~ ^[1-2]$ ]] && { echo "${CWARNING}apache_option input error! Please only input number 1~2${CEND}"; exit 1; }
       web_yn=y
-      [ -e "${apache_install_dir}/conf/httpd.conf" ] && { echo "${CWARNING}Aapche already installed! ${CEND}"; apache_option=Other; }
+      [ -e "${apache_install_dir}/bin/httpd" ] && { echo "${CWARNING}Aapche already installed! ${CEND}"; apache_option=Other; }
       ;;
     --php_option)
       php_option=$2; shift 2
@@ -104,15 +106,20 @@ while :; do
       ;;
     --php_extensions)
       php_extensions=$2; shift 2
-      [ -n "`echo ${php_extensions} | grep -w zendguardloader`" ] && zendguardloader_yn=y
-      [ -n "`echo ${php_extensions} | grep -w ioncube`" ] && ioncube_yn=y
-      [ -n "`echo ${php_extensions} | grep -w sourceguardian`" ] && sourceguardian_yn=y
-      [ -n "`echo ${php_extensions} | grep -w imagick`" ] && magick_option=1
-      [ -n "`echo ${php_extensions} | grep -w gmagick`" ] && magick_option=2
+      [ -n "`echo ${php_extensions} | grep -w zendguardloader`" ] && pecl_zendguardloader=1
+      [ -n "`echo ${php_extensions} | grep -w ioncube`" ] && pecl_ioncube=1
+      [ -n "`echo ${php_extensions} | grep -w sourceguardian`" ] && pecl_sourceguardian=1
+      [ -n "`echo ${php_extensions} | grep -w imagick`" ] && pecl_imagick=1
+      [ -n "`echo ${php_extensions} | grep -w gmagick`" ] && pecl_gmagick=1
+      [ -n "`echo ${php_extensions} | grep -w fileinfo`" ] && pecl_fileinfo=1
+      [ -n "`echo ${php_extensions} | grep -w imap`" ] && pecl_imap=1
+      [ -n "`echo ${php_extensions} | grep -w phalcon`" ] && pecl_phalcon=1
       [ -n "`echo ${php_extensions} | grep -w redis`" ] && pecl_redis=1
       [ -n "`echo ${php_extensions} | grep -w memcached`" ] && pecl_memcached=1
       [ -n "`echo ${php_extensions} | grep -w memcache`" ] && pecl_memcache=1
       [ -n "`echo ${php_extensions} | grep -w mongodb`" ] && pecl_mongodb=1
+      [ -n "`echo ${php_extensions} | grep -w swoole`" ] && pecl_swoole=1
+      [ -n "`echo ${php_extensions} | grep -w xdebug`" ] && pecl_xdebug=1
       ;;
     --tomcat_option)
       tomcat_option=$2; shift 2
@@ -153,9 +160,11 @@ while :; do
       ;;
     --redis)
       redis_yn=y; shift 1
+      [ -e "${redis_install_dir}/bin/redis-server" ] && { echo "${CWARNING}redis-server already installed! ${CEND}"; redis_yn=Other; }
       ;;
     --memcached)
       memcached_yn=y; shift 1
+      [ -e "${memcached_install_dir}/bin/memcached" ] && { echo "${CWARNING}memcached-server already installed! ${CEND}"; memcached_yn=Other; }
       ;;
     --phpmyadmin)
       phpmyadmin_yn=y; shift 1
@@ -209,15 +218,17 @@ if [ -e "/etc/ssh/sshd_config" ]; then
 fi
 
 if [ ${ARG_NUM} == 0 ]; then
-  # check iptables
-  while :; do echo
-    read -e -p "Do you want to enable iptables? [y/n]: " iptables_yn
-    if [[ ! ${iptables_yn} =~ ^[y,n]$ ]]; then
-      echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
-    else
-      break
-    fi
-  done
+  if [ ! -e ~/.oneinstack ]; then
+    # check iptables
+    while :; do echo
+      read -e -p "Do you want to enable iptables? [y/n]: " iptables_yn
+      if [[ ! ${iptables_yn} =~ ^[y,n]$ ]]; then
+        echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+      else
+        break
+      fi
+    done
+  fi
 
   # check Web server
   while :; do echo
@@ -255,7 +266,7 @@ if [ ${ARG_NUM} == 0 ]; then
           if [[ ! ${apache_option} =~ ^[1-3]$ ]]; then
             echo "${CWARNING}input error! Please only input number 1~3${CEND}"
           else
-            [ "${apache_option}" != '3' -a -e "${apache_install_dir}/conf/httpd.conf" ] && { echo "${CWARNING}Aapche already installed! ${CEND}"; apache_option=Other; }
+            [ "${apache_option}" != '3' -a -e "${apache_install_dir}/bin/httpd" ] && { echo "${CWARNING}Aapche already installed! ${CEND}"; apache_option=Other; }
             break
           fi
         done
@@ -422,7 +433,7 @@ if [ ${ARG_NUM} == 0 ]; then
     fi
   done
 
-  # check PHP
+  # choice php
   while :; do echo
     read -e -p "Do you want to install PHP? [y/n]: " php_yn
     if [[ ! ${php_yn} =~ ^[y,n]$ ]]; then
@@ -445,153 +456,166 @@ if [ ${ARG_NUM} == 0 ]; then
           if [[ ! ${php_option} =~ ^[1-8]$ ]]; then
             echo "${CWARNING}input error! Please only input number 1~8${CEND}"
           else
-            while :; do echo
-              read -e -p "Do you want to install opcode cache of the PHP? [y/n]: " phpcache_yn
-              if [[ ! ${phpcache_yn} =~ ^[y,n]$ ]]; then
-                echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+            break
+          fi
+        done
+      fi
+      break
+    fi
+  done
+
+  # check php ver
+  if [ -e "${php_install_dir}/bin/phpize" ]; then
+    PHP_detail_ver=$(${php_install_dir}/bin/php -r 'echo PHP_VERSION;')
+    PHP_main_ver=${PHP_detail_ver%.*}
+  fi
+
+  # PHP opcode cache and extensions
+  if [[ ${php_option} =~ ^[1-8]$ ]] || [ -e "${php_install_dir}/bin/phpize" ]; then
+    while :; do echo
+      read -e -p "Do you want to install opcode cache of the PHP? [y/n]: " phpcache_yn
+      if [[ ! ${phpcache_yn} =~ ^[y,n]$ ]]; then
+        echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+      else
+        if [ "${phpcache_yn}" == 'y' ]; then
+          if [ "${php_option}" == '1' -o "${PHP_main_ver}" == '5.3' ]; then
+            while :; do
+              echo 'Please select a opcode cache of the PHP:'
+              echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
+              echo -e "\t${CMSG}2${CEND}. Install XCache"
+              echo -e "\t${CMSG}3${CEND}. Install APCU"
+              echo -e "\t${CMSG}4${CEND}. Install eAccelerator-0.9"
+              read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
+              phpcache_option=${phpcache_option:-1}
+              if [[ ! ${phpcache_option} =~ ^[1-4]$ ]]; then
+                echo "${CWARNING}input error! Please only input number 1~4${CEND}"
               else
-                if [ "${phpcache_yn}" == 'y' ]; then
-                  if [ ${php_option} == 1 ]; then
-                    while :; do
-                      echo 'Please select a opcode cache of the PHP:'
-                      echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
-                      echo -e "\t${CMSG}2${CEND}. Install XCache"
-                      echo -e "\t${CMSG}3${CEND}. Install APCU"
-                      echo -e "\t${CMSG}4${CEND}. Install eAccelerator-0.9"
-                      read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
-                      phpcache_option=${phpcache_option:-1}
-                      if [[ ! ${phpcache_option} =~ ^[1-4]$ ]]; then
-                        echo "${CWARNING}input error! Please only input number 1~4${CEND}"
-                      else
-                        break
-                      fi
-                    done
-                  fi
-                  if [ ${php_option} == 2 ]; then
-                    while :; do
-                      echo 'Please select a opcode cache of the PHP:'
-                      echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
-                      echo -e "\t${CMSG}2${CEND}. Install XCache"
-                      echo -e "\t${CMSG}3${CEND}. Install APCU"
-                      echo -e "\t${CMSG}4${CEND}. Install eAccelerator-1.0-dev"
-                      read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
-                      phpcache_option=${phpcache_option:-1}
-                      if [[ ! ${phpcache_option} =~ ^[1-4]$ ]]; then
-                        echo "${CWARNING}input error! Please only input number 1~4${CEND}"
-                      else
-                        break
-                      fi
-                    done
-                  fi
-                  if [ ${php_option} == 3 ]; then
-                    while :; do
-                      echo 'Please select a opcode cache of the PHP:'
-                      echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
-                      echo -e "\t${CMSG}2${CEND}. Install XCache"
-                      echo -e "\t${CMSG}3${CEND}. Install APCU"
-                      read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
-                      phpcache_option=${phpcache_option:-1}
-                      if [[ ! ${phpcache_option} =~ ^[1-3]$ ]]; then
-                        echo "${CWARNING}input error! Please only input number 1~3${CEND}"
-                      else
-                        break
-                      fi
-                    done
-                  fi
-                  if [ ${php_option} == 4 ]; then
-                    while :; do
-                      echo 'Please select a opcode cache of the PHP:'
-                      echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
-                      echo -e "\t${CMSG}2${CEND}. Install XCache"
-                      echo -e "\t${CMSG}3${CEND}. Install APCU"
-                      read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
-                      phpcache_option=${phpcache_option:-1}
-                      if [[ ! ${phpcache_option} =~ ^[1-3]$ ]]; then
-                        echo "${CWARNING}input error! Please only input number 1~3${CEND}"
-                      else
-                        break
-                      fi
-                    done
-                  fi
-                  if [[ ${php_option} =~ ^[5-6]$ ]]; then
-                    while :; do
-                      echo 'Please select a opcode cache of the PHP:'
-                      echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
-                      echo -e "\t${CMSG}3${CEND}. Install APCU"
-                      read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
-                      phpcache_option=${phpcache_option:-1}
-                      if [[ ! ${phpcache_option} =~ ^[1,3]$ ]]; then
-                        echo "${CWARNING}input error! Please only input number 1,3${CEND}"
-                      else
-                        break
-                      fi
-                    done
-                  fi
-                  [[ ${php_option} =~ ^[7-8]$ ]] && phpcache_option=1
-                fi
                 break
               fi
             done
-            if [ "${phpcache_option}" == '2' ]; then
-              while :; do
-                read -e -p "Please input xcache admin password: " xcachepwd
-                (( ${#xcachepwd} >= 5 )) && { xcachepwd_md5=$(echo -n "${xcachepwd}" | md5sum | awk '{print $1}') ; break ; } || echo "${CFAILURE}xcache admin password least 5 characters! ${CEND}"
-              done
-            fi
-            if [[ ${php_option} =~ ^[1-4]$ ]] && [ "${phpcache_option}" != '1' -a "${armplatform}" != "y" ]; then
-              while :; do echo
-                read -e -p "Do you want to install ZendGuardLoader? [y/n]: " zendguardloader_yn
-                if [[ ! ${zendguardloader_yn} =~ ^[y,n]$ ]]; then
-                  echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
-                else
-                  break
-                fi
-              done
-            fi
-
-            # ionCube
-            if [ "${TARGET_ARCH}" != "arm64" ]; then
-              while :; do echo
-                read -e -p "Do you want to install ionCube? [y/n]: " ioncube_yn
-                if [[ ! ${ioncube_yn} =~ ^[y,n]$ ]]; then
-                  echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
-                else
-                  break
-                fi
-              done
-            fi
-
-            # ImageMagick or GraphicsMagick
-            while :; do echo
-              read -e -p "Do you want to install ImageMagick or GraphicsMagick? [y/n]: " magick_yn
-              if [[ ! ${magick_yn} =~ ^[y,n]$ ]]; then
-                echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+          fi
+          if [ "${php_option}" == '2' -o "${PHP_main_ver}" == '5.4' ]; then
+            while :; do
+              echo 'Please select a opcode cache of the PHP:'
+              echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
+              echo -e "\t${CMSG}2${CEND}. Install XCache"
+              echo -e "\t${CMSG}3${CEND}. Install APCU"
+              echo -e "\t${CMSG}4${CEND}. Install eAccelerator-1.0-dev"
+              read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
+              phpcache_option=${phpcache_option:-1}
+              if [[ ! ${phpcache_option} =~ ^[1-4]$ ]]; then
+                echo "${CWARNING}input error! Please only input number 1~4${CEND}"
               else
                 break
               fi
             done
-
-            if [ "${magick_yn}" == 'y' ]; then
-              while :; do
-                echo 'Please select ImageMagick or GraphicsMagick:'
-                echo -e "\t${CMSG}1${CEND}. Install ImageMagick"
-                echo -e "\t${CMSG}2${CEND}. Install GraphicsMagick"
-                read -e -p "Please input a number:(Default 1 press Enter) " magick_option
-                magick_option=${magick_option:-1}
-                if [[ ! ${magick_option} =~ ^[1-2]$ ]]; then
-                  echo "${CWARNING}input error! Please only input number 1~2${CEND}"
-                else
-                  break
-                fi
-              done
-            fi
-            break
           fi
-        done
+          if [ "${php_option}" == '3' -o "${PHP_main_ver}" == '5.5' ]; then
+            while :; do
+              echo 'Please select a opcode cache of the PHP:'
+              echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
+              echo -e "\t${CMSG}2${CEND}. Install XCache"
+              echo -e "\t${CMSG}3${CEND}. Install APCU"
+              read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
+              phpcache_option=${phpcache_option:-1}
+              if [[ ! ${phpcache_option} =~ ^[1-3]$ ]]; then
+                echo "${CWARNING}input error! Please only input number 1~3${CEND}"
+              else
+                break
+              fi
+            done
+          fi
+          if [ "${php_option}" == '4' -o "${PHP_main_ver}" == '5.6' ]; then
+            while :; do
+              echo 'Please select a opcode cache of the PHP:'
+              echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
+              echo -e "\t${CMSG}2${CEND}. Install XCache"
+              echo -e "\t${CMSG}3${CEND}. Install APCU"
+              read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
+              phpcache_option=${phpcache_option:-1}
+              if [[ ! ${phpcache_option} =~ ^[1-3]$ ]]; then
+                echo "${CWARNING}input error! Please only input number 1~3${CEND}"
+              else
+                break
+              fi
+            done
+          fi
+          if [[ ${php_option} =~ ^[5-8]$ ]] || [[ "${PHP_main_ver}" =~ ^7.[0-3]$ ]]; then 
+            while :; do
+              echo 'Please select a opcode cache of the PHP:'
+              echo -e "\t${CMSG}1${CEND}. Install Zend OPcache"
+              echo -e "\t${CMSG}3${CEND}. Install APCU"
+              read -e -p "Please input a number:(Default 1 press Enter) " phpcache_option
+              phpcache_option=${phpcache_option:-1}
+              if [[ ! ${phpcache_option} =~ ^[1,3]$ ]]; then
+                echo "${CWARNING}input error! Please only input number 1,3${CEND}"
+              else
+                break
+              fi
+            done
+          fi
+        fi
+        break
       fi
-      break
+    done
+    # set xcache passwd
+    if [ "${phpcache_option}" == '2' ]; then
+      while :; do
+        read -e -p "Please input xcache admin password: " xcachepwd
+        (( ${#xcachepwd} >= 5 )) && { xcachepwd_md5=$(echo -n "${xcachepwd}" | md5sum | awk '{print $1}') ; break ; } || echo "${CFAILURE}xcache admin password least 5 characters! ${CEND}"
+      done
     fi
-  done
+    # PHP extension
+    while :; do
+      echo
+      echo 'Please select PHP extensions:'
+      echo -e "\t${CMSG} 0${CEND}. Do not install"
+      echo -e "\t${CMSG} 1${CEND}. Install zendguardloader(PHP<=5.6)"
+      echo -e "\t${CMSG} 2${CEND}. Install ioncube"
+      echo -e "\t${CMSG} 3${CEND}. Install sourceguardian(PHP<=7.2)"
+      echo -e "\t${CMSG} 4${CEND}. Install imagick"
+      echo -e "\t${CMSG} 5${CEND}. Install gmagick"
+      echo -e "\t${CMSG} 6${CEND}. Install fileinfo"
+      echo -e "\t${CMSG} 7${CEND}. Install imap"
+      echo -e "\t${CMSG} 8${CEND}. Install phalcon(PHP>=5.5)"
+      echo -e "\t${CMSG} 9${CEND}. Install redis"
+      echo -e "\t${CMSG}10${CEND}. Install memcached"
+      echo -e "\t${CMSG}11${CEND}. Install memcache(PHP<=7.2)"
+      echo -e "\t${CMSG}12${CEND}. Install mongodb"
+      echo -e "\t${CMSG}13${CEND}. Install swoole"
+      echo -e "\t${CMSG}14${CEND}. Install xdebug(PHP>=5.5)"
+      read -e -p "Please input numbers:(Default '4 9 10 11' press Enter) " phpext_option
+      phpext_option=${phpext_option:-'4 9 10 11'}
+      [ "${phpext_option}" == '0' ] && break
+      array_phpext=(${phpext_option})
+      array_all=(1 2 3 4 5 6 7 8 9 10 11 12 13 14)
+      for v in ${array_phpext[@]}
+      do
+        [ -z "`echo ${array_all[@]} | grep -w ${v}`" ] && phpext_flag=1
+      done
+      if [ "${phpext_flag}" == '1' ]; then
+        unset phpext_flag
+        echo; echo "${CWARNING}input error! Please only input number 4 9 10 11 and so on${CEND}"; echo
+        continue
+      else
+        [ -n "`echo ${array_phpext[@]} | grep -w 1`" ] && pecl_zendguardloader=1
+        [ -n "`echo ${array_phpext[@]} | grep -w 2`" ] && pecl_ioncube=1
+        [ -n "`echo ${array_phpext[@]} | grep -w 3`" ] && pecl_sourceguardian=1
+        [ -n "`echo ${array_phpext[@]} | grep -w 4`" ] && pecl_imagick=1
+        [ -n "`echo ${array_phpext[@]} | grep -w 5`" ] && pecl_gmagick=1
+        [ -n "`echo ${array_phpext[@]} | grep -w 6`" ] && pecl_fileinfo=1
+        [ -n "`echo ${array_phpext[@]} | grep -w 7`" ] && pecl_imap=1
+        [ -n "`echo ${array_phpext[@]} | grep -w 8`" ] && pecl_phalcon=1
+        [ -n "`echo ${array_phpext[@]} | grep -w 9`" ] && pecl_redis=1
+        [ -n "`echo ${array_phpext[@]} | grep -w 10`" ] && pecl_memcached=1
+        [ -n "`echo ${array_phpext[@]} | grep -w 11`" ] && pecl_memcache=1
+        [ -n "`echo ${array_phpext[@]} | grep -w 12`" ] && pecl_mongodb=1
+        [ -n "`echo ${array_phpext[@]} | grep -w 13`" ] && pecl_swoole=1
+        [ -n "`echo ${array_phpext[@]} | grep -w 14`" ] && pecl_xdebug=1
+        break
+      fi
+    done
+  fi
 
   # check Pureftpd
   while :; do echo
@@ -619,20 +643,22 @@ if [ ${ARG_NUM} == 0 ]; then
 
   # check redis
   while :; do echo
-    read -e -p "Do you want to install redis? [y/n]: " redis_yn
+    read -e -p "Do you want to install redis-server? [y/n]: " redis_yn
     if [[ ! ${redis_yn} =~ ^[y,n]$ ]]; then
       echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
     else
+      [ "${redis_yn}" == 'y' -a -e "${redis_install_dir}/bin/redis-server" ] && { echo "${CWARNING}redis-server already installed! ${CEND}"; redis_yn=Other; }
       break
     fi
   done
 
   # check memcached
   while :; do echo
-    read -e -p "Do you want to install memcached? [y/n]: " memcached_yn
+    read -e -p "Do you want to install memcached-server? [y/n]: " memcached_yn
     if [[ ! ${memcached_yn} =~ ^[y,n]$ ]]; then
       echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
     else
+      [ "${memcached_yn}" == 'y' -a -e "${memcached_install_dir}/bin/memcached" ] && { echo "${CWARNING}memcached-server already installed! ${CEND}"; memcached_yn=Other; }
       break
     fi
   done
@@ -660,12 +686,12 @@ if [ ${ARG_NUM} == 0 ]; then
 fi
 
 # install wget gcc curl python
-${PM} -y -q install wget gcc curl python
+[ ! -e ~/.oneinstack ] && ${PM} -y -q install wget gcc curl python
 
 # get the IP information
 IPADDR=$(./include/get_ipaddr.py)
 PUBLIC_IPADDR=$(./include/get_public_ipaddr.py)
-IPADDR_COUNTRY=$(./include/get_ipaddr_state.py $PUBLIC_IPADDR)
+IPADDR_COUNTRY=$(./include/get_ipaddr_state.py ${PUBLIC_IPADDR})
 
 # Check download source packages
 . ./include/check_download.sh
@@ -711,8 +737,8 @@ if [[ ${nginx_option} =~ ^[1-3]$ ]] || [ "${db_yn}" == 'y' ]; then
 fi
 
 # openSSL
-. ./include/openssl.sh
 if [[ ${tomcat_option} =~ ^[1-4]$ ]] || [[ ${apache_option} =~ ^[1-2]$ ]] || [[ ${php_option} =~ ^[1-8]$ ]]; then
+  . include/openssl.sh
   Install_openSSL | tee -a ${oneinstack_dir}/install.log
 fi
 
@@ -845,10 +871,8 @@ esac
 # PHP opcode cache
 case "${phpcache_option}" in
   1)
-    if [[ "${php_option}" =~ ^[1-2]$ ]]; then
-      . include/zendopcache.sh
-      Install_ZendOPcache 2>&1 | tee -a ${oneinstack_dir}/install.log
-    fi
+    . include/zendopcache.sh
+    Install_ZendOPcache 2>&1 | tee -a ${oneinstack_dir}/install.log
     ;;
   2)
     . include/xcache.sh
@@ -859,42 +883,61 @@ case "${phpcache_option}" in
     Install_APCU 2>&1 | tee -a ${oneinstack_dir}/install.log
     ;;
   4)
-    if [[ "${php_option}" =~ ^[1-2]$ ]]; then
-      . include/eaccelerator.sh
-      Install_eAccelerator 2>&1 | tee -a ${oneinstack_dir}/install.log
-    fi
+    . include/eaccelerator.sh
+    Install_eAccelerator 2>&1 | tee -a ${oneinstack_dir}/install.log
     ;;
 esac
 
-# ZendGuardLoader (php <= 5.6)
-if [ "${zendguardloader_yn}" == 'y' ]; then
+# ZendGuardLoader
+if [ "${pecl_zendguardloader}" == '1' ]; then
   . include/ZendGuardLoader.sh
   Install_ZendGuardLoader 2>&1 | tee -a ${oneinstack_dir}/install.log
 fi
 
-# ionCube
-if [ "${ioncube_yn}" == 'y' ]; then
+# ioncube
+if [ "${pecl_ioncube}" == '1' ]; then
   . include/ioncube.sh
   Install_ionCube 2>&1 | tee -a ${oneinstack_dir}/install.log
 fi
 
 # SourceGuardian
-if [ "${sourceguardian_yn}" == 'y' ]; then
+if [ "${pecl_sourceguardian}" == '1' ]; then
   . include/sourceguardian.sh
   Install_SourceGuardian 2>&1 | tee -a ${oneinstack_dir}/install.log
 fi
 
-# ImageMagick or GraphicsMagick
-if [ "${magick_option}" == '1' ]; then
+# imagick
+if [ "${pecl_imagick}" == '1' ]; then
   . include/ImageMagick.sh
-  [ ! -d "${imagick_install_dir}" ] && Install_ImageMagick 2>&1 | tee -a ${oneinstack_dir}/install.log
+  Install_ImageMagick 2>&1 | tee -a ${oneinstack_dir}/install.log
   Install_pecl-imagick 2>&1 | tee -a ${oneinstack_dir}/install.log
-elif [ "${magick_option}" == '2' ]; then
+fi
+
+# gmagick
+if [ "${pecl_gmagick}" == '1' ]; then
   . include/GraphicsMagick.sh
-  [ ! -d "${gmagick_install_dir}" ] && Install_GraphicsMagick 2>&1 | tee -a ${oneinstack_dir}/install.log
+  Install_GraphicsMagick 2>&1 | tee -a ${oneinstack_dir}/install.log
   Install_pecl-gmagick 2>&1 | tee -a ${oneinstack_dir}/install.log
 fi
 
+# fileinfo
+if [ "${pecl_fileinfo}" == '1' ]; then
+  . include/pecl_fileinfo.sh
+  Install_pecl-fileinfo 2>&1 | tee -a ${oneinstack_dir}/install.log
+fi
+
+# imap
+if [ "${pecl_imap}" == '1' ]; then
+  . include/pecl_imap.sh
+  Install_pecl-imap 2>&1 | tee -a ${oneinstack_dir}/install.log
+fi
+
+# phalcon
+if [ "${pecl_phalcon}" == '1' ]; then
+  . include/pecl_phalcon.sh
+  Install_pecl-phalcon 2>&1 | tee -a ${oneinstack_dir}/install.log
+fi
+
 # pecl_memcached
 if [ "${pecl_memcached}" == '1' ]; then
   . include/memcached.sh
@@ -914,11 +957,23 @@ if [ "${pecl_redis}" == '1' ]; then
 fi
 
 # pecl_mongodb
-if [ -e "${mongo_install_dir}/bin/mongo" -o "${pecl_mongodb}" == '1' ]; then
+if [ "${pecl_mongodb}" == '1' ]; then
   . include/pecl_mongodb.sh
   Install_pecl-mongodb 2>&1 | tee -a ${oneinstack_dir}/install.log
 fi
 
+# swoole
+if [ "${pecl_swoole}" == '1' ]; then
+  . include/pecl_swoole.sh
+  Install_pecl-swoole 2>&1 | tee -a ${oneinstack_dir}/install.log
+fi
+
+# xdebug
+if [ "${pecl_xdebug}" == '1' ]; then
+  . include/pecl_xdebug.sh
+  Install_pecl-xdebug 2>&1 | tee -a ${oneinstack_dir}/install.log
+fi
+
 # pecl_pgsql
 if [ -e "${pgsql_install_dir}/bin/psql" ]; then
   . include/pecl_pgsql.sh
@@ -979,16 +1034,13 @@ fi
 # redis
 if [ "${redis_yn}" == 'y' ]; then
   . include/redis.sh
-  [ ! -d "${redis_install_dir}" ] && Install_redis-server 2>&1 | tee -a ${oneinstack_dir}/install.log
-  Install_pecl-redis 2>&1 | tee -a ${oneinstack_dir}/install.log
+  Install_redis-server 2>&1 | tee -a ${oneinstack_dir}/install.log
 fi
 
 # memcached
 if [ "${memcached_yn}" == 'y' ]; then
   . include/memcached.sh
-  [ ! -d "${memcached_install_dir}/include/memcached" ] && Install_memcached 2>&1 | tee -a ${oneinstack_dir}/install.log
-  Install_pecl-memcached 2>&1 | tee -a ${oneinstack_dir}/install.log
-  Install_pecl-memcache 2>&1 | tee -a ${oneinstack_dir}/install.log
+  Install_memcached-server 2>&1 | tee -a ${oneinstack_dir}/install.log
 fi
 
 # index example
@@ -1009,6 +1061,11 @@ fi
 # Starting DB
 [ -d "/etc/mysql" ] && /bin/mv /etc/mysql{,_bk}
 [ -d "${db_install_dir}/support-files" ] && service mysqld start
+
+# reload php
+[ -e "${php_install_dir}/sbin/php-fpm" ] && service php-fpm reload
+[ -e "${apache_install_dir}/bin/apachectl" ] && ${apache_install_dir}/bin/apachectl -k graceful
+
 endTime=`date +%s`
 ((installTime=($endTime-$startTime)/60))
 echo "####################Congratulations########################"
@@ -1030,13 +1087,13 @@ echo "Total OneinStack Install Time: ${CQUESTION}${installTime}${CEND} minutes"
 [ "${db_option}" == '15' ] && echo "$(printf "%-32s" "MongoDB password:")${CMSG}${dbmongopwd}${CEND}"
 [ "${php_yn}" == 'y' ] && echo -e "\n$(printf "%-32s" "PHP install dir:")${CMSG}${php_install_dir}${CEND}"
 [ "${php_yn}" == 'y' -a "${phpcache_option}" == '1' ] && echo "$(printf "%-32s" "Opcache Control Panel URL:")${CMSG}http://${IPADDR}/ocp.php${CEND}"
-[ "${phpcache_option}" == '2' ] && echo "$(printf "%-32s" "xcache Control Panel URL:")${CMSG}http://${IPADDR}/xcache${CEND}"
-[ "${phpcache_option}" == '2' ] && echo "$(printf "%-32s" "xcache user:")${CMSG}admin${CEND}"
-[ "${phpcache_option}" == '2' ] && echo "$(printf "%-32s" "xcache password:")${CMSG}${xcachepwd}${CEND}"
+[ "${phpcache_option}" == '2' -a -e "${php_install_dir}/etc/php.d/04-xcache.ini" ] && echo "$(printf "%-32s" "xcache Control Panel URL:")${CMSG}http://${IPADDR}/xcache${CEND}"
+[ "${phpcache_option}" == '2' -a -e "${php_install_dir}/etc/php.d/04-xcache.ini" ] && echo "$(printf "%-32s" "xcache user:")${CMSG}admin${CEND}"
+[ "${phpcache_option}" == '2' -a -e "${php_install_dir}/etc/php.d/04-xcache.ini" ] && echo "$(printf "%-32s" "xcache password:")${CMSG}${xcachepwd}${CEND}"
 [ "${phpcache_option}" == '3' ] && echo "$(printf "%-32s" "APC Control Panel URL:")${CMSG}http://${IPADDR}/apc.php${CEND}"
-[ "${phpcache_option}" == '4' ] && echo "$(printf "%-32s" "eAccelerator Control Panel URL:")${CMSG}http://${IPADDR}/control.php${CEND}"
-[ "${phpcache_option}" == '4' ] && echo "$(printf "%-32s" "eAccelerator user:")${CMSG}admin${CEND}"
-[ "${phpcache_option}" == '4' ] && echo "$(printf "%-32s" "eAccelerator password:")${CMSG}eAccelerator${CEND}"
+[ "${phpcache_option}" == '4' -a -e "${php_install_dir}/etc/php.d/02-eaccelerator.ini" ] && echo "$(printf "%-32s" "eAccelerator Control Panel URL:")${CMSG}http://${IPADDR}/control.php${CEND}"
+[ "${phpcache_option}" == '4' -a -e "${php_install_dir}/etc/php.d/02-eaccelerator.ini" ] && echo "$(printf "%-32s" "eAccelerator user:")${CMSG}admin${CEND}"
+[ "${phpcache_option}" == '4' -a -e "${php_install_dir}/etc/php.d/02-eaccelerator.ini" ] && 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}"

+ 7 - 7
ss.sh

@@ -73,7 +73,7 @@ Iptables_set() {
   done
 
   if [ "${PM}" == 'yum' ]; then
-    if [ -n "`grep 'dport 80 ' /etc/sysconfig/iptables`" -a -z "$(grep -E ${SS_port} /etc/sysconfig/iptables)" ]; then
+    if [ -n "`grep 'dport 80 ' /etc/sysconfig/iptables`" ] && [ -z "$(grep -E ${SS_port} /etc/sysconfig/iptables)" ]; then
       iptables -I INPUT 4 -p udp -m state --state NEW -m udp --dport ${SS_port} -j ACCEPT
       iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport ${SS_port} -j ACCEPT
       service iptables save
@@ -84,7 +84,7 @@ Iptables_set() {
     fi
   elif [ "${PM}" == 'apt-get' ]; then
     if [ -e '/etc/iptables/rules.v4' ]; then
-      if [ -n "`grep 'dport 80 ' /etc/iptables/rules.v4`" -a -z "$(grep -E ${SS_port} /etc/iptables/rules.v4)" ]; then
+      if [ -n "`grep 'dport 80 ' /etc/iptables/rules.v4`" ] && [ -z "$(grep -E ${SS_port} /etc/iptables/rules.v4)" ]; then
         iptables -I INPUT 4 -p udp -m state --state NEW -m udp --dport ${SS_port} -j ACCEPT
         iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport ${SS_port} -j ACCEPT
         iptables-save > /etc/iptables/rules.v4
@@ -94,7 +94,7 @@ Iptables_set() {
         ip6tables-save > /etc/iptables/rules.v6
       fi
     elif [ -e '/etc/iptables.up.rules' ]; then
-      if [ -n "`grep 'dport 80 ' /etc/iptables.up.rules`" -a -z "$(grep -E ${SS_port} /etc/iptables.up.rules)" ]; then
+      if [ -n "`grep 'dport 80 ' /etc/iptables.up.rules`" ] && [ -z "$(grep -E ${SS_port} /etc/iptables.up.rules)" ]; then
         iptables -I INPUT 4 -p udp -m state --state NEW -m udp --dport ${SS_port} -j ACCEPT
         iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport ${SS_port} -j ACCEPT
         iptables-save > /etc/iptables.up.rules
@@ -133,7 +133,7 @@ Def_parameter() {
 }
 
 Install_SS-python() {
-  [ ! -e "${python_install_dir}/bin/python" ] && Install_Python
+  Install_Python
   ${python_install_dir}/bin/pip install M2Crypto
   ${python_install_dir}/bin/pip install greenlet
   ${python_install_dir}/bin/pip install gevent
@@ -154,7 +154,7 @@ Install_SS-python() {
 Install_SS-libev() {
   src_url=http://mirrors.linuxeye.com/oneinstack/src/shadowsocks-libev-3.2.3.tar.gz && Download_src
   src_url=http://mirrors.linuxeye.com/oneinstack/src/libsodium-${libsodium_ver}.tar.gz && Download_src
-  src_url=http://mirrors.linuxeye.com/oneinstack/src/mbedtls-2.14.1-apache.tgz && Download_src
+  src_url=http://mirrors.linuxeye.com/oneinstack/src/mbedtls-2.16.0-apache.tgz && Download_src
   if [ ! -e "/usr/local/lib/libsodium.la" ]; then
     tar xzf libsodium-${libsodium_ver}.tar.gz
     pushd libsodium-${libsodium_ver} > /dev/null
@@ -163,8 +163,8 @@ Install_SS-libev() {
     popd > /dev/null
     rm -rf libsodium-${libsodium_ver}
   fi
-  tar xzf mbedtls-2.14.1-apache.tgz
-  pushd mbedtls-2.14.1 > /dev/null
+  tar xzf mbedtls-2.16.0-apache.tgz
+  pushd mbedtls-2.16.0 > /dev/null
   make SHARED=1 CFLAGS=-fPIC
   make DESTDIR=/usr install
   popd > /dev/null

+ 237 - 44
uninstall.sh

@@ -29,25 +29,29 @@ pushd ${oneinstack_dir} > /dev/null
 
 showhelp() {
   echo
-  echo "Usage: $0 command ...
-  --help, -h                  Show this help message, More: https://oneinstack.com
-  --quiet, -q                 quiet operation
-  --all                       Uninstall All
-  --web                       Uninstall Nginx/Tengine/OpenResty/Apache/Tomcat
-  --mysql                     Uninstall MySQL/MariaDB/Percona/AliSQL
-  --postgresql                Uninstall PostgreSQL
-  --mongodb                   Uninstall MongoDB
-  --php                       Uninstall PHP
-  --hhvm                      Uninstall HHVM
-  --pureftpd                  Uninstall PureFtpd
-  --redis                     Uninstall Redis
-  --memcached                 Uninstall Memcached
-  --phpmyadmin                Uninstall phpMyAdmin
+  echo "Usage: $0  command ...[parameters]....
+  --help, -h                    Show this help message, More: https://oneinstack.com
+  --quiet, -q                   quiet operation
+  --all                         Uninstall All
+  --web                         Uninstall Nginx/Tengine/OpenResty/Apache/Tomcat
+  --mysql                       Uninstall MySQL/MariaDB/Percona/AliSQL
+  --postgresql                  Uninstall PostgreSQL
+  --mongodb                     Uninstall MongoDB
+  --php                         Uninstall PHP
+  --phpcache                    Uninstall PHP opcode cache
+  --php_extensions [ext name]   Uninstall PHP extensions, include zendguardloader,ioncube,
+                                sourceguardian,imagick,gmagick,fileinfo,imap,phalcon,
+                                redis,memcached,memcache,mongodb,swoole,xdebug
+  --hhvm                        Uninstall HHVM
+  --pureftpd                    Uninstall PureFtpd
+  --redis                       Uninstall Redis-server
+  --memcached                   Uninstall Memcached-server
+  --phpmyadmin                  Uninstall phpMyAdmin
   "
 }
 
 ARG_NUM=$#
-TEMP=`getopt -o hvVq --long help,version,quiet,all,web,mysql,postgresql,mongodb,php,hhvm,pureftpd,redis,memcached,phpmyadmin -- "$@" 2>/dev/null`
+TEMP=`getopt -o hvVq --long help,version,quiet,all,web,mysql,postgresql,mongodb,php,phpcache,php_extensions:,hhvm,pureftpd,redis,memcached,phpmyadmin -- "$@" 2>/dev/null`
 [ $? != 0 ] && echo "${CWARNING}ERROR: unknown argument! ${CEND}" && showhelp && exit 1
 eval set -- "${TEMP}"
 while :; do
@@ -90,6 +94,26 @@ while :; do
     --php)
       php_yn=y; shift 1
       ;;
+    --phpcache)
+      phpcache_yn=y; shift 1
+      ;;
+    --php_extensions)
+      php_extensions=$2; shift 2
+      [ -n "`echo ${php_extensions} | grep -w zendguardloader`" ] && pecl_zendguardloader=1
+      [ -n "`echo ${php_extensions} | grep -w ioncube`" ] && pecl_ioncube=1
+      [ -n "`echo ${php_extensions} | grep -w sourceguardian`" ] && pecl_sourceguardian=1
+      [ -n "`echo ${php_extensions} | grep -w imagick`" ] && pecl_imagick=1
+      [ -n "`echo ${php_extensions} | grep -w gmagick`" ] && pecl_gmagick=1
+      [ -n "`echo ${php_extensions} | grep -w fileinfo`" ] && pecl_fileinfo=1
+      [ -n "`echo ${php_extensions} | grep -w imap`" ] && pecl_imap=1
+      [ -n "`echo ${php_extensions} | grep -w phalcon`" ] && pecl_phalcon=1
+      [ -n "`echo ${php_extensions} | grep -w redis`" ] && pecl_redis=1
+      [ -n "`echo ${php_extensions} | grep -w memcached`" ] && pecl_memcached=1
+      [ -n "`echo ${php_extensions} | grep -w memcache`" ] && pecl_memcache=1
+      [ -n "`echo ${php_extensions} | grep -w mongodb`" ] && pecl_mongodb=1
+      [ -n "`echo ${php_extensions} | grep -w swoole`" ] && pecl_swoole=1
+      [ -n "`echo ${php_extensions} | grep -w xdebug`" ] && pecl_xdebug=1
+      ;;
     --hhvm)
       hhvm_yn=y; shift 1
       ;;
@@ -118,7 +142,6 @@ Uninstall_status() {
   if [ "${quiet_yn}" != 'y' ]; then
     while :; do echo
       read -e -p "Do you want to uninstall? [y/n]: " uninstall_yn
-      echo
       if [[ ! ${uninstall_yn} =~ ^[y,n]$ ]]; then
         echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
       else
@@ -250,6 +273,163 @@ Uninstall_PHP() {
   sed -i "s@${php_install_dir}/bin:@@" /etc/profile
 }
 
+Uninstall_PHPcache() {
+  . include/zendopcache.sh
+  . include/xcache.sh
+  . include/apcu.sh
+  . include/eaccelerator.sh
+  Uninstall_ZendOPcache
+  Uninstall_XCache
+  Uninstall_APCU
+  Uninstall_eAccelerator
+  # reload php
+  [ -e "${php_install_dir}/sbin/php-fpm" ] && service php-fpm reload
+  [ -e "${apache_install_dir}/bin/apachectl" ] && ${apache_install_dir}/bin/apachectl -k graceful
+}
+
+Uninstall_PHPext() {
+  # ZendGuardLoader
+  if [ "${pecl_zendguardloader}" == '1' ]; then
+    . include/ZendGuardLoader.sh
+    Uninstall_ZendGuardLoader
+  fi
+
+  # ioncube
+  if [ "${pecl_ioncube}" == '1' ]; then
+    . include/ioncube.sh
+    Uninstall_ionCube
+  fi
+
+  # SourceGuardian
+  if [ "${pecl_sourceguardian}" == '1' ]; then
+    . include/sourceguardian.sh
+    Uninstall_SourceGuardian
+  fi
+
+  # imagick
+  if [ "${pecl_imagick}" == '1' ]; then
+    . include/ImageMagick.sh
+    Uninstall_ImageMagick
+    Uninstall_pecl-imagick
+  fi
+
+  # gmagick
+  if [ "${pecl_gmagick}" == '1' ]; then
+    . include/GraphicsMagick.sh
+    Uninstall_GraphicsMagick
+    Uninstall_pecl-gmagick
+  fi
+
+  # fileinfo
+  if [ "${pecl_fileinfo}" == '1' ]; then
+    . include/pecl_fileinfo.sh
+    Uninstall_pecl-fileinfo
+  fi
+
+  # imap
+  if [ "${pecl_imap}" == '1' ]; then
+    . include/pecl_imap.sh
+    Uninstall_pecl-imap
+  fi
+
+  # phalcon
+  if [ "${pecl_phalcon}" == '1' ]; then
+    . include/pecl_phalcon.sh
+    Uninstall_pecl-phalcon
+  fi
+
+  # pecl_memcached
+  if [ "${pecl_memcached}" == '1' ]; then
+    . include/memcached.sh
+    Uninstall_pecl-memcached
+  fi
+
+  # pecl_memcache
+  if [ "${pecl_memcache}" == '1' ]; then
+    . include/memcached.sh
+    Uninstall_pecl-memcache
+  fi
+
+  # pecl_redis
+  if [ "${pecl_redis}" == '1' ]; then
+    . include/redis.sh
+    Uninstall_pecl-redis
+  fi
+
+  # pecl_mongodb
+  if [ "${pecl_mongodb}" == '1' ]; then
+    . include/pecl_mongodb.sh
+    Uninstall_pecl-mongodb
+  fi
+
+  # swoole
+  if [ "${pecl_swoole}" == '1' ]; then
+    . include/pecl_swoole.sh
+    Uninstall_pecl-swoole
+  fi
+
+  # xdebug
+  if [ "${pecl_xdebug}" == '1' ]; then
+    . include/pecl_xdebug.sh
+    Uninstall_pecl-xdebug
+  fi
+
+  # reload php
+  [ -e "${php_install_dir}/sbin/php-fpm" ] && service php-fpm reload
+  [ -e "${apache_install_dir}/bin/apachectl" ] && ${apache_install_dir}/bin/apachectl -k graceful
+}
+
+Menu_PHPext() {
+  while :; do
+    echo 'Please select uninstall PHP extensions:'
+    echo -e "\t${CMSG} 0${CEND}. Do not uninstall"
+    echo -e "\t${CMSG} 1${CEND}. Uninstall zendguardloader(PHP<=5.6)"
+    echo -e "\t${CMSG} 2${CEND}. Uninstall ioncube"
+    echo -e "\t${CMSG} 3${CEND}. Uninstall sourceguardian(PHP<=7.2)"
+    echo -e "\t${CMSG} 4${CEND}. Uninstall imagick"
+    echo -e "\t${CMSG} 5${CEND}. Uninstall gmagick"
+    echo -e "\t${CMSG} 6${CEND}. Uninstall fileinfo"
+    echo -e "\t${CMSG} 7${CEND}. Uninstall imap"
+    echo -e "\t${CMSG} 8${CEND}. Uninstall phalcon(PHP>=5.5)"
+    echo -e "\t${CMSG} 9${CEND}. Uninstall redis"
+    echo -e "\t${CMSG}10${CEND}. Uninstall memcached"
+    echo -e "\t${CMSG}11${CEND}. Uninstall memcache(PHP<=7.2)"
+    echo -e "\t${CMSG}12${CEND}. Uninstall mongodb"
+    echo -e "\t${CMSG}13${CEND}. Uninstall swoole"
+    echo -e "\t${CMSG}14${CEND}. Uninstall xdebug(PHP>=5.5)"
+    read -e -p "Please input a number:(Default 0 press Enter) " phpext_option
+    phpext_option=${phpext_option:-0}
+    [ "${phpext_option}" == '0' ] && break
+    array_phpext=(${phpext_option})
+    array_all=(1 2 3 4 5 6 7 8 9 10 11 12 13 14)
+    for v in ${array_phpext[@]}
+    do
+      [ -z "`echo ${array_all[@]} | grep -w ${v}`" ] && phpext_flag=1
+    done
+    if [ "${phpext_flag}" == '1' ]; then
+      unset phpext_flag
+      echo; echo "${CWARNING}input error! Please only input number 1 2 3 14 and so on${CEND}"; echo
+      continue
+    else
+      [ -n "`echo ${array_phpext[@]} | grep -w 1`" ] && pecl_zendguardloader=1
+      [ -n "`echo ${array_phpext[@]} | grep -w 2`" ] && pecl_ioncube=1
+      [ -n "`echo ${array_phpext[@]} | grep -w 3`" ] && pecl_sourceguardian=1
+      [ -n "`echo ${array_phpext[@]} | grep -w 4`" ] && pecl_imagick=1
+      [ -n "`echo ${array_phpext[@]} | grep -w 5`" ] && pecl_gmagick=1
+      [ -n "`echo ${array_phpext[@]} | grep -w 6`" ] && pecl_fileinfo=1
+      [ -n "`echo ${array_phpext[@]} | grep -w 7`" ] && pecl_imap=1
+      [ -n "`echo ${array_phpext[@]} | grep -w 8`" ] && pecl_phalcon=1
+      [ -n "`echo ${array_phpext[@]} | grep -w 9`" ] && pecl_redis=1
+      [ -n "`echo ${array_phpext[@]} | grep -w 10`" ] && pecl_memcached=1
+      [ -n "`echo ${array_phpext[@]} | grep -w 11`" ] && pecl_memcache=1
+      [ -n "`echo ${array_phpext[@]} | grep -w 12`" ] && pecl_mongodb=1
+      [ -n "`echo ${array_phpext[@]} | grep -w 13`" ] && pecl_swoole=1
+      [ -n "`echo ${array_phpext[@]} | grep -w 14`" ] && pecl_xdebug=1
+      break
+    fi
+  done
+}
+
 Print_HHVM() {
   [ -e "/usr/bin/hhvm" ] && echo "/usr/bin/hhvm"
   [ -e "/etc/hhvm" ] && echo "/etc/hhvm"
@@ -276,24 +456,24 @@ Uninstall_PureFtpd() {
   [ -e "/lib/systemd/system/pureftpd.service" ] && { systemctl disable pureftpd > /dev/null 2>&1; rm -f /lib/systemd/system/pureftpd.service; }
 }
 
-Print_Redis() {
+Print_Redis-server() {
   [ -e "${redis_install_dir}" ] && echo "${redis_install_dir}"
   [ -e "/etc/init.d/redis-server" ] && echo "/etc/init.d/redis-server"
   [ -e "/lib/systemd/system/redis-server.service" ] && echo '/lib/systemd/system/redis-server.service'
 }
 
-Uninstall_Redis() {
+Uninstall_Redis-server() {
   [ -e "${redis_install_dir}" ] && { service redis-server stop > /dev/null 2>&1; rm -rf ${redis_install_dir} /etc/init.d/redis-server /usr/local/bin/redis-*; echo "${CMSG}Redis uninstall completed! ${CEND}"; }
   [ -e "/lib/systemd/system/redis-server.service" ] && { systemctl disable redis-server > /dev/null 2>&1; rm -f /lib/systemd/system/redis-server.service; }
 }
 
-Print_Memcached() {
+Print_Memcached-server() {
   [ -e "${memcached_install_dir}" ] && echo "${memcached_install_dir}"
   [ -e "/etc/init.d/memcached" ] && echo "/etc/init.d/memcached"
   [ -e "/usr/bin/memcached" ] && echo "/usr/bin/memcached"
 }
 
-Uninstall_Memcached() {
+Uninstall_Memcached-server() {
   [ -e "${memcached_install_dir}" ] && { service memcached stop > /dev/null 2>&1; rm -rf ${memcached_install_dir} /etc/init.d/memcached /usr/bin/memcached; echo "${CMSG}Memcached uninstall completed! ${CEND}"; }
 }
 
@@ -313,7 +493,7 @@ Uninstall_openssl() {
   [ -d "${openssl_install_dir}" ] && rm -rf ${openssl_install_dir}
 }
 
-Menu(){
+Menu() {
 while :; do
   printf "
 What Are You Doing?
@@ -323,17 +503,19 @@ What Are You Doing?
 \t${CMSG} 3${CEND}. Uninstall PostgreSQL
 \t${CMSG} 4${CEND}. Uninstall MongoDB
 \t${CMSG} 5${CEND}. Uninstall PHP
-\t${CMSG} 6${CEND}. Uninstall HHVM
-\t${CMSG} 7${CEND}. Uninstall PureFtpd
-\t${CMSG} 8${CEND}. Uninstall Redis
-\t${CMSG} 9${CEND}. Uninstall Memcached
-\t${CMSG}10${CEND}. Uninstall phpMyAdmin
+\t${CMSG} 6${CEND}. Uninstall PHP opcode cache
+\t${CMSG} 7${CEND}. Uninstall PHP extensions
+\t${CMSG} 8${CEND}. Uninstall HHVM
+\t${CMSG} 9${CEND}. Uninstall PureFtpd
+\t${CMSG}10${CEND}. Uninstall Redis
+\t${CMSG}11${CEND}. Uninstall Memcached
+\t${CMSG}12${CEND}. Uninstall phpMyAdmin
 \t${CMSG} q${CEND}. Exit
 "
   echo
   read -e -p "Please input the correct option: " Number
-  if [[ ! "${Number}" =~ ^[0-9,q]$|^10$ ]]; then
-    echo "${CWARNING}input error! Please only input 0~10 and q${CEND}"
+  if [[ ! "${Number}" =~ ^[0-9,q]$|^1[0-2]$ ]]; then
+    echo "${CWARNING}input error! Please only input 0~12 and q${CEND}"
   else
     case "$Number" in
     0)
@@ -345,8 +527,8 @@ What Are You Doing?
       Print_PHP
       Print_HHVM
       Print_PureFtpd
-      Print_Redis
-      Print_Memcached
+      Print_Redis-server
+      Print_Memcached-server
       Print_openssl
       Print_phpMyAdmin
       Uninstall_status
@@ -358,8 +540,8 @@ What Are You Doing?
         Uninstall_PHP
         Uninstall_HHVM
         Uninstall_PureFtpd
-        Uninstall_Redis
-        Uninstall_Memcached
+        Uninstall_Redis-server
+        Uninstall_Memcached-server
         Uninstall_openssl
         Uninstall_phpMyAdmin
       else
@@ -396,26 +578,35 @@ What Are You Doing?
       [ "${uninstall_yn}" == 'y' ] && Uninstall_PHP || exit
       ;;
     6)
+      Uninstall_status
+      [ "${uninstall_yn}" == 'y' ] && Uninstall_PHPcache || exit
+      ;;
+    7)
+      Menu_PHPext
+      [ "${phpext_option}" != '0' ] && Uninstall_status
+      [ "${uninstall_yn}" == 'y' ] && Uninstall_PHPext || exit
+      ;;
+    8)
       Print_HHVM
       Uninstall_status
       [ "${uninstall_yn}" == 'y' ] && Uninstall_HHVM || exit
       ;;
-    7)
+    9)
       Print_PureFtpd
       Uninstall_status
       [ "${uninstall_yn}" == 'y' ] && Uninstall_PureFtpd || exit
       ;;
-    8)
-      Print_Redis
+    10)
+      Print_Redis-server
       Uninstall_status
-      [ "${uninstall_yn}" == 'y' ] && Uninstall_Redis || exit
+      [ "${uninstall_yn}" == 'y' ] && Uninstall_Redis-server || exit
       ;;
-    9)
-      Print_Memcached
+    11)
+      Print_Memcached-server
       Uninstall_status
-      [ "${uninstall_yn}" == 'y' ] && Uninstall_Memcached || exit
+      [ "${uninstall_yn}" == 'y' ] && Uninstall_Memcached-server || exit
       ;;
-    10)
+    12)
       Print_phpMyAdmin
       Uninstall_status
       [ "${uninstall_yn}" == 'y' ] && Uninstall_phpMyAdmin || exit
@@ -438,8 +629,8 @@ else
   [ "${php_yn}" == 'y' ] && Print_PHP
   [ "${hhvm_yn}" == 'y' ] && Print_HHVM
   [ "${pureftpd_yn}" == 'y' ] && Print_PureFtpd
-  [ "${redis_yn}" == 'y' ] && Print_Redis
-  [ "${memcached_yn}" == 'y' ] && Print_Memcached
+  [ "${redis_yn}" == 'y' ] && Print_Redis-server
+  [ "${memcached_yn}" == 'y' ] && Print_Memcached-server
   [ "${phpmyadmin_yn}" == 'y' ] && Print_phpMyAdmin
   [ "${all_yn}" == 'y' ] && Print_openssl
   Uninstall_status
@@ -448,11 +639,13 @@ else
     [ "${mysql_yn}" == 'y' ] && Uninstall_MySQL
     [ "${postgresql_yn}" == 'y' ] && Uninstall_PostgreSQL
     [ "${mongodb_yn}" == 'y' ] && Uninstall_MongoDB
+    [ "${phpcache_yn}" == 'y' ] && Uninstall_PHPcache
+    Uninstall_PHPext
     [ "${php_yn}" == 'y' ] && Uninstall_PHP
     [ "${hhvm_yn}" == 'y' ] && Uninstall_HHVM
     [ "${pureftpd_yn}" == 'y' ] && Uninstall_PureFtpd
-    [ "${redis_yn}" == 'y' ] && Uninstall_Redis
-    [ "${memcached_yn}" == 'y' ] && Uninstall_Memcached
+    [ "${redis_yn}" == 'y' ] && Uninstall_Redis-server
+    [ "${memcached_yn}" == 'y' ] && Uninstall_Memcached-server
     [ "${phpmyadmin_yn}" == 'y' ] && Uninstall_phpMyAdmin
     [ "${all_yn}" == 'y' ] && Uninstall_openssl
   fi

+ 11 - 9
versions.txt

@@ -38,7 +38,7 @@ alisql_ver=5.6.32-9
 
 pgsql_ver=11.1
 
-mongodb_ver=4.0.4
+mongodb_ver=4.0.5
 
 # JDK
 jdk110_ver=11.0.1
@@ -63,19 +63,21 @@ mcrypt_ver=2.6.8
 mhash_ver=0.9.9.9
 libsodium_ver=1.0.16
 argon2_ver=20171227
-imagemagick_ver=6.9.10-19
+imagemagick_ver=6.9.10-21
 imagick_ver=3.4.3
 graphicsmagick_ver=1.3.30
-gmagick_for_php7_ver=2.0.5RC1
-gmagick_ver=1.1.7RC3
+gmagick_ver=2.0.5RC1
+gmagick_oldver=1.1.7RC3
 zendopcache_ver=7.0.5
 xcache_ver=3.2.0
-apcu_ver=4.0.11
-apcu_for_php7_ver=5.1.14
+apcu_ver=5.1.16
+apcu_oldver=4.0.11
 eaccelerator_ver=0.9.6.1
 phalcon_ver=3.4.2
-swoole_ver=4.2.10
+swoole_ver=4.2.12
+swoole_oldver=1.10.5
 xdebug_ver=2.6.1
+xdebug_oldver=2.5.5
 
 # Ftp
 pureftpd_ver=1.0.47
@@ -87,8 +89,8 @@ pecl_redis_ver=4.2.0
 # Memcached
 memcached_ver=1.5.12
 libmemcached_ver=1.0.18
-pecl_memcached_ver=2.2.0
-pecl_memcached_php7_ver=3.1.3
+pecl_memcached_ver=3.1.3
+pecl_memcached_oldver=2.2.0
 pecl_memcache_ver=3.0.8
 
 # MongoDB

+ 10 - 10
vhost.sh

@@ -242,11 +242,11 @@ EOF
       [ -e "${PATH_SSL}/${domain}.crt" ] && rm -f ${PATH_SSL}/${domain}.{crt,key}
       [ -e /bin/systemctl -a -e /lib/systemd/system/nginx.service ] && Nginx_cmd='/bin/systemctl restart nginx' || Nginx_cmd='/etc/init.d/nginx force-reload'
       Apache_cmd="${apache_install_dir}/bin/apachectl -k graceful"
-      if [ -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/conf/httpd.conf" ]; then
+      if [ -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/bin/httpd" ]; then
         Command="${Nginx_cmd};${Apache_cmd}"
-      elif [ -e "${web_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/conf/httpd.conf" ]; then
+      elif [ -e "${web_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then
         Command="${Nginx_cmd}"
-      elif [ ! -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/conf/httpd.conf" ]; then
+      elif [ ! -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/bin/httpd" ]; then
         Command="${Apache_cmd}"
       fi
       ~/.acme.sh/acme.sh --install-cert -d ${domain} --fullchain-file ${PATH_SSL}/${domain}.crt --key-file ${PATH_SSL}/${domain}.key --reloadcmd "${Command}" > /dev/null
@@ -303,7 +303,7 @@ What Are You Doing?
       nginx_ssl_flag=y
       PATH_SSL=${web_install_dir}/conf/ssl
       [ ! -d "${PATH_SSL}" ] && mkdir ${PATH_SSL}
-    elif [ ! -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/bin/apachectl" ]; then
+    elif [ ! -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/bin/httpd" ]; then
       apache_ssl_flag=y
       PATH_SSL=${apache_install_dir}/conf/ssl
       [ ! -d "${PATH_SSL}" ] && mkdir ${PATH_SSL}
@@ -870,7 +870,7 @@ EOF
 }
 
 Add_Vhost() {
-  if [ -e "${web_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/conf/httpd.conf" ]; then
+  if [ -e "${web_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" ]; then
     Choose_env
     Input_Add_domain
     Nginx_anti_hotlinking
@@ -882,16 +882,16 @@ Add_Vhost() {
       Nginx_log
       Create_nginx_php-fpm_hhvm_conf
     fi
-  elif [ ! -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/conf/httpd.conf" ]; then
+  elif [ ! -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/bin/httpd" ]; then
     Choose_env
     Input_Add_domain
     Apache_log
     Create_apache_conf
-  elif [ ! -e "${web_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/conf/httpd.conf" -a -e "${tomcat_install_dir}/conf/server.xml" ]; then
+  elif [ ! -e "${web_install_dir}/sbin/nginx" -a ! -e "${apache_install_dir}/bin/httpd" -a -e "${tomcat_install_dir}/conf/server.xml" ]; then
     Choose_env
     Input_Add_domain
     Create_tomcat_conf
-  elif [ -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/conf/httpd.conf" ]; then
+  elif [ -e "${web_install_dir}/sbin/nginx" -a -e "${apache_install_dir}/bin/httpd" ]; then
     Choose_env
     Input_Add_domain
     Nginx_anti_hotlinking
@@ -958,7 +958,7 @@ Del_NGX_Vhost() {
 }
 
 Del_Apache_Vhost() {
-  if [ -e "${apache_install_dir}/conf/httpd.conf" ]; then
+  if [ -e "${apache_install_dir}/bin/httpd" ]; then
     if [ -e "${web_install_dir}/sbin/nginx" ]; then
       rm -f ${apache_install_dir}/conf/vhost/${domain}.conf
       ${apache_install_dir}/bin/apachectl -k graceful
@@ -1061,7 +1061,7 @@ Del_Tomcat_Vhost() {
 
 List_Vhost() {
   [ -d "${web_install_dir}/conf/vhost" ] && Domain_List=$(ls ${web_install_dir}/conf/vhost | sed "s@.conf@@g")
-  [ -e "${apache_install_dir}/conf/httpd.conf" -a ! -d "${web_install_dir}/conf/vhost" ] && Domain_List=$(ls ${apache_install_dir}/conf/vhost | grep -v '0.conf' | sed "s@.conf@@g")
+  [ -e "${apache_install_dir}/bin/httpd" -a ! -d "${web_install_dir}/conf/vhost" ] && Domain_List=$(ls ${apache_install_dir}/conf/vhost | grep -v '0.conf' | sed "s@.conf@@g")
   [ -e "${tomcat_install_dir}/conf/server.xml" -a ! -d "${web_install_dir}/sbin/nginx" ] && Domain_List=$(ls ${tomcat_install_dir}/conf/vhost | grep -v 'localhost.xml' | sed "s@.xml@@g")
   if [ -n "${Domain_List}" ]; then
     echo