Browse Source

delete web_install_dir db_install_dir db_data_dir

lj2007331 9 years ago
parent
commit
be452e00ad

+ 33 - 33
backup.sh

@@ -2,60 +2,60 @@
 # Author:  yeho <lj2007331 AT gmail.com>
 # BLOG:  https://blog.linuxeye.com
 #
-# Version: 1.0-Alpha Jun 15,2015 lj2007331 AT gmail.com
 # Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
 #
 # Project home page:
 #       http://oneinstack.com
+#       https://github.com/lj2007331/oneinstack
 
 cd tools
 . ../options.conf
 
 DB_Local_BK() {
-	for D in `echo $db_name | tr ',' ' '`
-	do
-		./db_bk.sh $D
-	done
+    for D in `echo $db_name | tr ',' ' '`
+    do
+        ./db_bk.sh $D
+    done
 }
 
 DB_Remote_BK() {
-        for D in `echo $db_name | tr ',' ' '`
-        do
-                ./db_bk.sh $D
-		DB_GREP="DB_${D}_`date +%Y`"
-                DB_FILE=`ls -lrt $backup_dir | grep ${DB_GREP} | tail -1 | awk '{print $NF}'`
-                echo "file:::$backup_dir/$DB_FILE $backup_dir push" >> config_bakcup.txt
-                echo "com:::[ -e "$backup_dir/$DB_FILE" ] && rm -rf $backup_dir/DB_${D}_$(date +%Y%m%d --date="$expired_days days ago")_*.tgz" >> config_bakcup.txt
-        done
+    for D in `echo $db_name | tr ',' ' '`
+    do
+        ./db_bk.sh $D
+        DB_GREP="DB_${D}_`date +%Y`"
+        DB_FILE=`ls -lrt $backup_dir | grep ${DB_GREP} | tail -1 | awk '{print $NF}'`
+        echo "file:::$backup_dir/$DB_FILE $backup_dir push" >> config_bakcup.txt
+        echo "com:::[ -e "$backup_dir/$DB_FILE" ] && rm -rf $backup_dir/DB_${D}_$(date +%Y%m%d --date="$expired_days days ago")_*.tgz" >> config_bakcup.txt
+    done
 }
 
 WEB_Local_BK() {
-	for W in `echo $website_name | tr ',' ' '`
-        do
-                ./website_bk.sh $W
-        done
+    for W in `echo $website_name | tr ',' ' '`
+    do
+        ./website_bk.sh $W
+    done
 }
 
 WEB_Remote_BK() {
-        for W in `echo $website_name | tr ',' ' '`
-        do
-                echo "file:::$wwwroot_dir/$W $backup_dir push" >> config_bakcup.txt
-        done
+    for W in `echo $website_name | tr ',' ' '`
+    do
+        echo "file:::$wwwroot_dir/$W $backup_dir push" >> config_bakcup.txt
+    done
 }
 
 if [ "$local_bankup_yn" == 'y' -a "$remote_bankup_yn" == 'n' ];then
-	WEB_Local_BK
-	DB_Local_BK
+    WEB_Local_BK
+    DB_Local_BK
 elif [ "$local_bankup_yn" == 'n' -a "$remote_bankup_yn" == 'y' ];then
-	echo "com:::[ ! -e "$backup_dir" ] && mkdir -p $backup_dir" > config_bakcup.txt
-	DB_Remote_BK
-	WEB_Remote_BK
-	./mabs.sh -c config_bakcup.txt -T -1 | tee mabs.log
+    echo "com:::[ ! -e "$backup_dir" ] && mkdir -p $backup_dir" > config_bakcup.txt
+    DB_Remote_BK
+    WEB_Remote_BK
+    ./mabs.sh -c config_bakcup.txt -T -1 | tee mabs.log
 elif [ "$local_bankup_yn" == 'y' -a "$remote_bankup_yn" == 'y' ];then
-	echo "com:::[ ! -e "$backup_dir" ] && mkdir -p $backup_dir" > config_bakcup.txt
-	WEB_Local_BK
-	WEB_Remote_BK
-	DB_Local_BK
-	DB_Remote_BK
-	./mabs.sh -c config_bakcup.txt -T -1 | tee mabs.log	
+    echo "com:::[ ! -e "$backup_dir" ] && mkdir -p $backup_dir" > config_bakcup.txt
+    WEB_Local_BK
+    WEB_Remote_BK
+    DB_Local_BK
+    DB_Remote_BK
+    ./mabs.sh -c config_bakcup.txt -T -1 | tee mabs.log	
 fi

+ 103 - 86
backup_setup.sh

@@ -2,26 +2,42 @@
 # Author:  yeho <lj2007331 AT gmail.com>
 # BLOG:  https://blog.linuxeye.com
 #
-# Version: 1.0-Alpha Jun 15,2015 lj2007331 AT gmail.com
 # Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
 #
 # Project home page:
 #       http://oneinstack.com
+#       https://github.com/lj2007331/oneinstack
+
+export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+clear
+printf "
+#######################################################################
+#       OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+      #
+#                     Setup the backup parameters                     #
+#       For more information please visit http://oneinstack.com       #
+#######################################################################
+"
+
+. ./include/color.sh
+. ./include/check_db.sh
+
+# Check if user is root
+[ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; }
 
 while : 
 do
-	echo
-	echo 'Please select your backup destination:'
-	echo -e "\t\033[32m1\033[0m. Only Localhost"
-	echo -e "\t\033[32m2\033[0m. Only Remote host"
-	echo -e "\t\033[32m3\033[0m. Localhost and remote host"
-	read -p "Please input a number:(Default 1 press Enter) " DESC_BK 
-	[ -z "$DESC_BK" ] && DESC_BK=1
-	if [ $DESC_BK != 1 -a $DESC_BK != 2 -a $DESC_BK != 3 ];then
-	        echo -e "\033[31minput error! Please only input number 1,2,3\033[0m"
-	else
-	        break
-	fi
+    echo
+    echo 'Please select your backup destination:'
+    echo -e "\t${CMSG}1${CEND}. Only Localhost"
+    echo -e "\t${CMSG}2${CEND}. Only Remote host"
+    echo -e "\t${CMSG}3${CEND}. Localhost and remote host"
+    read -p "Please input a number:(Default 1 press Enter) " DESC_BK 
+    [ -z "$DESC_BK" ] && DESC_BK=1
+    if [ $DESC_BK != 1 -a $DESC_BK != 2 -a $DESC_BK != 3 ];then
+        echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
+    else
+        break
+    fi
 done
 
 [ "$DESC_BK" == '1' ] && { sed -i 's@^local_bankup_yn=.*@local_bankup_yn=y@' ./options.conf; sed -i 's@remote_bankup_yn=.*@remote_bankup_yn=n@' ./options.conf; }
@@ -29,101 +45,102 @@ done
 [ "$DESC_BK" == '3' ] && { sed -i 's@^local_bankup_yn=.*@local_bankup_yn=y@' ./options.conf; sed -i 's@remote_bankup_yn=.*@remote_bankup_yn=y@' ./options.conf; }
 
 . ./options.conf
+. ./include/check_db.sh
 
 while :
 do
-	echo
-	echo "Please enter the directory for save the backup file: "
-	read -p "(Default directory: $backup_dir): " NEW_backup_dir 
-	[ -z "$NEW_backup_dir" ] && NEW_backup_dir="$backup_dir"
-        if [ -z "`echo $NEW_backup_dir| grep '^/'`" ]; then
-                echo -e "\033[31minput error! \033[0m"
-        else
-                break
-        fi
+    echo
+    echo "Please enter the directory for save the backup file: "
+    read -p "(Default directory: $backup_dir): " NEW_backup_dir 
+    [ -z "$NEW_backup_dir" ] && NEW_backup_dir="$backup_dir"
+    if [ -z "`echo $NEW_backup_dir| grep '^/'`" ]; then
+        echo "${CWARNING}input error! ${CEND}"
+    else
+        break
+    fi
 done
 sed -i "s@^backup_dir=.*@backup_dir=$NEW_backup_dir@" ./options.conf
 
 while :
 do
-	echo
-	echo "Pleas enter a valid backup number of days: "
-	read -p "(Default days: 5): " expired_days 
-	[ -z "$expired_days" ] && expired_days=5
-	[ -n "`echo $expired_days | sed -n "/^[0-9]\+$/p"`" ] && break || echo -e "\033[31minput error! Please only enter numbers! \033[0m"
+    echo
+    echo "Pleas enter a valid backup number of days: "
+    read -p "(Default days: 5): " expired_days 
+    [ -z "$expired_days" ] && expired_days=5
+    [ -n "`echo $expired_days | sed -n "/^[0-9]\+$/p"`" ] && break || echo "${CWARNING}input error! Please only enter numbers! ${CEND}"
 done
 sed -i "s@^expired_days=.*@expired_days=$expired_days@" ./options.conf
 
-databases=`$db_install_dir/bin/mysql -uroot -p$dbrootpwd -e "show databases\G" | grep Database | awk '{print $2}' | grep -Evw "(performance_schema|information_schema|mysql|ftpusers)"`
+databases=`$db_install_dir/bin/mysql -uroot -p$dbrootpwd -e "show databases\G" | grep Database | awk '{print $2}' | grep -Evw "(performance_schema|information_schema|mysql)"`
 while :
 do
-	echo
-	echo "Please enter one or more name for database, separate multiple database names with commas: "
-	read -p "(Default database: `echo $databases | tr ' ' ','`) " db_name
-	db_name=`echo $db_name | tr -d ' '`
-	[ -z "$db_name" ] && db_name="`echo $databases | tr ' ' ','`"
-	D_tmp=0
-	echo $db_name
-	for D in `echo $db_name | tr ',' ' '`
-	do
-		[ -z "`echo $databases | grep -w $D`" ] && { echo -e "\033[31m$D not exist! \033[0m" ; D_tmp=1; }
-	done
-	[ "$D_tmp" != '1' ] && break
+    echo
+    echo "Please enter one or more name for database, separate multiple database names with commas: "
+    read -p "(Default database: `echo $databases | tr ' ' ','`) " db_name
+    db_name=`echo $db_name | tr -d ' '`
+    [ -z "$db_name" ] && db_name="`echo $databases | tr ' ' ','`"
+    D_tmp=0
+    echo $db_name
+    for D in `echo $db_name | tr ',' ' '`
+    do
+        [ -z "`echo $databases | grep -w $D`" ] && { echo "${CWARNING}$D was not exist! ${CEND}" ; D_tmp=1; }
+    done
+    [ "$D_tmp" != '1' ] && break
 done
 sed -i "s@^db_name=.*@db_name=$db_name@" ./options.conf
 
 websites=`ls $wwwroot_dir | grep -vw default`
 while :
 do
-        echo
-        echo "Please enter one or more name for website, separate multiple website names with commas: "
-        read -p "(Default website: `echo $websites | tr ' ' ','`) " website_name 
-        website_name=`echo $website_name | tr -d ' '`
-        [ -z "$website_name" ] && website_name="`echo $websites | tr ' ' ','`"
-        W_tmp=0
-        echo $db_name
-        for W in `echo $website_name | tr ',' ' '`
-        do
-                [ ! -e "$wwwroot_dir/$W" ] && { echo -e "\033[31m$wwwroot_dir/$W not exist! \033[0m" ; W_tmp=1; }
-        done
-        [ "$W_tmp" != '1' ] && break
+    echo
+    echo "Please enter one or more name for website, separate multiple website names with commas: "
+    read -p "(Default website: `echo $websites | tr ' ' ','`) " website_name 
+    website_name=`echo $website_name | tr -d ' '`
+    [ -z "$website_name" ] && website_name="`echo $websites | tr ' ' ','`"
+    W_tmp=0
+    echo $db_name
+    for W in `echo $website_name | tr ',' ' '`
+    do
+        [ ! -e "$wwwroot_dir/$W" ] && { echo -e "\033[31m$wwwroot_dir/$W not exist! \033[0m" ; W_tmp=1; }
+    done
+    [ "$W_tmp" != '1' ] && break
 done
 echo $website_name
 sed -i "s@^website_name=.*@website_name=$website_name@" ./options.conf
 
 if [ "$remote_bankup_yn" == 'y' ];then
-	> tools/iplist.txt
-	while :
-	do
-		echo
-		read -p "Please enter the remote host ip: " remote_ip
-		[ -z "$remote_ip" -o "$remote_ip" == '127.0.0.1' ] && continue
-		echo
-		read -p "Please enter the remote host port(Default: 22) : " remote_port
-		[ -z "$remote_port" ] && remote_port=22 
-		echo
-		read -p "Please enter the remote host user(Default: root) : " remote_user
-		[ -z "$remote_user" ] && remote_user=root 
-		echo
-		read -p "Please enter the remote host password: " remote_password
-	        IPcode=$(echo "ibase=16;$(echo "$remote_ip" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
-	        Portcode=$(echo "ibase=16;$(echo "$remote_port" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
-	        PWcode=$(echo "ibase=16;$(echo "$remote_password" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
-		[ -e "~/.ssh/known_hosts" ] && grep $remote_ip ~/.ssh/known_hosts | sed -i "/$remote_ip/d" ~/.ssh/known_hosts
-		./tools/mssh.exp ${IPcode}P $remote_user ${PWcode}P ${Portcode}P true 10
-		if [ $? -eq 0 ];then
-			[ -z "`grep $remote_ip tools/iplist.txt`" ] && echo "$remote_ip $remote_port $remote_user $remote_password" >> tools/iplist.txt || echo -e "\033[31m$remote_ip has been added! \033[0m" 
-			while :
-			do
-				echo
-			        read -p "Do you want to add more host ? [y/n]: " more_host_yn 
-			        if [ "$more_host_yn" != 'y' -a "$more_host_yn" != 'n' ];then
-			                echo -e "\033[31minput error! Please only input 'y' or 'n'\033[0m"
-			        else
-					break
-				fi
-			done
-			[ "$more_host_yn" == 'n' ] && break
-		fi
-	done
+    > tools/iplist.txt
+    while :
+    do
+        echo
+        read -p "Please enter the remote host ip: " remote_ip
+        [ -z "$remote_ip" -o "$remote_ip" == '127.0.0.1' ] && continue
+        echo
+        read -p "Please enter the remote host port(Default: 22) : " remote_port
+        [ -z "$remote_port" ] && remote_port=22 
+        echo
+        read -p "Please enter the remote host user(Default: root) : " remote_user
+        [ -z "$remote_user" ] && remote_user=root 
+        echo
+        read -p "Please enter the remote host password: " remote_password
+        IPcode=$(echo "ibase=16;$(echo "$remote_ip" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
+        Portcode=$(echo "ibase=16;$(echo "$remote_port" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
+        PWcode=$(echo "ibase=16;$(echo "$remote_password" | xxd -ps -u)"|bc|tr -d '\\'|tr -d '\n')
+        [ -e "~/.ssh/known_hosts" ] && grep $remote_ip ~/.ssh/known_hosts | sed -i "/$remote_ip/d" ~/.ssh/known_hosts
+        ./tools/mssh.exp ${IPcode}P $remote_user ${PWcode}P ${Portcode}P true 10
+        if [ $? -eq 0 ];then
+            [ -z "`grep $remote_ip tools/iplist.txt`" ] && echo "$remote_ip $remote_port $remote_user $remote_password" >> tools/iplist.txt || echo "${CWARNING}$remote_ip has been added! ${CEND}" 
+            while :
+            do
+                echo
+                read -p "Do you want to add more host ? [y/n]: " more_host_yn 
+                if [ "$more_host_yn" != 'y' -a "$more_host_yn" != 'n' ];then
+                    echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
+                else
+                    break
+                fi
+            done
+            [ "$more_host_yn" == 'n' ] && break
+        fi
+    done
 fi

+ 1 - 2
include/apache-2.2.sh

@@ -50,7 +50,7 @@ if [ "$Nginx_version" == '3' ];then
     sed -i 's/^#ServerName www.example.com:80/ServerName 0.0.0.0:80/' $apache_install_dir/conf/httpd.conf
     TMP_PORT=80
     TMP_IP=$IPADDR
-elif [ "$Nginx_version" == '1' -o "$Nginx_version" == '2' ];then
+elif [ "$Nginx_version" == '1' -o "$Nginx_version" == '2' -o -e "$web_install_dir/sbin/nginx" ];then
     sed -i 's/^#ServerName www.example.com:80/ServerName 127.0.0.1:9090/' $apache_install_dir/conf/httpd.conf
     sed -i 's@^Listen.*@Listen 127.0.0.1:9090@' $apache_install_dir/conf/httpd.conf
     TMP_PORT=9090
@@ -119,7 +119,6 @@ RemoteIPInternalProxy 127.0.0.1
 EOF
     sed -i "s@Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf\nInclude conf/extra/httpd-remoteip.conf@" $apache_install_dir/conf/httpd.conf
 fi
-[ "$Nginx_version" == '3' -a "$Apache_version" != '3' ] && sed -i "s@^web_install_dir.*@web_install_dir=$apache_install_dir@" options.conf
 service httpd start
 cd ..
 }

+ 1 - 2
include/apache-2.4.sh

@@ -63,7 +63,7 @@ if [ "$Nginx_version" == '3' ];then
     sed -i 's/^#ServerName www.example.com:80/ServerName 0.0.0.0:80/' $apache_install_dir/conf/httpd.conf
     TMP_PORT=80
     TMP_IP=$IPADDR
-elif [ "$Nginx_version" == '1' -o "$Nginx_version" == '2' ];then
+elif [ "$Nginx_version" == '1' -o "$Nginx_version" == '2' -o -e "$web_install_dir/sbin/nginx" ];then
     sed -i 's/^#ServerName www.example.com:80/ServerName 127.0.0.1:9090/' $apache_install_dir/conf/httpd.conf
     sed -i 's@^Listen.*@Listen 127.0.0.1:9090@' $apache_install_dir/conf/httpd.conf
     TMP_PORT=9090
@@ -131,7 +131,6 @@ EOF
     sed -i "s@Include conf/extra/httpd-mpm.conf@Include conf/extra/httpd-mpm.conf\nInclude conf/extra/httpd-remoteip.conf@" $apache_install_dir/conf/httpd.conf
     sed -i "s@LogFormat \"%h %l@LogFormat \"%h %a %l@g" $apache_install_dir/conf/httpd.conf
 fi
-[ "$Nginx_version" == '3' -a "$Apache_version" != '3' ] && sed -i "s@^web_install_dir.*@web_install_dir=$apache_install_dir@" options.conf
 service httpd start
 cd ..
 }

+ 13 - 0
include/check_db.sh

@@ -0,0 +1,13 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+#       https://github.com/lj2007331/oneinstack
+
+[ -d "$mysql_install_dir/support-files" ] && { db_install_dir=$mysql_install_dir; db_data_dir=$mysql_data_dir; }
+[ -d "$mariadb_install_dir/support-files" ] && { db_install_dir=$mariadb_install_dir; db_data_dir=$mariadb_data_dir; }
+[ -d "$percona_install_dir/support-files" ] && { db_install_dir=$percona_install_dir; db_data_dir=$percona_data_dir; }

+ 12 - 0
include/check_web.sh

@@ -0,0 +1,12 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# BLOG:  https://blog.linuxeye.com
+#
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+#       https://github.com/lj2007331/oneinstack
+
+[ -e "$nginx_install_dir/sbin/nginx" ] && web_install_dir=$nginx_install_dir
+[ -e "$tengine_install_dir/sbin/nginx" ] && web_install_dir=$tengine_install_dir

+ 0 - 1
include/hhvm_CentOS.sh

@@ -11,7 +11,6 @@
 Install_hhvm_CentOS()
 {
 cd $oneinstack_dir/src
-. ../options.conf
 
 id -u $run_user >/dev/null 2>&1
 [ $? -ne 0 ] && useradd -M -s /sbin/nologin $run_user 

+ 3 - 2
include/mariadb-10.0.sh

@@ -190,7 +190,8 @@ $mariadb_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.db wher
 $mariadb_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.proxies_priv where Host!='localhost';"
 $mariadb_install_dir/bin/mysql -uroot -p$dbrootpwd -e "drop database test;"
 $mariadb_install_dir/bin/mysql -uroot -p$dbrootpwd -e "reset master;"
-sed -i "s@^db_install_dir.*@db_install_dir=$mariadb_install_dir@" options.conf
-sed -i "s@^db_data_dir.*@db_data_dir=$mariadb_data_dir@" options.conf
+rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf
+echo "$mariadb_install_dir/lib" > mariadb.conf 
+ldconfig
 service mysqld stop
 }

+ 3 - 2
include/mariadb-5.5.sh

@@ -190,7 +190,8 @@ $mariadb_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.db wher
 $mariadb_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.proxies_priv where Host!='localhost';"
 $mariadb_install_dir/bin/mysql -uroot -p$dbrootpwd -e "drop database test;"
 $mariadb_install_dir/bin/mysql -uroot -p$dbrootpwd -e "reset master;"
-sed -i "s@^db_install_dir.*@db_install_dir=$mariadb_install_dir@" options.conf
-sed -i "s@^db_data_dir.*@db_data_dir=$mariadb_data_dir@" options.conf
+rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf
+echo "$mariadb_install_dir/lib" > mariadb.conf 
+ldconfig
 service mysqld stop
 }

+ 3 - 2
include/mysql-5.5.sh

@@ -202,7 +202,8 @@ $mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.db where
 $mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.proxies_priv where Host!='localhost';"
 $mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "drop database test;"
 $mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "reset master;"
-sed -i "s@^db_install_dir.*@db_install_dir=$mysql_install_dir@" options.conf
-sed -i "s@^db_data_dir.*@db_data_dir=$mysql_data_dir@" options.conf
+rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf
+echo "$mysql_install_dir/lib" > mysql.conf 
+ldconfig
 service mysqld stop
 }

+ 3 - 2
include/mysql-5.6.sh

@@ -201,7 +201,8 @@ $mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.db where
 $mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.proxies_priv where Host!='localhost';"
 $mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "drop database test;"
 $mysql_install_dir/bin/mysql -uroot -p$dbrootpwd -e "reset master;"
-sed -i "s@^db_install_dir.*@db_install_dir=$mysql_install_dir@" options.conf
-sed -i "s@^db_data_dir.*@db_data_dir=$mysql_data_dir@" options.conf
+rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf
+echo "$mysql_install_dir/lib" > mysql.conf 
+ldconfig
 service mysqld stop
 }

+ 0 - 1
include/nginx.sh

@@ -111,7 +111,6 @@ endscript
 }
 EOF
 
-sed -i "s@^web_install_dir.*@web_install_dir=$nginx_install_dir@" options.conf
 ldconfig
 service nginx start
 }

+ 3 - 2
include/percona-5.5.sh

@@ -202,7 +202,8 @@ $percona_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.db wher
 $percona_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.proxies_priv where Host!='localhost';"
 $percona_install_dir/bin/mysql -uroot -p$dbrootpwd -e "drop database test;"
 $percona_install_dir/bin/mysql -uroot -p$dbrootpwd -e "reset master;"
-sed -i "s@^db_install_dir.*@db_install_dir=$percona_install_dir@" options.conf
-sed -i "s@^db_data_dir.*@db_data_dir=$percona_data_dir@" options.conf
+rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf
+echo "$percona_install_dir/lib" > percona.conf
+ldconfig
 service mysqld stop
 }

+ 3 - 2
include/percona-5.6.sh

@@ -201,7 +201,8 @@ $percona_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.db wher
 $percona_install_dir/bin/mysql -uroot -p$dbrootpwd -e "delete from mysql.proxies_priv where Host!='localhost';"
 $percona_install_dir/bin/mysql -uroot -p$dbrootpwd -e "drop database test;"
 $percona_install_dir/bin/mysql -uroot -p$dbrootpwd -e "reset master;"
-sed -i "s@^db_install_dir.*@db_install_dir=$percona_install_dir@" options.conf
-sed -i "s@^db_data_dir.*@db_data_dir=$percona_data_dir@" options.conf
+rm -rf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf
+echo "$percona_install_dir/lib" > percona.conf
+ldconfig
 service mysqld stop
 }

+ 0 - 1
include/tengine.sh

@@ -100,7 +100,6 @@ endscript
 }
 EOF
 
-sed -i "s@^web_install_dir.*@web_install_dir=$tengine_install_dir@" options.conf
 ldconfig
 service nginx start
 }

+ 85 - 80
install.sh

@@ -24,6 +24,8 @@ sed -i "s@^oneinstack_dir.*@oneinstack_dir=`pwd`@" ./options.conf
 . ./options.conf
 . ./include/color.sh
 . ./include/check_os.sh
+. ./include/check_db.sh
+. ./include/check_web.sh
 . ./include/download.sh
 . ./include/get_char.sh
 
@@ -79,7 +81,7 @@ do
         echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
     else
         if [ "$Web_yn" == 'y' ];then
-            [ -d "$web_install_dir/conf" ] && { echo "${CWARNING}The web service already installed! ${CEND}" ; Web_yn=Other ; break ; }
+            # Nginx/Tegine
             while :
             do
                 echo
@@ -92,69 +94,75 @@ do
                 if [ $Nginx_version != 1 -a $Nginx_version != 2 -a $Nginx_version != 3 ];then
                     echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
                 else
-            	    while :
-            	    do
-                        echo
-                        echo 'Please select Apache server:'
-                        echo -e "\t${CMSG}1${CEND}. Install Apache-2.4"
-                        echo -e "\t${CMSG}2${CEND}. Install Apache-2.2"
-                        echo -e "\t${CMSG}3${CEND}. Do not install"
-                        read -p "Please input a number:(Default 3 press Enter) " Apache_version
-                        [ -z "$Apache_version" ] && Apache_version=3
-                        if [ $Apache_version != 1 -a $Apache_version != 2 -a $Apache_version != 3 ];then
-                            echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
-                        else
-                            break
-                        fi
-            	    done
-                    while :
-                    do
-                        echo
-                        echo 'Please select tomcat server:'
-                        echo -e "\t${CMSG}1${CEND}. Install Tomcat-8"
-                        echo -e "\t${CMSG}2${CEND}. Install Tomcat-7"
-                        echo -e "\t${CMSG}3${CEND}. Do not install"
-                        read -p "Please input a number:(Default 3 press Enter) " Tomcat_version
-                        [ -z "$Tomcat_version" ] && Tomcat_version=3
-                        if [ $Tomcat_version != 1 -a $Tomcat_version != 2 -a $Tomcat_version != 3 ];then
-                            echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
-                        else
-                            if [ "$Tomcat_version" == '1' ];then
-                                while :
-                                do
-                                    echo
-                                    echo 'Please select JDK version:'
-                                    echo -e "\t${CMSG}1${CEND}. Install JDK-1.8"
-                                    echo -e "\t${CMSG}2${CEND}. Install JDK-1.7"
-                                    read -p "Please input a number:(Default 2 press Enter) " JDK_version
-                                    [ -z "$JDK_version" ] && JDK_version=2
-                                    if [ $JDK_version != 1 -a $JDK_version != 2 ];then
-                                        echo "${CWARNING}input error! Please only input number 1,2${CEND}"
-                                    else
-                                        break
-                                    fi
-                                done
+                    [ -e "$nginx_install_dir/sbin/nginx" ] && { echo "${CWARNING}Nginx already installed! ${CEND}"; Nginx_version=Other; }
+                    [ -e "$tengine_install_dir/sbin/nginx" ] && { echo "${CWARNING}Tengine already installed! ${CEND}"; Nginx_version=Other; }
+                    break
+                fi
+            done
+            # Apache
+            while :
+            do
+                echo
+                echo 'Please select Apache server:'
+                echo -e "\t${CMSG}1${CEND}. Install Apache-2.4"
+                echo -e "\t${CMSG}2${CEND}. Install Apache-2.2"
+                echo -e "\t${CMSG}3${CEND}. Do not install"
+                read -p "Please input a number:(Default 3 press Enter) " Apache_version
+                [ -z "$Apache_version" ] && Apache_version=3
+                if [ $Apache_version != 1 -a $Apache_version != 2 -a $Apache_version != 3 ];then
+                    echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
+                else
+                    [ -e "$apache_install_dir/conf/httpd.conf" ] && { echo "${CWARNING}Aapche already installed! ${CEND}"; Apache_version=Other; }  
+                    break
+                fi
+            done
+            # Tomcat
+            while :
+            do
+                echo
+                echo 'Please select tomcat server:'
+                echo -e "\t${CMSG}1${CEND}. Install Tomcat-8"
+                echo -e "\t${CMSG}2${CEND}. Install Tomcat-7"
+                echo -e "\t${CMSG}3${CEND}. Do not install"
+                read -p "Please input a number:(Default 3 press Enter) " Tomcat_version
+                [ -z "$Tomcat_version" ] && Tomcat_version=3
+                if [ $Tomcat_version != 1 -a $Tomcat_version != 2 -a $Tomcat_version != 3 ];then
+                    echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
+                else
+                    [ "$Tomcat_version" != '3' -a -e "$tomcat_install_dir/conf/server.xml" ] && { echo "${CWARNING}Tomcat already installed! ${CEND}" ; Tomcat_version=Other; }  
+                    if [ "$Tomcat_version" == '1' ];then
+                        while :
+                        do
+                            echo
+                            echo 'Please select JDK version:'
+                            echo -e "\t${CMSG}1${CEND}. Install JDK-1.8"
+                            echo -e "\t${CMSG}2${CEND}. Install JDK-1.7"
+                            read -p "Please input a number:(Default 2 press Enter) " JDK_version
+                            [ -z "$JDK_version" ] && JDK_version=2
+                            if [ $JDK_version != 1 -a $JDK_version != 2 ];then
+                                echo "${CWARNING}input error! Please only input number 1,2${CEND}"
+                            else
+                                break
                             fi
-                            if [ "$Tomcat_version" == '2' ];then
-                                while :
-                                do
-                                    echo
-                                    echo 'Please select JDK version:'
-                                    echo -e "\t${CMSG}1${CEND}. Install JDK-1.8"
-                                    echo -e "\t${CMSG}2${CEND}. Install JDK-1.7"
-                                    echo -e "\t${CMSG}3${CEND}. Install JDK-1.6"
-                                    read -p "Please input a number:(Default 2 press Enter) " JDK_version
-                                    [ -z "$JDK_version" ] && JDK_version=2
-                                    if [ $JDK_version != 1 -a $JDK_version != 2 -a $JDK_version != 3 ];then
-                                        echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
-                                    else
-                                        break
-                                    fi
-                                done
+                        done
+                    fi
+                    if [ "$Tomcat_version" == '2' ];then
+                        while :
+                        do
+                            echo
+                            echo 'Please select JDK version:'
+                            echo -e "\t${CMSG}1${CEND}. Install JDK-1.8"
+                            echo -e "\t${CMSG}2${CEND}. Install JDK-1.7"
+                            echo -e "\t${CMSG}3${CEND}. Install JDK-1.6"
+                            read -p "Please input a number:(Default 2 press Enter) " JDK_version
+                            [ -z "$JDK_version" ] && JDK_version=2
+                            if [ $JDK_version != 1 -a $JDK_version != 2 -a $JDK_version != 3 ];then
+                                echo "${CWARNING}input error! Please only input number 1,2,3${CEND}"
+                            else
+                                break
                             fi
-                            break
-                        fi
-                    done
+                        done
+                    fi
                     break
                 fi
             done
@@ -172,7 +180,7 @@ do
         echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
     else
         if [ "$DB_yn" == 'y' ];then
-            [ -d "$db_install_dir/support-files" ] && { echo "${CWARNING}The database already installed! ${CEND}" ; DB_yn=Other ; break ; }
+            [ -d "$db_install_dir/support-files" ] && { echo "${CWARNING}Database already installed! ${CEND}"; DB_yn=Other; break; }
             while :
             do
                 echo
@@ -211,7 +219,7 @@ do
         echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
     else
         if [ "$PHP_yn" == 'y' ];then
-            [ -e "$php_install_dir/bin/phpize" ] && { echo "${CWARNING}The php already installed! ${CEND}" ; PHP_yn=Other ; break ; }
+            [ -e "$php_install_dir/bin/phpize" ] && { echo "${CWARNING}PHP already installed! ${CEND}"; PHP_yn=Other; break; }
             while :
             do
                 echo
@@ -393,7 +401,7 @@ do
     if [ "$FTP_yn" != 'y' -a "$FTP_yn" != 'n' ];then
         echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
     else
-        [ "$FTP_yn" == 'y' -a -e "$pureftpd_install_dir/sbin/pure-ftpwho" ] && { echo "${CWARNING}The FTP service already installed! ${CEND}" ; FTP_yn=Other ; break ; }
+        [ "$FTP_yn" == 'y' -a -e "$pureftpd_install_dir/sbin/pure-ftpwho" ] && { echo "${CWARNING}Pure-FTPd already installed! ${CEND}"; FTP_yn=Other; }
         break
     fi
 done
@@ -406,9 +414,7 @@ do
     if [ "$phpMyAdmin_yn" != 'y' -a "$phpMyAdmin_yn" != 'n' ];then
         echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
     else
-        if [ "$phpMyAdmin_yn" == 'y' ];then
-            [ -d "$wwwroot_dir/default/phpMyAdmin" ] && echo "${CWARNING}The phpMyAdmin already installed! ${CEND}" && phpMyAdmin_yn=Other && break
-        fi
+        [ "$phpMyAdmin_yn" == 'y' -a -d "$wwwroot_dir/default/phpMyAdmin" ] && { echo "${CWARNING}phpMyAdmin already installed! ${CEND}"; phpMyAdmin_yn=Other; } 
         break
     fi
 done
@@ -422,9 +428,7 @@ if [ "$PHP_version" != '5' ];then
         if [ "$redis_yn" != 'y' -a "$redis_yn" != 'n' ];then
             echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
         else
-            if [ "$redis_yn" == 'y' ];then
-                [ -e "$redis_install_dir/bin/redis-server" ] && { echo "${CWARNING}The redis already installed! ${CEND}" ; redis_yn=Other ; break ; }
-            fi
+            [ "$redis_yn" == 'y' -a -e "$redis_install_dir/bin/redis-server" ] && { echo "${CWARNING}Redis already installed! ${CEND}"; redis_yn=Other; }
             break
         fi
     done
@@ -437,16 +441,14 @@ if [ "$PHP_version" != '5' ];then
         if [ "$memcached_yn" != 'y' -a "$memcached_yn" != 'n' ];then
             echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
         else
-            if [ "$memcached_yn" == 'y' ];then
-                [ -d "$memcached_install_dir/include/memcached" ] && { echo "${CWARNING}The memcached already installed! ${CEND}" ; memcached_yn=Other ; break ; }
-            fi
+            [ "$memcached_yn" == 'y' -a -d "$memcached_install_dir/include/memcached" ] && { echo "${CWARNING}Memcached already installed! ${CEND}"; memcached_yn=Other; }
             break
         fi
     done
 fi
 
 # check jemalloc or tcmalloc 
-if [ "$Web_yn" == 'y' -o "$DB_yn" == 'y' ];then
+if [ "$Nginx_version" == '1' -o "$Nginx_version" == '2' -o "$DB_yn" == 'y' ];then
     while :
     do
         echo
@@ -482,6 +484,7 @@ do
         echo "${CWARNING}input error! Please only input 'y' or 'n'${CEND}"
     else
         if [ "$HHVM_yn" == 'y' ];then
+            [ -e "/usr/bin/hhvm" ] && { echo "${CWARNING}HHVM already installed! ${CEND}"; HHVM_yn=Other; }
             if [ "$OS" == 'CentOS' -a "$OS_BIT" == '64' ] && [ -n "`grep -E ' 7\.| 6\.5| 6\.6| 6\.7' /etc/redhat-release`" ];then
                 break
             else
@@ -492,7 +495,7 @@ do
                 HHVM_yn=
                 break
             fi
-        elif [ "$HHVM_yn" == 'n' ];then
+        else
             break
         fi
     fi
@@ -658,22 +661,24 @@ if [ "$memcached_yn" == 'y' ];then
     Install_memcached 2>&1 | tee -a $oneinstack_dir/install.log
 fi
 
-# get db_install_dir and web_install_dir
-. ./options.conf
-
 # index example
 if [ ! -e "$wwwroot_dir/default/index.html" -a "$Web_yn" == 'y' ];then
     . include/demo.sh
     DEMO 2>&1 | tee -a $oneinstack_dir/install.log 
 fi
 
+# get web_install_dir and db_install_dir
+. include/check_db.sh
+. include/check_web.sh
+
+# HHVM
 if [ "$HHVM_yn" == 'y' ];then
     . include/hhvm_CentOS.sh 
     Install_hhvm_CentOS 2>&1 | tee -a $oneinstack_dir/install.log 
 fi
 
 # Starting DB 
-[ -e "$db_install_dir" -a -z "`ps -ef | grep -v grep | grep mysql`" ] && /etc/init.d/mysqld start
+[ -d "$db_install_dir/support-files" -a -z "`ps -ef | grep -v grep | grep mysql`" ] && /etc/init.d/mysqld start
 
 echo "####################Congratulations########################"
 [ "$Web_yn" == 'y' -a "$Nginx_version" != '3' -a "$Apache_version" == '3' ] && echo -e "\n`printf "%-32s" "Nginx/Tengine install dir":`${CMSG}$web_install_dir${CEND}"

+ 0 - 6
options.conf

@@ -36,12 +36,6 @@ wwwlogs_dir=/home/wwwlogs
 
 #########################################################################
 # automatically generated, You can't change 
-web_install_dir=
-
-db_install_dir=
-
-db_data_dir=
-
 dbrootpwd=
 
 #########################################################################

+ 6 - 6
pureftpd_vhost.sh

@@ -112,7 +112,7 @@ What Are You Doing?
 
         2)
             USER
-            [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] is not existed! ${CEND}"; continue; }
+            [ -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 
@@ -127,7 +127,7 @@ What Are You Doing?
 
         3)
             USER
-            [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] is not existed! ${CEND}"; continue; }
+            [ -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 
@@ -142,13 +142,13 @@ What Are You Doing?
 
         4)
             if [ ! -e "$Passwdfile" ];then
-                echo "${CQUESTION}User is not existed! ${CEND}"
+                echo "${CQUESTION}User was not existed! ${CEND}"
             else
                 $FTP_bin list
             fi
             
             USER
-            [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] is not existed! ${CEND}"; continue; } 
+            [ -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
             echo
@@ -157,7 +157,7 @@ What Are You Doing?
 
         5)
             if [ ! -e "$Passwdfile" ];then
-            	echo "${CQUESTION}User is not existed! ${CEND}"
+            	echo "${CQUESTION}User was not existed! ${CEND}"
             else
             	$FTP_bin list
             fi
@@ -165,7 +165,7 @@ What Are You Doing?
 
         6)
             USER
-            [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] is not existed! ${CEND}"; continue; } 
+            [ -e "$Passwdfile" ] && [ -z "`grep ^${User}: $Passwdfile`" ] && { echo "${CQUESTION}[$User] was not existed! ${CEND}"; continue; } 
             $FTP_bin show $User
             ;;
 

+ 1 - 0
reset_db_root_password.sh

@@ -20,6 +20,7 @@ printf "
 
 . ./options.conf
 . ./include/color.sh
+. ./include/check_db.sh
 
 # Check if user is root
 [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; } 

+ 17 - 10
tools/db_bk.sh

@@ -1,8 +1,15 @@
 #!/bin/bash
 # Author:  yeho <lj2007331 AT gmail.com>
-# Blog:  http://blog.linuxeye.com
+# BLOG:  https://blog.linuxeye.com
+#
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+#       https://github.com/lj2007331/oneinstack
 
 . ../options.conf
+. ./include/check_db.sh
 
 DBname=$1
 LogFile=$backup_dir/db.log
@@ -16,18 +23,18 @@ DB_tmp=`$db_install_dir/bin/mysql -uroot -p$dbrootpwd -e "show databases\G" | gr
 [ -z "$DB_tmp" ] && { echo "[$DBname] not exist" >> $LogFile ;  exit 1 ; }
 
 if [ -e "$OldFile" ];then
-	/bin/rm -f $OldFile
-        echo "[$OldFile] Delete Old File Success" >> $LogFile
+    /bin/rm -f $OldFile
+    echo "[$OldFile] Delete Old File Success" >> $LogFile
 else
-        echo "[$OldFile] Delete Old Backup File" >> $LogFile
+    echo "[$OldFile] Delete Old Backup File" >> $LogFile
 fi
 
 if [ -e "$NewFile" ];then
-        echo "[$NewFile] The Backup File is exists,Can't Backup" >> $LogFile
+    echo "[$NewFile] The Backup File is exists,Can't Backup" >> $LogFile
 else
-	$db_install_dir/bin/mysqldump -uroot -p$dbrootpwd --opt --databases $DBname > $DumpFile 
-	cd $backup_dir
-        tar czf $NewFile ${DumpFile##*/} >> $LogFile 2>&1
-        echo "[$NewFile] Backup success ">> $LogFile
-        /bin/rm -f $DumpFile
+    $db_install_dir/bin/mysqldump -uroot -p$dbrootpwd --opt --databases $DBname > $DumpFile 
+    cd $backup_dir
+    tar czf $NewFile ${DumpFile##*/} >> $LogFile 2>&1
+    echo "[$NewFile] Backup success ">> $LogFile
+    /bin/rm -f $DumpFile
 fi

+ 7 - 1
tools/website_bk.sh

@@ -1,6 +1,12 @@
 #!/bin/bash
 # Author:  yeho <lj2007331 AT gmail.com>
-# Blog:  http://blog.linuxeye.com
+# BLOG:  https://blog.linuxeye.com
+#
+# Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
+#
+# Project home page:
+#       http://oneinstack.com
+#       https://github.com/lj2007331/oneinstack
 
 . ../options.conf
 

+ 13 - 12
uninstall.sh

@@ -21,18 +21,20 @@ printf "
 . ./options.conf
 . ./include/color.sh
 . ./include/get_char.sh
+. ./include/check_db.sh
 
 # Check if user is root
 [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; } 
 
 Uninstall()
 {
-[ -e "$db_install_dir" ] && service mysqld stop && rm -rf /etc/init.d/mysqld /etc/my.cnf
-[ -e "$apache_install_dir" ] && service httpd stop && rm -rf /etc/init.d/httpd
+[ -e "$db_install_dir" ] && service mysqld stop && rm -rf /etc/init.d/mysqld /etc/my.cnf /etc/ld.so.conf.d/{mysql,mariadb,percona}*.conf
+[ -e "$apache_install_dir" ] && service httpd stop && rm -rf /etc/init.d/httpd /etc/logrotate.d/apache
 [ -e "$tomcat_install_dir" ] && service tomcat stop && rm -rf /etc/init.d/tomcat
 [ -e "/usr/java" ] && rm -rf /usr/java
-[ -e "$php_install_dir" ] && service php-fpm stop && rm -rf /etc/init.d/php-fpm
-[ -e "$web_install_dir" ] && service nginx stop && rm -rf /etc/init.d/nginx /etc/logrotate.d/nginx
+[ -e "$php_install_dir/bin/phpize" ] && service php-fpm stop && rm -rf /etc/init.d/php-fpm
+[ -e "$nginx_install_dir" ] && service nginx stop && rm -rf /etc/init.d/nginx /etc/logrotate.d/nginx
+[ -e "$tengine_install_dir" ] && service nginx stop && rm -rf /etc/init.d/nginx /etc/logrotate.d/nginx
 [ -e "$pureftpd_install_dir" ] && service pureftpd stop && rm -rf /etc/init.d/pureftpd
 [ -e "$redis_install_dir" ] && service redis-server stop && rm -rf /etc/init.d/redis-server
 [ -e "$memcached_install_dir" ] && service memcached stop && rm -rf /etc/init.d/memcached
@@ -51,12 +53,10 @@ do
 done
 
 sed -i 's@^oneinstack_dir=.*@oneinstack_dir=@' ./options.conf
-sed -i 's@^web_install_dir=.*@web_install_dir=@' ./options.conf
-sed -i 's@^db_install_dir=.*@db_install_dir=@' ./options.conf
-sed -i 's@^db_data_dir=.*@db_data_dir=@' ./options.conf
 sed -i 's@^dbrootpwd=.*@dbrootpwd=@' ./options.conf
-sed -i 's@^ftpmanagerpwd=.*@ftpmanagerpwd=@' ./options.conf
-sed -i 's@^conn_ftpusers_dbpwd=.*@conn_ftpusers_dbpwd=@' ./options.conf
+sed -i 's@^website_name=.*@website_name=@' ./options.conf
+sed -i 's@^local_bankup_yn=.*@local_bankup_yn=y@' ./options.conf
+sed -i 's@^remote_bankup_yn=.*@remote_bankup_yn=n@' ./options.conf
 sed -i "s@^export.*$db_install_dir.*@@g" /etc/profile && . /etc/profile
 echo "${CMSG}Uninstall completed${CEND}"
 }
@@ -69,12 +69,13 @@ for D in `cat ./options.conf | grep dir= | grep -v oneinstack | grep -v backup_d
 do
     [ -e "$D" ] && echo $D
 done
-[ -e "$web_install_dir" ] && echo -e "/etc/init.d/nginx\n/etc/logrotate.d/nginx"
-[ -e "$apache_install_dir" ] && echo '/etc/init.d/httpd'
+[ -e "/etc/init.d/nginx" ] && echo '/etc/init.d/nginx'
+[ -e "/etc/logrotate.d/nginx" ] && echo '/etc/logrotate.d/nginx'
+[ -e "$apache_install_dir" ] && echo -e "/etc/init.d/httpd\n/etc/logrotate.d/apache"
 [ -e "$tomcat_install_dir" ] && echo '/etc/init.d/tomcat'
 [ -e "/usr/java" ] && echo '/usr/java' 
 [ -e "$db_install_dir" ] && echo -e "/etc/init.d/mysqld\n/etc/my.cnf"
-[ -e "$php_install_dir" ] && echo '/etc/init.d/php-fpm'
+[ -e "$php_install_dir/bin/phpize" ] && echo '/etc/init.d/php-fpm'
 [ -e "$pureftpd_install_dir" ] && echo '/etc/init.d/pureftpd'
 [ -e "$memcached_install_dir" ] && echo '/etc/init.d/memcached' 
 [ -e "$redis_install_dir" ] && echo '/etc/init.d/redis-server' 

+ 5 - 4
upgrade.sh

@@ -21,6 +21,7 @@ printf "
 . ./options.conf
 . ./include/color.sh
 . ./include/check_os.sh
+. ./include/check_db.sh
 . ./include/download.sh
 . ./include/get_char.sh
 . ./include/upgrade_web.sh
@@ -67,9 +68,9 @@ What Are You Doing?
     else
         case "$Number" in
         1)
-            if [ ! -e "$web_install_dir/sbin/dso_tool" ];then
+            if [ -e "$nginx_install_dir/sbin/nginx" ];then
                 Upgrade_Nginx
-            elif [ -e "$web_install_dir/sbin/dso_tool" ];then
+            elif [ -e "$tengine_install_dir/sbin/nginx" ];then
                 Upgrade_Tengine
             fi
             ;;
@@ -102,9 +103,9 @@ if [ $# == 0 ];then
 elif [ $# == 1 ];then
     case $1 in
     web)
-        if [ ! -e "$web_install_dir/sbin/dso_tool" ];then
+        if [ -e "$nginx_install_dir/sbin/nginx" ];then
             Upgrade_Nginx
-        elif [ -e "$web_install_dir/sbin/dso_tool" ];then
+        elif [ -e "$tengine_install_dir/sbin/nginx" ];then
             Upgrade_Tengine
         fi
         ;;

+ 29 - 43
vhost.sh

@@ -19,13 +19,14 @@ printf "
 
 . ./options.conf
 . ./include/color.sh
+. ./include/check_web.sh
 
 # Check if user is root
 [ $(id -u) != "0" ] && { echo "${CFAILURE}Error: You must be root to run this script${CEND}"; exit 1; } 
 
 Choose_env()
 {
-if [ -e "$php_install_dir" -a -e "$tomcat_install_dir" -a -e "/usr/bin/hhvm" ];then
+if [ -e "$php_install_dir/bin/phpize" -a -e "$tomcat_install_dir/conf/server.xml" -a -e "/usr/bin/hhvm" ];then
     Number=111
     while :
     do
@@ -45,7 +46,7 @@ if [ -e "$php_install_dir" -a -e "$tomcat_install_dir" -a -e "/usr/bin/hhvm" ];t
     [ "$Choose_number" == '1' ] && NGX_FLAG=php
     [ "$Choose_number" == '2' ] && NGX_FLAG=java
     [ "$Choose_number" == '3' ] && NGX_FLAG=hhvm
-elif [ -e "$php_install_dir" -a -e "$tomcat_install_dir" -a ! -e "/usr/bin/hhvm" ];then
+elif [ -e "$php_install_dir/bin/phpize" -a -e "$tomcat_install_dir/conf/server.xml" -a ! -e "/usr/bin/hhvm" ];then
     Number=110
     while :
     do
@@ -63,10 +64,10 @@ elif [ -e "$php_install_dir" -a -e "$tomcat_install_dir" -a ! -e "/usr/bin/hhvm"
     done
     [ "$Choose_number" == '1' ] && NGX_FLAG=php
     [ "$Choose_number" == '2' ] && NGX_FLAG=java
-elif [ -e "$php_install_dir" -a ! -e "$tomcat_install_dir" -a ! -e "/usr/bin/hhvm" ];then
+elif [ -e "$php_install_dir/bin/phpize" -a ! -e "$tomcat_install_dir/conf/server.xml" -a ! -e "/usr/bin/hhvm" ];then
     Number=100
     NGX_FLAG=php
-elif [ -e "$php_install_dir" -a ! -e "$tomcat_install_dir" -a -e "/usr/bin/hhvm" ];then
+elif [ -e "$php_install_dir/bin/phpize" -a ! -e "$tomcat_install_dir/conf/server.xml" -a -e "/usr/bin/hhvm" ];then
     Number=101
     while :
     do
@@ -84,7 +85,7 @@ elif [ -e "$php_install_dir" -a ! -e "$tomcat_install_dir" -a -e "/usr/bin/hhvm"
     done
     [ "$Choose_number" == '1' ] && NGX_FLAG=php
     [ "$Choose_number" == '2' ] && NGX_FLAG=hhvm
-elif [ ! -e "$php_install_dir" -a -e "$tomcat_install_dir" -a -e "/usr/bin/hhvm" ];then
+elif [ ! -e "$php_install_dir/bin/phpize" -a -e "$tomcat_install_dir/conf/server.xml" -a -e "/usr/bin/hhvm" ];then
     Number=011
     while :
     do
@@ -102,10 +103,10 @@ elif [ ! -e "$php_install_dir" -a -e "$tomcat_install_dir" -a -e "/usr/bin/hhvm"
     done
     [ "$Choose_number" == '1' ] && NGX_FLAG=java
     [ "$Choose_number" == '2' ] && NGX_FLAG=hhvm
-elif [ ! -e "$php_install_dir" -a -e "$tomcat_install_dir" -a ! -e "/usr/bin/hhvm" ];then
+elif [ ! -e "$php_install_dir/bin/phpize" -a -e "$tomcat_install_dir/conf/server.xml" -a ! -e "/usr/bin/hhvm" ];then
     Number=010
     NGX_FLAG=java
-elif [ ! -e "$php_install_dir" -a ! -e "$tomcat_install_dir" -a -e "/usr/bin/hhvm" ];then
+elif [ ! -e "$php_install_dir/bin/phpize" -a ! -e "$tomcat_install_dir/conf/server.xml" -a -e "/usr/bin/hhvm" ];then
     Number=001
     NGX_FLAG=hhvm
 else
@@ -280,19 +281,13 @@ server_name $domain$moredomainame;
 $N_log
 index index.html index.htm index.jsp index.php;
 root $vhostdir;
-#error_page 404 /404.html;
-#if ( \$query_string ~* ".*[\;'\<\>].*" ){
-#        return 404;
-#        }
 $anti_hotlinking
 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
         expires 30d;
         }
-
 location ~ .*\.(js|css)?$ {
         expires 7d;
         }
-
 `echo -e $NGX_CONF`
 }
 EOF
@@ -322,7 +317,7 @@ echo "`printf "%-32s" "Directory of:"`${CMSG}$vhostdir${CEND}"
 
 }
 
-Create_nginx_php-fpm_conf()
+Create_nginx_php-fpm_hhvm_conf()
 {
 [ ! -d $web_install_dir/conf/vhost ] && mkdir $web_install_dir/conf/vhost
 cat > $web_install_dir/conf/vhost/$domain.conf << EOF
@@ -333,17 +328,11 @@ $N_log
 index index.html index.htm index.jsp index.php;
 include $rewrite.conf;
 root $vhostdir;
-#error_page 404 /404.html;
-if ( \$query_string ~* ".*[\;'\<\>].*" ){
-	return 404;
-	}
 $anti_hotlinking
 `echo -e $NGX_CONF`
-
 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
 	expires 30d;
 	}
-
 location ~ .*\.(js|css)?$ {
 	expires 7d;
 	}
@@ -451,30 +440,23 @@ server_name $domain$moredomainame;
 $N_log
 index index.html index.htm index.jsp index.php;
 root $vhostdir;
-#error_page 404 /404.html;
-if ( \$query_string ~* ".*[\;'\<\>].*" ){
-        return 404;
-        }
 $anti_hotlinking
 location / {
-        try_files \$uri @apache;
-        }
-
+	try_files \$uri @apache;
+	}
 location @apache {
-        internal;
-        proxy_pass http://127.0.0.1:9090;
+	internal;
+	proxy_pass http://127.0.0.1:9090;
 	}
-
 location ~ .*\.(php|php5)?$ {
-        proxy_pass http://127.0.0.1:9090;
-        }
+	proxy_pass http://127.0.0.1:9090;
+	}
 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {
-        expires 30d;
-        }
-
+	expires 30d;
+	}
 location ~ .*\.(js|css)?$ {
-        expires 7d;
-        }
+	expires 7d;
+	}
 }
 EOF
 
@@ -534,7 +516,7 @@ echo "`printf "%-32s" "Directory of:"`${CMSG}$vhostdir${CEND}"
 [ "$rewrite_yn" == 'y' ] && echo "`printf "%-32s" "Rewrite rule:"`${CMSG}$rewrite${CEND}" 
 }
 
-if [ -d "$web_install_dir" -a ! -d "$apache_install_dir" -a "$web_install_dir" != "$apache_install_dir" ];then
+if [ -e "$web_install_dir/sbin/nginx" -a ! -e "$apache_install_dir/modules/libphp5.so" ];then
     Choose_env
     Input_domain
     Nginx_anti_hotlinking
@@ -544,24 +526,28 @@ if [ -d "$web_install_dir" -a ! -d "$apache_install_dir" -a "$web_install_dir" !
     else
         Nginx_rewrite
         Nginx_log
-        Create_nginx_php-fpm_conf
+        Create_nginx_php-fpm_hhvm_conf
     fi
-elif [ -d "$web_install_dir" -a -d "$apache_install_dir" -a "$web_install_dir" == "$apache_install_dir" ];then
+elif [ ! -e "$web_install_dir/sbin/nginx" -a -e "$apache_install_dir/modules/libphp5.so" ];then
     Choose_env
     Input_domain
     Apache_log
     Create_apache_conf
-elif [ -d "$web_install_dir" -a -d "$apache_install_dir" -a "$web_install_dir" != "$apache_install_dir" ];then
+elif [ -e "$web_install_dir/sbin/nginx" -a -e "$apache_install_dir/modules/libphp5.so" ];then
     Choose_env
     Input_domain
     Nginx_anti_hotlinking
     if [ "$NGX_FLAG" == 'java' ];then
         Nginx_log
         Create_nginx_tomcat_conf
-    else
+    elif [ "$NGX_FLAG" == 'hhvm' ];then
+        Nginx_rewrite
+        Nginx_log
+        Create_nginx_php-fpm_hhvm_conf
+    elif [ "$NGX_FLAG" == 'php' ];then
         #Nginx_rewrite
         Nginx_log
         Apache_log
         Create_nginx_apache_mod-php_conf
     fi
-fi 
+fi