Jelajahi Sumber

Script optimization

lj2007331 9 tahun lalu
induk
melakukan
cd06e5a4cc

+ 3 - 3
apps.conf

@@ -32,9 +32,9 @@ jdk_8_version=1.8.0_66
 # PHP
 php_3_version=5.3.29
 php_4_version=5.4.45
-php_5_version=5.5.30
-php_6_version=5.6.16
-php_7_version=7.0.1
+php_5_version=5.5.31
+php_6_version=5.6.17
+php_7_version=7.0.2
 
 zendopcache_version=7.0.5
 xcache_version=3.2.0

+ 1 - 1
backup_setup.sh

@@ -134,7 +134,7 @@ echo "You have to backup the content:"
 [ "$CONTENT_BK" != '2' ] && echo "Database: ${CMSG}$db_name${CEND}"
 [ "$CONTENT_BK" != '1' ] && echo "Website: ${CMSG}$website_name${CEND}"
 
-if [ "$DESC_BK" == '2' -o "$DESC_BK" == '3' ];then
+if [[ "$DESC_BK" =~ ^[1,2]$ ]];then 
     > tools/iplist.txt
     while :
     do

+ 3 - 3
include/ImageMagick.sh

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

+ 2 - 4
include/apache-2.2.sh

@@ -40,10 +40,8 @@ fi
 sed -i '2a # chkconfig: - 85 15' /etc/init.d/httpd
 sed -i '3a # description: Apache is a World Wide Web server. It is used to serve' /etc/init.d/httpd
 chmod +x /etc/init.d/httpd
-OS_CentOS='chkconfig --add httpd \n
-chkconfig httpd on'
-OS_Debian_Ubuntu='update-rc.d httpd defaults'
-OS_command
+[ "$OS" == 'CentOS' ] && { chkconfig --add httpd; chkconfig httpd on; }
+[[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d httpd defaults
 
 sed -i "s@^User daemon@User $run_user@" $apache_install_dir/conf/httpd.conf
 sed -i "s@^Group daemon@Group $run_user@" $apache_install_dir/conf/httpd.conf

+ 2 - 4
include/apache-2.4.sh

@@ -53,10 +53,8 @@ fi
 sed -i '2a # chkconfig: - 85 15' /etc/init.d/httpd
 sed -i '3a # description: Apache is a World Wide Web server. It is used to serve' /etc/init.d/httpd
 chmod +x /etc/init.d/httpd
-OS_CentOS='chkconfig --add httpd \n
-chkconfig httpd on'
-OS_Debian_Ubuntu='update-rc.d httpd defaults'
-OS_command
+[ "$OS" == 'CentOS' ] && { chkconfig --add httpd; chkconfig httpd on; }
+[[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d httpd defaults
 
 sed -i "s@^User daemon@User $run_user@" $apache_install_dir/conf/httpd.conf
 sed -i "s@^Group daemon@Group $run_user@" $apache_install_dir/conf/httpd.conf

+ 0 - 11
include/check_os.sh

@@ -35,14 +35,3 @@ else
     SYS_BIG_FLAG=i586
     SYS_BIT_a=x86;SYS_BIT_b=i686;
 fi
-
-OS_command(){
-    if [ $OS == 'CentOS' ];then
-        echo -e $OS_CentOS | bash
-    elif [ $OS == 'Debian' -o $OS == 'Ubuntu' ];then
-        echo -e $OS_Debian_Ubuntu | bash
-    else
-        echo "${CFAILURE}Does not support this OS, Please contact the author! ${CEND}" 
-        kill -9 $$
-    fi
-}

+ 1 - 1
include/init_Debian.sh

@@ -20,7 +20,7 @@ apt-get -y update
 [ "$upgrade_yn" == 'y' ] && apt-get -y upgrade 
 
 # Install needed packages
-for Package in gcc g++ make cmake autoconf libjpeg8 libjpeg8-dev libjpeg-dev libpng12-0 libpng12-dev libpng3 libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev libreadline-dev curl libcurl3 libcurl4-openssl-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl libssl-dev libtool libevent-dev bison re2c libsasl2-dev libxslt1-dev locales libcloog-ppl0 patch vim zip unzip tmux htop wget bc expect rsync git lsof lrzsz cron logrotate
+for Package in gcc g++ make cmake autoconf libjpeg8 libjpeg8-dev libjpeg-dev libpng12-0 libpng12-dev libpng3 libfreetype6 libfreetype6-dev libxml2 libxml2-dev zlib1g zlib1g-dev libc6 libc6-dev libglib2.0-0 libglib2.0-dev bzip2 libzip-dev libbz2-1.0 libncurses5 libncurses5-dev libaio1 libaio-dev libreadline-dev curl libcurl3 libcurl4-openssl-dev libcurl4-gnutls-dev e2fsprogs libkrb5-3 libkrb5-dev libltdl-dev libidn11 libidn11-dev openssl libssl-dev libtool libevent-dev bison re2c libsasl2-dev libxslt1-dev locales libcloog-ppl0 patch vim zip unzip tmux htop wget bc expect rsync git lsof lrzsz cron logrotate
 do
     apt-get -y install $Package
 done

+ 1 - 1
include/init_Ubuntu.sh

@@ -25,7 +25,7 @@ do
     apt-get -y install $Package
 done
 
-if [ "$Ubuntu_version" == '14' -o "$Ubuntu_version" == '15' ];then
+if [[ "$Ubuntu_version" =~ ^14$|^15$ ]];then 
     apt-get -y install libcloog-ppl1
     apt-get -y remove bison
     cd src

+ 1 - 2
include/jdk-1.6.sh

@@ -17,8 +17,7 @@ JDK_NAME="jdk$jdk_6_version"
 JDK_PATH=$JAVA_dir/$JDK_NAME
 src_url=http://mirrors.linuxeye.com/jdk/$JDK_FILE && Download_src
 
-OS_CentOS='[ -n "`rpm -qa | grep jdk`" ] && rpm -e `rpm -qa | grep jdk`'
-OS_command
+[ "$OS" == 'CentOS' ] && [ -n "`rpm -qa | grep jdk`" ] && rpm -e `rpm -qa | grep jdk`
 
 chmod +x $JDK_FILE
 ./$JDK_FILE

+ 1 - 2
include/jdk-1.7.sh

@@ -17,8 +17,7 @@ JDK_NAME="jdk$jdk_7_version"
 JDK_PATH=$JAVA_dir/$JDK_NAME
 src_url=http://mirrors.linuxeye.com/jdk/$JDK_FILE && Download_src
 
-OS_CentOS='[ -n "`rpm -qa | grep jdk`" ] && rpm -e `rpm -qa | grep jdk`'
-OS_command
+[ "$OS" == 'CentOS' ] && [ -n "`rpm -qa | grep jdk`" ] && rpm -e `rpm -qa | grep jdk`
 
 tar xzf $JDK_FILE 
 

+ 1 - 2
include/jdk-1.8.sh

@@ -17,8 +17,7 @@ JDK_NAME="jdk$jdk_8_version"
 JDK_PATH=$JAVA_dir/$JDK_NAME
 src_url=http://mirrors.linuxeye.com/jdk/$JDK_FILE && Download_src
 
-OS_CentOS='[ -n "`rpm -qa | grep jdk`" ] && rpm -e `rpm -qa | grep jdk`'
-OS_command
+[ "$OS" == 'CentOS' ] && [ -n "`rpm -qa | grep jdk`" ] && rpm -e `rpm -qa | grep jdk`
 
 tar xzf $JDK_FILE
 

+ 2 - 4
include/mariadb-10.0.sh

@@ -45,10 +45,8 @@ fi
 sed -i "s@^basedir=.*@basedir=$mariadb_install_dir@" /etc/init.d/mysqld
 sed -i "s@^datadir=.*@datadir=$mariadb_data_dir@" /etc/init.d/mysqld
 chmod +x /etc/init.d/mysqld
-OS_CentOS='chkconfig --add mysqld \n
-chkconfig mysqld on'
-OS_Debian_Ubuntu='update-rc.d mysqld defaults'
-OS_command
+[ "$OS" == 'CentOS' ] && { chkconfig --add mysqld; chkconfig mysqld on; }
+[[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d mysqld defaults
 cd ..
 
 # my.cf

+ 2 - 4
include/mariadb-10.1.sh

@@ -45,10 +45,8 @@ fi
 sed -i "s@^basedir=.*@basedir=$mariadb_install_dir@" /etc/init.d/mysqld
 sed -i "s@^datadir=.*@datadir=$mariadb_data_dir@" /etc/init.d/mysqld
 chmod +x /etc/init.d/mysqld
-OS_CentOS='chkconfig --add mysqld \n
-chkconfig mysqld on'
-OS_Debian_Ubuntu='update-rc.d mysqld defaults'
-OS_command
+[ "$OS" == 'CentOS' ] && { chkconfig --add mysqld; chkconfig mysqld on; }
+[[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d mysqld defaults
 cd ..
 
 # my.cf

+ 2 - 4
include/mariadb-5.5.sh

@@ -45,10 +45,8 @@ fi
 sed -i "s@^basedir=.*@basedir=$mariadb_install_dir@" /etc/init.d/mysqld
 sed -i "s@^datadir=.*@datadir=$mariadb_data_dir@" /etc/init.d/mysqld
 chmod +x /etc/init.d/mysqld
-OS_CentOS='chkconfig --add mysqld \n
-chkconfig mysqld on'
-OS_Debian_Ubuntu='update-rc.d mysqld defaults'
-OS_command
+[ "$OS" == 'CentOS' ] && { chkconfig --add mysqld; chkconfig mysqld on; }
+[[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d mysqld defaults
 cd ..
 
 # my.cf

+ 4 - 9
include/memcached.sh

@@ -26,12 +26,8 @@ if [ -d "$memcached_install_dir/include/memcached" ];then
     cd ..
     rm -rf memcached-$memcached_version
     ln -s $memcached_install_dir/bin/memcached /usr/bin/memcached
-    OS_CentOS='/bin/cp ../init.d/Memcached-init-CentOS /etc/init.d/memcached \n
-chkconfig --add memcached \n
-chkconfig memcached on'
-    OS_Debian_Ubuntu='/bin/cp ../init.d/Memcached-init-Ubuntu /etc/init.d/memcached \n
-update-rc.d memcached defaults'
-    OS_command
+    [ "$OS" == 'CentOS' ] && { /bin/cp ../init.d/Memcached-init-CentOS /etc/init.d/memcached; chkconfig --add memcached; chkconfig memcached on; } 
+    [[ $OS =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Memcached-init-Ubuntu /etc/init.d/memcached; update-rc.d memcached defaults; } 
     sed -i "s@/usr/local/memcached@$memcached_install_dir@g" /etc/init.d/memcached
     [ -n "`grep 'CACHESIZE=' /etc/init.d/memcached`" ] && sed -i "s@^CACHESIZE=.*@CACHESIZE=`expr $Mem / 8`@" /etc/init.d/memcached 
     [ -n "`grep 'start_instance default 256;' /etc/init.d/memcached`" ] && sed -i "s@start_instance default 256;@start_instance default `expr $Mem / 8`;@" /etc/init.d/memcached
@@ -84,9 +80,8 @@ if [ -e "$php_install_dir/bin/phpize" ];then
     # php memcached extension
     tar xzf libmemcached-$libmemcached_version.tar.gz
     cd libmemcached-$libmemcached_version
-    OS_CentOS='yum -y install cyrus-sasl-devel'
-    OS_Debian_Ubuntu='sed -i "s@lthread -pthread -pthreads@lthread -lpthread -pthreads@" ./configure'
-    OS_command
+    [ "$OS" == 'CentOS' ] && yum -y install cyrus-sasl-devel 
+    [[ $OS =~ ^Ubuntu$|^Debian$ ]] && sed -i "s@lthread -pthread -pthreads@lthread -lpthread -pthreads@" ./configure 
     ./configure --with-memcached=$memcached_install_dir
     make && make install
     cd ..

+ 2 - 4
include/mysql-5.5.sh

@@ -57,10 +57,8 @@ fi
 
 /bin/cp $mysql_install_dir/support-files/mysql.server /etc/init.d/mysqld
 chmod +x /etc/init.d/mysqld
-OS_CentOS='chkconfig --add mysqld \n
-chkconfig mysqld on'
-OS_Debian_Ubuntu='update-rc.d mysqld defaults'
-OS_command
+[ "$OS" == 'CentOS' ] && { chkconfig --add mysqld; chkconfig mysqld on; }
+[[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d mysqld defaults
 cd ..
 
 # my.cf

+ 2 - 4
include/mysql-5.6.sh

@@ -55,10 +55,8 @@ fi
 
 /bin/cp $mysql_install_dir/support-files/mysql.server /etc/init.d/mysqld
 chmod +x /etc/init.d/mysqld
-OS_CentOS='chkconfig --add mysqld \n
-chkconfig mysqld on'
-OS_Debian_Ubuntu='update-rc.d mysqld defaults'
-OS_command
+[ "$OS" == 'CentOS' ] && { chkconfig --add mysqld; chkconfig mysqld on; }
+[[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d mysqld defaults
 cd ..
 
 # my.cf

+ 2 - 4
include/mysql-5.7.sh

@@ -69,10 +69,8 @@ fi
 
 /bin/cp $mysql_install_dir/support-files/mysql.server /etc/init.d/mysqld
 chmod +x /etc/init.d/mysqld
-OS_CentOS='chkconfig --add mysqld \n
-chkconfig mysqld on'
-OS_Debian_Ubuntu='update-rc.d mysqld defaults'
-OS_command
+[ "$OS" == 'CentOS' ] && { chkconfig --add mysqld; chkconfig mysqld on; }
+[[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d mysqld defaults
 cd ..
 
 # my.cf

+ 2 - 6
include/nginx.sh

@@ -58,12 +58,8 @@ fi
 [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $nginx_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$nginx_install_dir/sbin:\1@" /etc/profile
 . /etc/profile
 
-OS_CentOS='/bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx \n
-chkconfig --add nginx \n
-chkconfig nginx on'
-OS_Debian_Ubuntu='/bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx \n
-update-rc.d nginx defaults'
-OS_command
+[ "$OS" == 'CentOS' ] && { /bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; } 
+[[ $OS =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx; update-rc.d nginx defaults; } 
 cd ..
 
 sed -i "s@/usr/local/nginx@$nginx_install_dir@g" /etc/init.d/nginx

+ 2 - 4
include/percona-5.5.sh

@@ -56,10 +56,8 @@ fi
 
 /bin/cp $percona_install_dir/support-files/mysql.server /etc/init.d/mysqld
 chmod +x /etc/init.d/mysqld
-OS_CentOS='chkconfig --add mysqld \n
-chkconfig mysqld on'
-OS_Debian_Ubuntu='update-rc.d mysqld defaults'
-OS_command
+[ "$OS" == 'CentOS' ] && { chkconfig --add mysqld; chkconfig mysqld on; }
+[[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d mysqld defaults
 cd ..
 
 # my.cf

+ 2 - 4
include/percona-5.6.sh

@@ -55,10 +55,8 @@ fi
 
 /bin/cp $percona_install_dir/support-files/mysql.server /etc/init.d/mysqld
 chmod +x /etc/init.d/mysqld
-OS_CentOS='chkconfig --add mysqld \n
-chkconfig mysqld on'
-OS_Debian_Ubuntu='update-rc.d mysqld defaults'
-OS_command
+[ "$OS" == 'CentOS' ] && { chkconfig --add mysqld; chkconfig mysqld on; }
+[[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d mysqld defaults
 cd ..
 
 # my.cf

+ 3 - 14
include/php-5.3.sh

@@ -47,13 +47,7 @@ rm -rf mhash-$mhash_version
 
 echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
 ldconfig
-OS_CentOS='ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config \n
-if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ];then \n
-        ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 \n
-else \n
-        ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1 \n
-fi'
-OS_command
+[ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; }
 
 [ ! -e '/usr/include/freetype2/freetype' ] &&  ln -s /usr/include/freetype2 /usr/include/freetype2/freetype
 
@@ -124,21 +118,16 @@ sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini
 sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini
 sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini
 sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini
-sed -i 's@^;upload_tmp_dir.*@upload_tmp_dir = /tmp@' $php_install_dir/etc/php.ini
 sed -i 's@^max_execution_time.*@max_execution_time = 5@' $php_install_dir/etc/php.ini
 sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini
-sed -i 's@^session.cookie_httponly.*@session.cookie_httponly = 1@' $php_install_dir/etc/php.ini
-sed -i 's@^mysqlnd.collect_memory_statistics.*@mysqlnd.collect_memory_statistics = On@' $php_install_dir/etc/php.ini
 [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini
 
 if [[ ! $Apache_version =~ ^[1-2]$ ]];then
     # php-fpm Init Script
     /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
     chmod +x /etc/init.d/php-fpm
-    OS_CentOS='chkconfig --add php-fpm \n
-chkconfig php-fpm on'
-    OS_Debian_Ubuntu='update-rc.d php-fpm defaults'
-    OS_command
+    [ "$OS" == 'CentOS' ] && { chkconfig --add php-fpm; chkconfig php-fpm on; }
+    [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d php-fpm defaults
 
     cat > $php_install_dir/etc/php-fpm.conf <<EOF
 ;;;;;;;;;;;;;;;;;;;;;

+ 3 - 14
include/php-5.4.sh

@@ -47,13 +47,7 @@ rm -rf mhash-$mhash_version
 
 echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
 ldconfig
-OS_CentOS='ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config \n
-if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ];then \n
-        ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 \n
-else \n
-        ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1 \n
-fi'
-OS_command
+[ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; }
 
 tar xzf mcrypt-$mcrypt_version.tar.gz
 cd mcrypt-$mcrypt_version
@@ -121,21 +115,16 @@ sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini
 sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini
 sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini
 sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini
-sed -i 's@^;upload_tmp_dir.*@upload_tmp_dir = /tmp@' $php_install_dir/etc/php.ini
 sed -i 's@^max_execution_time.*@max_execution_time = 5@' $php_install_dir/etc/php.ini
 sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini
-sed -i 's@^session.cookie_httponly.*@session.cookie_httponly = 1@' $php_install_dir/etc/php.ini
-sed -i 's@^mysqlnd.collect_memory_statistics.*@mysqlnd.collect_memory_statistics = On@' $php_install_dir/etc/php.ini
 [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini
 
 if [[ ! $Apache_version =~ ^[1-2]$ ]];then
     # php-fpm Init Script
     /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
     chmod +x /etc/init.d/php-fpm
-    OS_CentOS='chkconfig --add php-fpm \n
-chkconfig php-fpm on'
-    OS_Debian_Ubuntu='update-rc.d php-fpm defaults'
-    OS_command
+    [ "$OS" == 'CentOS' ] && { chkconfig --add php-fpm; chkconfig php-fpm on; }
+    [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d php-fpm defaults
 
     cat > $php_install_dir/etc/php-fpm.conf <<EOF
 ;;;;;;;;;;;;;;;;;;;;;

+ 3 - 14
include/php-5.5.sh

@@ -46,13 +46,7 @@ rm -rf mhash-$mhash_version
 
 echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
 ldconfig
-OS_CentOS='ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config \n
-if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ];then \n
-        ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 \n
-else \n
-        ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1 \n
-fi'
-OS_command
+[ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; }
 
 tar xzf mcrypt-$mcrypt_version.tar.gz
 cd mcrypt-$mcrypt_version
@@ -120,11 +114,8 @@ sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini
 sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini
 sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini
 sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini
-sed -i 's@^;upload_tmp_dir.*@upload_tmp_dir = /tmp@' $php_install_dir/etc/php.ini
 sed -i 's@^max_execution_time.*@max_execution_time = 5@' $php_install_dir/etc/php.ini
 sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini
-sed -i 's@^session.cookie_httponly.*@session.cookie_httponly = 1@' $php_install_dir/etc/php.ini
-sed -i 's@^mysqlnd.collect_memory_statistics.*@mysqlnd.collect_memory_statistics = On@' $php_install_dir/etc/php.ini
 [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini
 
 if [ "$PHP_cache" == '1' ];then
@@ -144,10 +135,8 @@ if [[ ! $Apache_version =~ ^[1-2]$ ]];then
     # php-fpm Init Script
     /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
     chmod +x /etc/init.d/php-fpm
-    OS_CentOS='chkconfig --add php-fpm \n
-chkconfig php-fpm on'
-    OS_Debian_Ubuntu='update-rc.d php-fpm defaults'
-    OS_command
+    [ "$OS" == 'CentOS' ] && { chkconfig --add php-fpm; chkconfig php-fpm on; }
+    [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d php-fpm defaults
 
     cat > $php_install_dir/etc/php-fpm.conf <<EOF
 ;;;;;;;;;;;;;;;;;;;;;

+ 3 - 14
include/php-5.6.sh

@@ -46,13 +46,7 @@ rm -rf mhash-$mhash_version
 
 echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
 ldconfig
-OS_CentOS='ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config \n
-if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ];then \n
-        ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 \n
-else \n
-        ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1 \n
-fi'
-OS_command
+[ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; }
 
 tar xzf mcrypt-$mcrypt_version.tar.gz
 cd mcrypt-$mcrypt_version
@@ -121,11 +115,8 @@ sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini
 sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini
 sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini
 sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini
-sed -i 's@^;upload_tmp_dir.*@upload_tmp_dir = /tmp@' $php_install_dir/etc/php.ini
 sed -i 's@^max_execution_time.*@max_execution_time = 5@' $php_install_dir/etc/php.ini
 sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini
-sed -i 's@^session.cookie_httponly.*@session.cookie_httponly = 1@' $php_install_dir/etc/php.ini
-sed -i 's@^mysqlnd.collect_memory_statistics.*@mysqlnd.collect_memory_statistics = On@' $php_install_dir/etc/php.ini
 [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini
 
 if [ "$PHP_cache" == '1' ];then
@@ -145,10 +136,8 @@ if [[ ! $Apache_version =~ ^[1-2]$ ]];then
     # php-fpm Init Script
     /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
     chmod +x /etc/init.d/php-fpm
-    OS_CentOS='chkconfig --add php-fpm \n
-chkconfig php-fpm on'
-    OS_Debian_Ubuntu='update-rc.d php-fpm defaults'
-    OS_command
+    [ "$OS" == 'CentOS' ] && { chkconfig --add php-fpm; chkconfig php-fpm on; }
+    [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d php-fpm defaults
 
     cat > $php_install_dir/etc/php-fpm.conf <<EOF
 ;;;;;;;;;;;;;;;;;;;;;

+ 3 - 14
include/php-7.sh

@@ -45,13 +45,7 @@ rm -rf mhash-$mhash_version
 
 echo '/usr/local/lib' > /etc/ld.so.conf.d/local.conf
 ldconfig
-OS_CentOS='ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config \n
-if [ `getconf WORD_BIT` == 32 ] && [ `getconf LONG_BIT` == 64 ];then \n
-        ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 \n
-else \n
-        ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1 \n
-fi'
-OS_command
+[ "$OS" == 'CentOS' ] && { ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config; [ "$OS_BIT" == '64' ] && ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1 || ln -s /lib/libpcre.so.0.0.1 /lib/libpcre.so.1; }
 
 tar xzf mcrypt-$mcrypt_version.tar.gz
 cd mcrypt-$mcrypt_version
@@ -120,12 +114,9 @@ sed -i 's@^request_order.*@request_order = "CGP"@' $php_install_dir/etc/php.ini
 sed -i 's@^;date.timezone.*@date.timezone = Asia/Shanghai@' $php_install_dir/etc/php.ini
 sed -i 's@^post_max_size.*@post_max_size = 100M@' $php_install_dir/etc/php.ini
 sed -i 's@^upload_max_filesize.*@upload_max_filesize = 50M@' $php_install_dir/etc/php.ini
-sed -i 's@^;upload_tmp_dir.*@upload_tmp_dir = /tmp@' $php_install_dir/etc/php.ini
 sed -i 's@^max_execution_time.*@max_execution_time = 600@' $php_install_dir/etc/php.ini
 sed -i 's@^;realpath_cache_size.*@realpath_cache_size = 2M@' $php_install_dir/etc/php.ini
 sed -i 's@^disable_functions.*@disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen@' $php_install_dir/etc/php.ini
-sed -i 's@^session.cookie_httponly.*@session.cookie_httponly = 1@' $php_install_dir/etc/php.ini
-sed -i 's@^mysqlnd.collect_memory_statistics.*@mysqlnd.collect_memory_statistics = On@' $php_install_dir/etc/php.ini
 [ -e /usr/sbin/sendmail ] && sed -i 's@^;sendmail_path.*@sendmail_path = /usr/sbin/sendmail -t -i@' $php_install_dir/etc/php.ini
 
 if [ "$PHP_cache" == '1' ];then
@@ -150,10 +141,8 @@ if [[ ! $Apache_version =~ ^[1-2]$ ]];then
     # php-fpm Init Script
     /bin/cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
     chmod +x /etc/init.d/php-fpm
-    OS_CentOS='chkconfig --add php-fpm \n
-chkconfig php-fpm on'
-    OS_Debian_Ubuntu='update-rc.d php-fpm defaults'
-    OS_command
+    [ "$OS" == 'CentOS' ] && { chkconfig --add php-fpm; chkconfig php-fpm on; }
+    [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d php-fpm defaults
 
     cat > $php_install_dir/etc/php-fpm.conf <<EOF
 ;;;;;;;;;;;;;;;;;;;;;

+ 5 - 9
include/pureftpd.sh

@@ -33,12 +33,9 @@ if [ -e "$pureftpd_install_dir/sbin/pure-ftpwho" ];then
     sed -i "s@pureftpwho=.*@pureftpwho=$pureftpd_install_dir/sbin/pure-ftpwho@" /etc/init.d/pureftpd
     sed -i "s@/etc/pure-ftpd.conf@$pureftpd_install_dir/etc/pure-ftpd.conf@" /etc/init.d/pureftpd
     chmod +x /etc/init.d/pureftpd
-    OS_CentOS='chkconfig --add pureftpd \n
-chkconfig pureftpd on'
+    [ "$OS" == 'CentOS' ] && { chkconfig --add pureftpd; chkconfig pureftpd on; }
+    [[ $OS =~ ^Ubuntu$|^Debian$ ]] && { sed -i 's@^. /etc/rc.d/init.d/functions@. /lib/lsb/init-functions@' /etc/init.d/pureftpd; [ -z "`grep ^'# Default-Start' /etc/init.d/pureftpd`" ] && sed -i "s@^# chkconfig.*@# chkconfig&\n# Default-Start: 2 3 4 5\n# Default-Stop: 0 1 6@" /etc/init.d/pureftpd; update-rc.d pureftpd defaults; }
     [ "$Debian_version" == '7' ] && sed -i 's@/var/lock/subsys/@/var/lock/@g' /etc/init.d/pureftpd 
-    OS_Debian_Ubuntu="sed -i 's@^. /etc/rc.d/init.d/functions@. /lib/lsb/init-functions@' /etc/init.d/pureftpd \n
-update-rc.d pureftpd defaults"
-    OS_command
     cd ../../
 
     /bin/cp config/pure-ftpd.conf $pureftpd_install_dir/etc
@@ -52,16 +49,15 @@ update-rc.d pureftpd defaults"
         if [ -z "`grep '20000:30000' /etc/sysconfig/iptables`" ];then
             iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
             iptables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT
+            service iptables save
         fi
-    elif [ $OS == 'Debian' -o $OS == 'Ubuntu' ];then
+    elif [[ $OS =~ ^Ubuntu$|^Debian$ ]];then 
         if [ -z "`grep '20000:30000' /etc/iptables.up.rules`" ];then
             iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
             iptables -I INPUT 6 -p tcp -m state --state NEW -m tcp --dport 20000:30000 -j ACCEPT
+            iptables-save > /etc/iptables.up.rules
         fi
     fi
-    OS_CentOS='service iptables save'
-    OS_Debian_Ubuntu='iptables-save > /etc/iptables.up.rules'
-    OS_command
 else
     rm -rf $pureftpd_install_dir
     echo "${CFAILURE}Pure-Ftp install failed, Please contact the author! ${CEND}"

+ 2 - 8
include/redis.sh

@@ -36,14 +36,8 @@ if [ -f "src/redis-server" ];then
     echo "${CSUCCESS}Redis-server install successfully! ${CEND}"
     cd ..
     rm -rf redis-$redis_version
-    OS_CentOS='/bin/cp ../init.d/Redis-server-init-CentOS /etc/init.d/redis-server \n
-chkconfig --add redis-server \n
-chkconfig redis-server on'
-    OS_Debian_Ubuntu="useradd -M -s /sbin/nologin redis \n
-chown -R redis:redis $redis_install_dir/var/ \n
-/bin/cp ../init.d/Redis-server-init-Ubuntu /etc/init.d/redis-server \n
-update-rc.d redis-server defaults"
-    OS_command
+    [ "$OS" == 'CentOS' ] && { /bin/cp ../init.d/Redis-server-init-CentOS /etc/init.d/redis-server; chkconfig --add redis-server; chkconfig redis-server on; } 
+    [[ $OS =~ ^Ubuntu$|^Debian$ ]] && { useradd -M -s /sbin/nologin redis; chown -R redis:redis $redis_install_dir/var/; /bin/cp ../init.d/Redis-server-init-Ubuntu /etc/init.d/redis-server; update-rc.d redis-server defaults; } 
     sed -i "s@/usr/local/redis@$redis_install_dir@g" /etc/init.d/redis-server
     #[ -z "`grep 'vm.overcommit_memory' /etc/sysctl.conf`" ] && echo 'vm.overcommit_memory = 1' >> /etc/sysctl.conf
     #sysctl -p

+ 2 - 6
include/tengine.sh

@@ -56,12 +56,8 @@ fi
 [ -n "`grep ^'export PATH=' /etc/profile`" -a -z "`grep $tengine_install_dir /etc/profile`" ] && sed -i "s@^export PATH=\(.*\)@export PATH=$tengine_install_dir/sbin:\1@" /etc/profile
 . /etc/profile
 
-OS_CentOS='/bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx \n
-chkconfig --add nginx \n
-chkconfig nginx on'
-OS_Debian_Ubuntu='/bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx \n
-update-rc.d nginx defaults'
-OS_command
+[ "$OS" == 'CentOS' ] && { /bin/cp ../init.d/Nginx-init-CentOS /etc/init.d/nginx; chkconfig --add nginx; chkconfig nginx on; } 
+[[ $OS =~ ^Ubuntu$|^Debian$ ]] && { /bin/cp ../init.d/Nginx-init-Ubuntu /etc/init.d/nginx; update-rc.d nginx defaults; } 
 cd ..
 
 sed -i "s@/usr/local/nginx@$tengine_install_dir@g" /etc/init.d/nginx

+ 7 - 11
include/tomcat-7.sh

@@ -35,9 +35,8 @@ if [ -e "$tomcat_install_dir/conf/server.xml" ];then
     jar cf ../catalina.jar ./*
     cd ../../bin 
     rm -rf $tomcat_install_dir/lib/catalina 
-    OS_CentOS='yum -y install apr apr-devel'
-    OS_Debian_Ubuntu='apt-get -y install libapr1-dev libaprutil1-dev'
-    OS_command
+    [ "$OS" == 'CentOS' ] && yum -y install apr apr-devel 
+    [[ $OS =~ ^Ubuntu$|^Debian$ ]] && apt-get -y install libapr1-dev libaprutil1-dev
     tar xzf tomcat-native.tar.gz 
     cd tomcat-native-*-src/jni/native/
     rm -rf /usr/local/apr
@@ -64,15 +63,14 @@ EOF
             if [ "$OS" == 'CentOS' ];then
                 if [ -z "`grep -w '8080' /etc/sysconfig/iptables`" ];then
                     iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
+                    service iptables save
                 fi
-            elif [ $OS == 'Debian' -o $OS == 'Ubuntu' ];then
+            elif [[ $OS =~ ^Ubuntu$|^Debian$ ]];then 
                 if [ -z "`grep -w '8080' /etc/iptables.up.rules`" ];then
                     iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
+                    iptables-save > /etc/iptables.up.rules
                 fi
             fi
-            OS_CentOS='service iptables save'
-            OS_Debian_Ubuntu='iptables-save > /etc/iptables.up.rules'
-            OS_command
         fi
 
         [ ! -d "$tomcat_install_dir/conf/vhost" ] && mkdir $tomcat_install_dir/conf/vhost
@@ -111,10 +109,8 @@ EOF
         sed -i "s@JAVA_HOME=.*@JAVA_HOME=$JAVA_HOME@" /etc/init.d/tomcat
         sed -i "s@^CATALINA_HOME=.*@CATALINA_HOME=$tomcat_install_dir@" /etc/init.d/tomcat
         sed -i "s@^TOMCAT_USER=.*@TOMCAT_USER=$run_user@" /etc/init.d/tomcat
-        OS_CentOS='chkconfig --add tomcat \n
-        chkconfig tomcat on'
-        OS_Debian_Ubuntu='update-rc.d tomcat defaults'
-        OS_command
+        [ "$OS" == 'CentOS' ] && { chkconfig --add tomcat; chkconfig tomcat on; } 
+        [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d tomcat defaults 
         echo "${CSUCCESS}Tomcat install successfully! ${CEND}"
     fi
 else

+ 7 - 11
include/tomcat-8.sh

@@ -35,9 +35,8 @@ if [ -e "$tomcat_install_dir/conf/server.xml" ];then
     jar cf ../catalina.jar ./*
     cd ../../bin 
     rm -rf $tomcat_install_dir/lib/catalina 
-    OS_CentOS='yum -y install apr apr-devel'
-    OS_Debian_Ubuntu='apt-get -y install libapr1-dev libaprutil1-dev'
-    OS_command
+    [ "$OS" == 'CentOS' ] && yum -y install apr apr-devel 
+    [[ $OS =~ ^Ubuntu$|^Debian$ ]] && apt-get -y install libapr1-dev libaprutil1-dev 
     tar xzf tomcat-native.tar.gz 
     cd tomcat-native-*-src/jni/native/
     rm -rf /usr/local/apr
@@ -64,15 +63,14 @@ EOF
             if [ "$OS" == 'CentOS' ];then
                 if [ -z "`grep -w '8080' /etc/sysconfig/iptables`" ];then
                     iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
+                    service iptables save
                 fi
-            elif [ $OS == 'Debian' -o $OS == 'Ubuntu' ];then
+            elif [[ $OS =~ ^Ubuntu$|^Debian$ ]];then 
                 if [ -z "`grep -w '8080' /etc/iptables.up.rules`" ];then
                     iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
+                    iptables-save > /etc/iptables.up.rules
                 fi
             fi
-            OS_CentOS='service iptables save'
-            OS_Debian_Ubuntu='iptables-save > /etc/iptables.up.rules'
-            OS_command
         fi
 
         [ ! -d "$tomcat_install_dir/conf/vhost" ] && mkdir $tomcat_install_dir/conf/vhost
@@ -111,10 +109,8 @@ EOF
         sed -i "s@JAVA_HOME=.*@JAVA_HOME=$JAVA_HOME@" /etc/init.d/tomcat
         sed -i "s@^CATALINA_HOME=.*@CATALINA_HOME=$tomcat_install_dir@" /etc/init.d/tomcat
         sed -i "s@^TOMCAT_USER=.*@TOMCAT_USER=$run_user@" /etc/init.d/tomcat
-        OS_CentOS='chkconfig --add tomcat \n
-        chkconfig tomcat on'
-        OS_Debian_Ubuntu='update-rc.d tomcat defaults'
-        OS_command
+        [ "$OS" == 'CentOS' ] && { chkconfig --add tomcat;chkconfig tomcat on; } 
+        [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d tomcat defaults
         echo "${CSUCCESS}Tomcat install successfully! ${CEND}"
     fi
 else

+ 2 - 2
install.sh

@@ -533,7 +533,7 @@ if [ "$ionCube_yn" == 'y' ];then
 fi
 
 # PHP opcode cache
-if [ "$PHP_cache" == '1' ] && [ "$PHP_version" == '1' -o "$PHP_version" == '2' ];then
+if [ "$PHP_cache" == '1' ] && [[ "$PHP_version" =~ ^[1,2]$ ]];then
     . include/zendopcache.sh
     Install_ZendOPcache 2>&1 | tee -a $oneinstack_dir/install.log
 elif [ "$PHP_cache" == '2' ];then
@@ -636,7 +636,7 @@ echo "####################Congratulations########################"
 [ "$Web_yn" == 'y' -a "$Nginx_version" != '3' -a "$Apache_version" == '3' ] && echo -e "\n`printf "%-32s" "Nginx/Tengine install dir":`${CMSG}$web_install_dir${CEND}"
 [ "$Web_yn" == 'y' -a "$Nginx_version" != '3' -a "$Apache_version" != '3' ] && echo -e "\n`printf "%-32s" "Nginx/Tengine install dir":`${CMSG}$web_install_dir${CEND}\n`printf "%-32s" "Apache install  dir":`${CMSG}$apache_install_dir${CEND}" 
 [ "$Web_yn" == 'y' -a "$Nginx_version" == '3' -a "$Apache_version" != '3' ] && echo -e "\n`printf "%-32s" "Apache install dir":`${CMSG}$apache_install_dir${CEND}"
-[ "$Tomcat_version" == '1' -o "$Tomcat_version" == '2' ] && echo -e "\n`printf "%-32s" "Tomcat install dir":`${CMSG}$tomcat_install_dir${CEND}"
+[[ "$Tomcat_version" =~ ^[1,2]$ ]] && echo -e "\n`printf "%-32s" "Tomcat install dir":`${CMSG}$tomcat_install_dir${CEND}"
 [ "$DB_yn" == 'y' ] && echo -e "\n`printf "%-32s" "Database install dir:"`${CMSG}$db_install_dir${CEND}"
 [ "$DB_yn" == 'y' ] && echo "`printf "%-32s" "Database data dir:"`${CMSG}$db_data_dir${CEND}"
 [ "$DB_yn" == 'y' ] && echo "`printf "%-32s" "Database user:"`${CMSG}root${CEND}"

+ 4 - 4
pureftpd_vhost.sh

@@ -99,7 +99,7 @@ What Are You Doing?
             [ -e "$Passwdfile" ] && [ -n "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] is already existed! ${CEND}"; continue; } 
             PASSWORD;DIRECTORY
             $FTP_bin useradd $User -f $Passwdfile -u $run_user -g $run_user -d $Directory -m < $FTP_tmp_passfile
-            $FTP_bin -f $Passwdfile -F $Puredbfile > /dev/null 2>&1 
+            $FTP_bin mkdb $Puredbfile -f $Passwdfile > /dev/null 2>&1 
             echo "#####################################"
             echo
             echo "[$User] create successful! "
@@ -115,7 +115,7 @@ What Are You Doing?
             [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] was not existed! ${CEND}"; continue; }
             DIRECTORY
             $FTP_bin usermod $User -f $Passwdfile -d $Directory -m 
-            $FTP_bin -f $Passwdfile -F $Puredbfile > /dev/null 2>&1 
+            $FTP_bin mkdb $Puredbfile -f $Passwdfile > /dev/null 2>&1 
             echo "#####################################"
             echo
             echo "[$User] modify a successful! "
@@ -130,7 +130,7 @@ What Are You Doing?
             [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] was not existed! ${CEND}"; continue; }
             PASSWORD
             $FTP_bin passwd $User -f $Passwdfile -m < $FTP_tmp_passfile
-            $FTP_bin -f $Passwdfile -F $Puredbfile > /dev/null 2>&1 
+            $FTP_bin mkdb $Puredbfile -f $Passwdfile > /dev/null 2>&1 
             echo "#####################################"
             echo
             echo "[$User] Password changed successfully! "
@@ -150,7 +150,7 @@ What Are You Doing?
             USER
             [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] was not existed! ${CEND}"; continue; } 
             $FTP_bin userdel $User -f $Passwdfile -m
-            $FTP_bin -f $Passwdfile -F $Puredbfile > /dev/null 2>&1
+            $FTP_bin mkdb $Puredbfile -f $Passwdfile > /dev/null 2>&1
             echo
             echo "[$User] have been deleted! "
             ;;

+ 9 - 17
shadowsocks.sh

@@ -38,7 +38,7 @@ if [ "$OS" == 'CentOS' ]; then
     do
         yum -y install $Package
     done
-elif [ $OS == 'Debian' -o $OS == 'Ubuntu' ];then
+elif [[ $OS =~ ^Ubuntu$|^Debian$ ]];then 
     apt-get -y update
     for Package in python-dev python-pip curl wget unzip gcc swig automake make perl cpio
     do
@@ -49,11 +49,7 @@ fi
 src_url=http://mirrors.linuxeye.com/oneinstack/src/ez_setup.py && Download_src
 
 which pip > /dev/null 2>&1
-if [ $? -ne 0 ]; then
-    OS_CentOS='python ez_setup.py install \n
-easy_install pip'
-    OS_command
-fi
+[ $? -ne 0 ] && [ "$OS" == 'CentOS' ] && { python ez_setup.py install; sleep 1; easy_install pip; }
 
 if [ -f /usr/bin/pip ]; then
     pip install M2Crypto
@@ -63,10 +59,8 @@ if [ -f /usr/bin/pip ]; then
     if [ -f /usr/bin/ssserver -o -f /usr/local/bin/ssserver ]; then
         /bin/cp ../init.d/Shadowsocks-init /etc/init.d/shadowsocks
         chmod +x /etc/init.d/shadowsocks
-        OS_CentOS='chkconfig --add shadowsocks \n
-chkconfig shadowsocks on'
-        OS_Debian_Ubuntu="update-rc.d shadowsocks defaults"
-        OS_command
+        [ "$OS" == 'CentOS' ] && { chkconfig --add shadowsocks; chkconfig shadowsocks on; }
+        [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d shadowsocks defaults
         [ ! -e /usr/bin/ssserver -a -e /usr/local/bin/ssserver ] && sed -i 's@Shadowsocks_bin=.*@Shadowsocks_bin=/usr/local/bin/ssserver@' /etc/init.d/shadowsocks
     else
         echo
@@ -90,9 +84,8 @@ done
 
 if [ "$Shadowsocks_yn" == 'y' ]; then
     [ -n "`ps -ef | grep -v grep | grep -i "ssserver"`" ] && /etc/init.d/shadowsocks stop
-    OS_CentOS='chkconfig --del shadowsocks'
-    OS_Debian_Ubuntu="update-rc.d -f shadowsocks remove"
-    OS_command
+    [ "$OS" == 'CentOS' ] && chkconfig --del shadowsocks 
+    [[ $OS =~ ^Ubuntu$|^Debian$ ]] && update-rc.d -f shadowsocks remove 
 
     rm -rf /etc/shadowsocks.json /var/run/shadowsocks.pid /etc/init.d/shadowsocks
     pip uninstall -y shadowsocks
@@ -144,18 +137,17 @@ done
 if [ "$OS" == 'CentOS' ];then
     if [ -z "`grep -E $Shadowsocks_port /etc/sysconfig/iptables`" ];then
         iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport $Shadowsocks_port -j ACCEPT
+        service iptables save 
     fi
-elif [ $OS == 'Debian' -o $OS == 'Ubuntu' ];then
+elif [[ $OS =~ ^Ubuntu$|^Debian$ ]];then 
     if [ -z "`grep -E $Shadowsocks_port /etc/iptables.up.rules`" ];then
         iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport $Shadowsocks_port -j ACCEPT
+        iptables-save > /etc/iptables.up.rules 
     fi
 else
     echo "${CWARNING}This port is already in iptables${CEND}"
 fi
 
-OS_CentOS='service iptables save'
-OS_Debian_Ubuntu='iptables-save > /etc/iptables.up.rules'
-OS_command
 }
 
 Config_shadowsocks(){

+ 6 - 6
uninstall.sh

@@ -89,7 +89,7 @@ echo "${CMSG}Web uninstall completed${CEND}"
 }
 
 Print_DB() {
-[ -e "$db_install_dir" ] && echo "$db_install_dir" || { echo;echo "${CWARNING}The database is not installed${CEND}";echo;exit; } 
+[ -e "$db_install_dir" ] && echo "$db_install_dir"
 [ -e "/etc/init.d/mysqld" ] && echo "/etc/init.d/mysqld"
 [ -e "/etc/my.cnf" ] && echo "/etc/my.cnf"
 }
@@ -104,7 +104,7 @@ echo "${CMSG}DB uninstall completed${CEND}"
 }
 
 Print_PHP() {
-[ -e "$php_install_dir" ] && echo "$php_install_dir" || { echo;echo "${CWARNING}The PHP is not installed${CEND}";echo;exit; } 
+[ -e "$php_install_dir" ] && echo "$php_install_dir"
 [ -e "/etc/init.d/php-fpm" ] && echo "/etc/init.d/php-fpm"
 [ -e "/usr/local/imagemagick" ] && echo "/usr/local/imagemagick"
 [ -e "/usr/local/graphicsmagick" ] && echo '/usr/local/graphicsmagick'
@@ -120,7 +120,7 @@ echo "${CMSG}PHP uninstall completed${CEND}"
 }
 
 Print_HHVM() {
-[ -e "/usr/bin/hhvm" ] && echo "/usr/bin/hhvm" || { echo;echo "${CWARNING}The HHVM is not installed${CEND}";echo;exit; } 
+[ -e "/usr/bin/hhvm" ] && echo "/usr/bin/hhvm"
 [ -e "/etc/hhvm" ] && echo "/etc/hhvm"
 [ -e "/var/log/hhvm" ] && echo "/var/log/hhvm"
 [ -e "/etc/supervisord.conf" ] && echo "/etc/supervisord.conf"
@@ -134,7 +134,7 @@ echo "${CMSG}HHVM uninstall completed${CEND}"
 }
 
 Print_PureFtpd() {
-[ -e "$pureftpd_install_dir" ] && echo "$pureftpd_install_dir" || { echo;echo "${CWARNING}The PureFtpd is not installed${CEND}";echo;exit; } 
+[ -e "$pureftpd_install_dir" ] && echo "$pureftpd_install_dir"
 [ -e "/etc/init.d/pureftpd" ] && echo "/etc/init.d/pureftpd" 
 }
 
@@ -144,7 +144,7 @@ echo "${CMSG}Pureftpd uninstall completed${CEND}"
 }
 
 Print_Redis() {
-[ -e "$redis_install_dir" ] && echo "$redis_install_dir" || { echo;echo "${CWARNING}The Redis is not installed${CEND}";echo;exit; } 
+[ -e "$redis_install_dir" ] && echo "$redis_install_dir"
 [ -e "/etc/init.d/redis-server" ] && echo "/etc/init.d/redis-server"
 }
 
@@ -154,7 +154,7 @@ echo "${CMSG}Redis uninstall completed${CEND}"
 }
 
 Print_Memcached() {
-[ -e "$memcached_install_dir" ] && echo "$memcached_install_dir" || { echo;echo "${CWARNING}The Memcached is not installed${CEND}";echo;exit; } 
+[ -e "$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"
 }