Browse Source

Update upgrade sh

lj2007331 9 years ago
parent
commit
b69e31a0cb
8 changed files with 175 additions and 160 deletions
  1. 1 4
      README.md
  2. 1 1
      apps.conf
  3. 4 34
      functions/upgrade_php.sh
  4. 4 38
      functions/upgrade_phpmyadmin.sh
  5. 3 39
      functions/upgrade_redis.sh
  6. 7 44
      functions/upgrade_web.sh
  7. 42 0
      reset_db_root_password.sh
  8. 113 0
      upgrade.sh

+ 1 - 4
README.md

@@ -93,10 +93,7 @@ Memcached:
 
 ## How to upgrade 
 ```bash
-   ./upgrade_php.sh # upgrade PHP
-   ./upgrade_web.sh # upgrade Nginx/Tengine
-   ./upgrade_redis.sh # upgrade Redis 
-   ./upgrade_phpmyadmin.sh # upgrade phpMyAdmin 
+   ./upgrade.sh
 ```
 
 ## How to uninstall 

+ 1 - 1
apps.conf

@@ -45,7 +45,7 @@ tomcat_7_version=7.0.62
 tomcat_8_version=8.0.23
 
 # Ftp
-pureftpd_version=1.0.39
+pureftpd_version=1.0.40
 
 # Redis
 redis_version=2.8.21

+ 4 - 34
upgrade_php.sh → functions/upgrade_php.sh

@@ -1,41 +1,10 @@
 #!/bin/bash
 # 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
+# Blog:  http://blog.linuxeye.com
 
-# Check if user is root
-[ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; } 
-
-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+      #
-#                    Upgrade PHP for OneinStack                       #
-#       For more information please visit http://oneinstack.com       #
-#######################################################################
-"
-
-cd src
-. ../options.conf
+Upgrade_PHP(){
+cd $oneinstack_dir/src
 [ ! -e "$php_install_dir" ] && echo -e "\033[31mThe PHP is not installed on your system!\033[0m " && exit 1
-
-get_char()
-{
-SAVEDSTTY=`stty -g`
-stty -echo
-stty cbreak
-dd if=/dev/tty bs=1 count=1 2> /dev/null
-stty -raw
-stty echo
-stty $SAVEDSTTY
-}
-
 echo
 Old_php_version=`$php_install_dir/bin/php -r 'echo PHP_VERSION;'`
 echo -e "Current PHP Version: \033[32m$Old_php_version\033[0m"
@@ -77,3 +46,4 @@ if [ -e "php-$php_version.tar.gz" ];then
         /etc/init.d/php-fpm restart
         echo -e "You have \033[32msuccessfully\033[0m upgrade from \033[32m$Old_php_version\033[0m to \033[32m$php_version\033[0m"
 fi
+}

+ 4 - 38
upgrade_phpmyadmin.sh → functions/upgrade_phpmyadmin.sh

@@ -1,47 +1,14 @@
 #!/bin/bash
 # 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
-
-# Check if user is root
-[ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; } 
-
-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+      #
-#                  Upgrade phpMyAdmin for OneinStack                  #
-#       For more information please visit http://oneinstack.com       #
-#######################################################################
-"
-
-cd src
-. ../options.conf
-
-[ ! -e "$home_dir/default/phpMyAdmin" ] && echo -e "\033[31mThe phpMyAdmin is not installed on your system!\033[0m " && exit 1
-
-get_char()
-{
-SAVEDSTTY=`stty -g`
-stty -echo
-stty cbreak
-dd if=/dev/tty bs=1 count=1 2> /dev/null
-stty -raw
-stty echo
-stty $SAVEDSTTY
-}
-echo
+# Blog:  http://blog.linuxeye.com
 
 Upgrade_phpMyAdmin()
 {
+cd $oneinstack_dir/src
+[ ! -e "$home_dir/default/phpMyAdmin" ] && echo -e "\033[31mThe phpMyAdmin is not installed on your system!\033[0m " && exit 1
 Old_phpMyAdmin_version=`grep Version $home_dir/default/phpMyAdmin/README | awk '{print $2}'`
 echo -e "Current phpMyAdmin Version: \033[32m$Old_phpMyAdmin_version\033[0m"
+
 while :
 do
         echo
@@ -75,4 +42,3 @@ if [ -e "phpMyAdmin-${phpMyAdmin_version}-all-languages.tar.gz" ];then
 	echo -e "You have \033[32msuccessfully\033[0m upgrade from \033[32m$Old_phpMyAdmin_version\033[0m to \033[32m$phpMyAdmin_version\033[0m"
 fi
 }
-Upgrade_phpMyAdmin

+ 3 - 39
upgrade_redis.sh → functions/upgrade_redis.sh

@@ -1,45 +1,11 @@
 #!/bin/bash
 # 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
-
-# Check if user is root
-[ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; } 
-
-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+      #
-#                    Upgrade Redis for OneinStack                     #
-#       For more information please visit http://oneinstack.com       #
-#######################################################################
-"
-
-cd src
-. ../options.conf
-
-[ ! -d "$redis_install_dir" ] && echo -e "\033[31mThe Redis is not installed on your system!\033[0m " && exit 1
-
-get_char()
-{
-SAVEDSTTY=`stty -g`
-stty -echo
-stty cbreak
-dd if=/dev/tty bs=1 count=1 2> /dev/null
-stty -raw
-stty echo
-stty $SAVEDSTTY
-}
-echo
+# Blog:  http://blog.linuxeye.com
 
 Upgrade_Redis()
 {
+cd $oneinstack_dir/src
+[ ! -d "$redis_install_dir" ] && echo -e "\033[31mThe Redis is not installed on your system!\033[0m " && exit 1
 Old_redis_version=`$redis_install_dir/bin/redis-cli --version | awk '{print $2}'`
 echo -e "Current Redis Version: \033[32m$Old_redis_version\033[0m"
 while :
@@ -85,5 +51,3 @@ if [ -e "redis-$redis_version.tar.gz" ];then
         cd ..
 fi
 }
-
-Upgrade_Redis

+ 7 - 44
upgrade_web.sh → functions/upgrade_web.sh

@@ -1,48 +1,14 @@
 #!/bin/bash
 # 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
-
-# Check if user is root
-[ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; } 
-
-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+      #
-#              Upgrade Nginx/Tengine for OneinStack                   #
-#       For more information please visit http://oneinstack.com       #
-#######################################################################
-"
-
-cd src
-. ../options.conf
-. ../functions/download.sh
-
-[ ! -e "$web_install_dir/sbin/nginx" ] && echo -e "\033[31mThe Nginx/Tengine is not installed on your system!\033[0m " && exit 1
-
-get_char()
-{
-SAVEDSTTY=`stty -g`
-stty -echo
-stty cbreak
-dd if=/dev/tty bs=1 count=1 2> /dev/null
-stty -raw
-stty echo
-stty $SAVEDSTTY
-}
-echo
+# Blog:  http://blog.linuxeye.com
 
 Upgrade_Nginx()
 {
+cd $oneinstack_dir/src
+[ ! -e "$nginx_install_dir/sbin/nginx" ] && echo -e "\033[31mThe Nginx is not installed on your system!\033[0m " && exit 1
 Old_nginx_version_tmp=`$web_install_dir/sbin/nginx -v 2>&1`
 Old_nginx_version=${Old_nginx_version_tmp##*/}
+echo
 echo -e "Current Nginx Version: \033[32m$Old_nginx_version\033[0m"
 while :
 do
@@ -90,8 +56,11 @@ fi
 
 Upgrade_Tengine()
 {
+cd $oneinstack_dir/src
+[ ! -e "$web_install_dir/sbin/nginx" ] && echo -e "\033[31mThe Tengine is not installed on your system!\033[0m " && exit 1
 Old_tengine_version_tmp=`$web_install_dir/sbin/nginx -v 2>&1`
 Old_tengine_version="`echo ${Old_tengine_version_tmp#*/} | awk '{print $1}'`"
+echo
 echo -e "Current Tengine Version: \033[32m$Old_tengine_version\033[0m"
 while :
 do
@@ -144,9 +113,3 @@ if [ -e "tengine-$tengine_version.tar.gz" ];then
         cd ..
 fi
 }
-
-if [ ! -e "$web_install_dir/sbin/dso_tool" ];then
-	Upgrade_Nginx
-elif [ -e "$web_install_dir/sbin/dso_tool" ];then 
-	Upgrade_Tengine
-fi

+ 42 - 0
reset_db_root_password.sh

@@ -0,0 +1,42 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+# Check if user is root
+[ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; }
+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+      #
+#              Reset Database root password for OneinStack            #
+#       For more information please visit http://oneinstack.com       #
+#######################################################################
+"
+. ./options.conf
+
+Reset_db_root_password()
+{
+[ ! -d "$db_install_dir" ] && echo -e "\033[31mThe Database is not installed on your system!\033[0m " && exit 1
+while :
+do
+	echo
+        read -p "Please input the root password of database: " New_dbrootpwd
+        [ -n "`echo $New_dbrootpwd | grep '[+|&]'`" ] && { echo -e "\033[31minput error,not contain a plus sign (+) and & \033[0m"; continue; }
+        (( ${#New_dbrootpwd} >= 5 )) && break || echo -e "\033[31mdatabase root password least 5 characters! \033[0m"
+done
+$db_install_dir/bin/mysqladmin -uroot -p"$dbrootpwd" password "$New_dbrootpwd" -h localhost > /dev/null 2>&1
+status_Localhost=`echo $?`
+$db_install_dir/bin/mysqladmin -uroot -p"$dbrootpwd" password "$New_dbrootpwd" -h 127.0.0.1 > /dev/null 2>&1
+status_127=`echo $?`
+if [ $status_Localhost == '0' -a $status_127 == '0' ]; then
+	sed -i "s+^dbrootpwd.*+dbrootpwd='$New_dbrootpwd'+" ./options.conf
+	echo
+	echo "Password reset succesfully! "
+	echo -e "The new password: \033[32m${New_dbrootpwd}\033[0m"
+	echo
+else
+	echo "Reset Database root password failed!"
+fi
+}
+Reset_db_root_password

+ 113 - 0
upgrade.sh

@@ -0,0 +1,113 @@
+#!/bin/bash
+# Author:  yeho <lj2007331 AT gmail.com>
+# Blog:  http://blog.linuxeye.com
+
+# Check if user is root
+[ $(id -u) != "0" ] && { echo -e "\033[31mError: You must be root to run this script\033[0m"; exit 1; }
+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+      #
+#       upgrade Nginx/Tengine,PHP,Redis,phpMyAdmin for OneinStack     # 
+#       For more information please visit http://oneinstack.com       #
+#######################################################################
+"
+. ./options.conf
+. ./functions/upgrade_web.sh
+. ./functions/upgrade_php.sh
+. ./functions/upgrade_redis.sh
+. ./functions/upgrade_phpmyadmin.sh
+
+get_char()
+{
+SAVEDSTTY=`stty -g`
+stty -echo
+stty cbreak
+dd if=/dev/tty bs=1 count=1 2> /dev/null
+stty -raw
+stty echo
+stty $SAVEDSTTY
+}
+
+Usage(){
+echo
+echo -e $"\033[035mUsage:\033[0m \033[032m $0 [ web | php | redis | phpmyadmin ]\033[0m"
+echo -e "-------------------------------------------------------"
+echo -e "\033[032mweb\033[0m             --->Upgrade Nginx/Tengine"
+echo -e "\033[032mphp\033[0m             --->Upgrade PHP"
+echo -e "\033[032mredis\033[0m           --->Upgrade Redis"
+echo -e "\033[032mphpmyadmin\033[0m      --->Upgrade phpMyAdmin"
+echo
+}
+
+Menu(){
+while :
+do
+        echo
+        echo -e "What Are You Doing?
+\t\033[32m1\033[0m. Upgrade Nginx/Tengine
+\t\033[32m2\033[0m. Upgrade PHP
+\t\033[32m3\033[0m. Upgrade Redis
+\t\033[32m4\033[0m. Upgrade phpMyAdmin
+\t\033[32mq\033[0m. Exit"
+        read -p "Please input the correct option: " Number
+        if [ "$Number" != '1' -a "$Number" != '2' -a "$Number" != '3' -a "$Number" != '4' -a "$Number" != 'q' ];then
+                echo -e "\033[31minput error! Please only input 1 ~ 4 and q\033[0m"
+        else
+        	case "$Number" in
+	        1)
+	        if [ ! -e "$web_install_dir/sbin/dso_tool" ];then
+	                Upgrade_Nginx
+	        elif [ -e "$web_install_dir/sbin/dso_tool" ];then
+	                Upgrade_Tengine
+	        fi
+	        ;;
+	        2)
+		Upgrade_PHP
+	        ;;
+	        3)
+		Upgrade_Redis
+	        ;;
+	        4)
+		Upgrade_phpMyAdmin
+	        ;;
+	        q)
+	        exit
+	        ;;
+	        esac
+        fi
+done
+}
+
+if [ $# == 0 ];then
+	Menu
+elif [ $# == 1 ];then
+	case $1 in
+        web)
+	if [ ! -e "$web_install_dir/sbin/dso_tool" ];then
+	        Upgrade_Nginx
+	elif [ -e "$web_install_dir/sbin/dso_tool" ];then
+	        Upgrade_Tengine
+	fi
+        ;;
+
+        php)
+	Upgrade_PHP
+        ;;
+
+        redis)
+	Upgrade_Redis
+        ;;
+
+        phpmyadmin)
+	Upgrade_phpMyAdmin
+        ;;
+
+        *)
+        Usage
+        ;;
+	esac
+else
+	Usage
+fi