Browse Source

Add Apache upgrade

lj2007331@gmail.com 7 years ago
parent
commit
f34a6f3446

+ 4 - 1
include/upgrade_memcached.sh

@@ -12,9 +12,12 @@ Upgrade_Memcached() {
   pushd ${oneinstack_dir}/src > /dev/null
   [ ! -e "${memcached_install_dir}/bin/memcached" ] && echo "${CWARNING}Memcached is not installed on your system! ${CEND}" && exit 1
   OLD_Memcached_version=`$memcached_install_dir/bin/memcached -V | awk '{print $2}'`
+  Latest_Memcached_version=`curl -s http://memcached.org/downloads | awk -F'>|<' '/\/files\/memcached/{print $3}' | grep -oE "[0-9]\.[0-9]\.[0-9]+"`
+  [ -z "$Latest_Memcached_version" ] && Latest_Memcached_version=1.6.8
   echo "Current Memcached Version: ${CMSG}$OLD_Memcached_version${CEND}"
   while :; do echo
-    read -p "Please input upgrade Memcached Version(example: 1.4.39): " NEW_Memcached_version
+    read -p "Please input upgrade Memcached Version(default: $Latest_Memcached_version): " NEW_Memcached_version
+    [ -z "$NEW_Memcached_version" ] && NEW_Memcached_version=$Latest_Memcached_version
     if [ "${NEW_Memcached_version}" != "$OLD_Memcached_version" ]; then
       [ ! -e "memcached-${NEW_Memcached_version}.tar.gz" ] && wget --no-check-certificate -c http://www.memcached.org/files/memcached-${NEW_Memcached_version}.tar.gz > /dev/null 2>&1
       if [ -e "memcached-${NEW_Memcached_version}.tar.gz" ]; then

+ 5 - 2
include/upgrade_php.sh

@@ -11,11 +11,14 @@
 Upgrade_PHP() {
   pushd ${oneinstack_dir}/src > /dev/null
   [ ! -e "${php_install_dir}" ] && echo "${CWARNING}PHP is not installed on your system! ${CEND}" && exit 1
-  echo
   OLD_PHP_version=`${php_install_dir}/bin/php -r 'echo PHP_VERSION;'`
+  Latest_PHP_version=`curl -s http://php.net/downloads.php | awk '/Changelog/{print $2}' | grep "${OLD_PHP_version%.*}"`
+  echo
+  [ -z "$Latest_PHP_version" ] && Latest_PHP_version=5.5.38
   echo "Current PHP Version: ${CMSG}$OLD_PHP_version${CEND}"
   while :; do echo
-    read -p "Please input upgrade PHP Version: " NEW_PHP_version
+    read -p "Please input upgrade PHP Version(Default: $Latest_PHP_version): " NEW_PHP_version
+    [ -z "$NEW_PHP_version" ] && NEW_PHP_version=$Latest_PHP_version
     if [ "${NEW_PHP_version%.*}" == "${OLD_PHP_version%.*}" ]; then
       [ ! -e "php-${NEW_PHP_version}.tar.gz" ] && wget --no-check-certificate -c http://www.php.net/distributions/php-${NEW_PHP_version}.tar.gz > /dev/null 2>&1
       if [ -e "php-${NEW_PHP_version}.tar.gz" ]; then

+ 4 - 2
include/upgrade_phpmyadmin.sh

@@ -12,10 +12,12 @@ Upgrade_phpMyAdmin() {
   pushd ${oneinstack_dir}/src > /dev/null
   [ ! -e "${wwwroot_dir}/default/phpMyAdmin" ] && echo "${CWARNING}phpMyAdmin is not installed on your system! ${CEND}" && exit 1
   OLD_phpMyAdmin_version=`grep Version ${wwwroot_dir}/default/phpMyAdmin/README | awk '{print $2}'`
+  Latest_phpMyAdmin_version=`curl -s https://www.phpmyadmin.net/files/ | awk -F'>|<' '/\/files\/[0-9]/{print $5}' | head -1`
+  [ -z "$Latest_phpMyAdmin_version" ] && Latest_phpMyAdmin_version=4.8.6
   echo "Current phpMyAdmin Version: ${CMSG}${OLD_phpMyAdmin_version}${CEND}"
-
   while :; do echo
-    read -p "Please input upgrade phpMyAdmin Version(example: 4.4.15): " NEW_phpMyAdmin_version
+    read -p "Please input upgrade phpMyAdmin Version(default: $Latest_phpMyAdmin_version): " NEW_phpMyAdmin_version
+    [ -z "$NEW_phpMyAdmin_version" ] && NEW_phpMyAdmin_version=$Latest_phpMyAdmin_version
     if [ "${NEW_phpMyAdmin_version}" != "${OLD_phpMyAdmin_version}" ]; then
       [ ! -e "phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz" ] && wget --no-check-certificate -c https://files.phpmyadmin.net/phpMyAdmin/${NEW_phpMyAdmin_version}/phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz > /dev/null 2>&1
       if [ -e "phpMyAdmin-${NEW_phpMyAdmin_version}-all-languages.tar.gz" ]; then

+ 4 - 1
include/upgrade_redis.sh

@@ -12,9 +12,12 @@ Upgrade_Redis() {
   pushd ${oneinstack_dir}/src > /dev/null
   [ ! -d "$redis_install_dir" ] && echo "${CWARNING}Redis is not installed on your system! ${CEND}" && exit 1
   OLD_Redis_version=`$redis_install_dir/bin/redis-cli --version | awk '{print $2}'`
+  Latest_Redis_version=`curl -s http://download.redis.io/redis-stable/00-RELEASENOTES | awk '/Released/{print $2}' | head -1`
+  [ -z "$Latest_Redis_version" ] && Latest_Redis_version=4.2.8
   echo "Current Redis Version: ${CMSG}$OLD_Redis_version${CEND}"
   while :; do echo
-    read -p "Please input upgrade Redis Version(example: 3.0.5): " NEW_Redis_version
+    read -p "Please input upgrade Redis Version(default: $Latest_Redis_version): " NEW_Redis_version
+    [ -z "$NEW_Redis_version" ] && NEW_Redis_version=$Latest_Redis_version
     if [ "$NEW_Redis_version" != "$OLD_Redis_version" ]; then
       [ ! -e "redis-$NEW_Redis_version.tar.gz" ] && wget --no-check-certificate -c http://download.redis.io/releases/redis-$NEW_Redis_version.tar.gz > /dev/null 2>&1
       if [ -e "redis-$NEW_Redis_version.tar.gz" ]; then

+ 74 - 5
include/upgrade_web.sh

@@ -13,10 +13,13 @@ Upgrade_Nginx() {
   [ ! -e "$nginx_install_dir/sbin/nginx" ] && echo "${CWARNING}Nginx is not installed on your system! ${CEND}" && exit 1
   OLD_Nginx_version_tmp=`$nginx_install_dir/sbin/nginx -v 2>&1`
   OLD_Nginx_version=${OLD_Nginx_version_tmp##*/}
+  Latest_Nginx_version=`curl -s http://nginx.org/en/CHANGES-1.12 | awk '/Changes with nginx/{print$0}' | awk '{print $4}' | head -1`
+  [ -z "$Latest_Nginx_version" ] && Latest_Nginx_version=`curl -s http://nginx.org/en/CHANGES | awk '/Changes with nginx/{print$0}' | awk '{print $4}' | head -1`
   echo
   echo "Current Nginx Version: ${CMSG}$OLD_Nginx_version${CEND}"
   while :; do echo
-    read -p "Please input upgrade Nginx Version(example: 1.9.15): " NEW_Nginx_version
+    read -p "Please input upgrade Nginx Version(default: $Latest_Nginx_version): " NEW_Nginx_version
+    [ -z "$NEW_Nginx_version" ] && NEW_Nginx_version=$Latest_Nginx_version
     if [ "$NEW_Nginx_version" != "$OLD_Nginx_version" ]; then
       [ ! -e "nginx-$NEW_Nginx_version.tar.gz" ] && wget --no-check-certificate -c http://nginx.org/download/nginx-$NEW_Nginx_version.tar.gz > /dev/null 2>&1
       if [ -e "nginx-$NEW_Nginx_version.tar.gz" ]; then
@@ -64,14 +67,16 @@ Upgrade_Nginx() {
 }
 
 Upgrade_Tengine() {
-  pushd ${oneinstack_dir}/src
+  pushd ${oneinstack_dir}/src > /dev/null
   [ ! -e "$tengine_install_dir/sbin/nginx" ] && echo "${CWARNING}Tengine is not installed on your system! ${CEND}" && exit 1
   OLD_Tengine_version_tmp=`$tengine_install_dir/sbin/nginx -v 2>&1`
   OLD_Tengine_version="`echo ${OLD_Tengine_version_tmp#*/} | awk '{print $1}'`"
+  Latest_Tengine_version=`curl -s http://tengine.taobao.org/changelog.html | grep -oE "[0-9]\.[0-9]\.[0-9]+" | head -1`
   echo
   echo "Current Tengine Version: ${CMSG}$OLD_Tengine_version${CEND}"
   while :; do echo
-    read -p "Please input upgrade Tengine Version(example: 2.1.15): " NEW_Tengine_version
+    read -p "Please input upgrade Tengine Version(default: $Latest_Tengine_version): " NEW_Tengine_version
+    [ -z "$NEW_Tengine_version" ] && NEW_Tengine_version=$Latest_Tengine_version
     if [ "$NEW_Tengine_version" != "$OLD_Tengine_version" ]; then
       [ ! -e "tengine-$NEW_Tengine_version.tar.gz" ] && wget --no-check-certificate -c http://tengine.taobao.org/download/tengine-$NEW_Tengine_version.tar.gz > /dev/null 2>&1
       if [ -e "tengine-$NEW_Tengine_version.tar.gz" ]; then
@@ -124,14 +129,16 @@ Upgrade_Tengine() {
 }
 
 Upgrade_OpenResty() {
-  pushd ${oneinstack_dir}/src
+  pushd ${oneinstack_dir}/src > /dev/null
   [ ! -e "$openresty_install_dir/nginx/sbin/nginx" ] && echo "${CWARNING}OpenResty is not installed on your system! ${CEND}" && exit 1
   OLD_OpenResty_version_tmp=`$openresty_install_dir/nginx/sbin/nginx -v 2>&1`
   OLD_OpenResty_version="`echo ${OLD_OpenResty_version_tmp#*/} | awk '{print $1}'`"
+  Latest_OpenResty_version=`curl -s https://openresty.org/en/download.html | awk '/download\/openresty-/{print $0}' |  grep -oE "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | head -1`
   echo
   echo "Current OpenResty Version: ${CMSG}$OLD_OpenResty_version${CEND}"
   while :; do echo
-    read -p "Please input upgrade OpenResty Version(example: 1.9.7.19): " NEW_OpenResty_version
+    read -p "Please input upgrade OpenResty Version(default: $Latest_OpenResty_version): " NEW_OpenResty_version
+    [ -z "$NEW_OpenResty_version" ] && NEW_OpenResty_version=$Latest_OpenResty_version
     if [ "$NEW_OpenResty_version" != "$OLD_OpenResty_version" ]; then
       [ ! -e "openresty-$NEW_OpenResty_version.tar.gz" ] && wget --no-check-certificate -c https://openresty.org/download/openresty-$NEW_OpenResty_version.tar.gz > /dev/null 2>&1
       if [ -e "openresty-$NEW_OpenResty_version.tar.gz" ]; then
@@ -176,3 +183,65 @@ Upgrade_OpenResty() {
   fi
   popd > /dev/null 
 }
+
+Upgrade_Apache() {
+  pushd ${oneinstack_dir}/src > /dev/null
+  [ ! -e "$apache_install_dir/bin/httpd" ] && echo "${CWARNING}Apache is not installed on your system! ${CEND}" && exit 1
+  OLD_Apache_version="`/usr/local/apache/bin/httpd -v | grep version | awk -F'/| ' '{print $4}'`"
+  Apache_flag="`echo $OLD_Apache_version | awk -F. '{print $1 $2}'`"
+  Latest_Apache_version=`curl -s http://httpd.apache.org/download.cgi | awk "/#apache$Apache_flag/{print $2}" | head -1 | grep -oE "2\.[24]\.[0-9]+"`
+  echo
+  echo "Current Apache Version: ${CMSG}$OLD_Apache_version${CEND}"
+  while :; do echo
+    read -p "Please input upgrade Apache Version(Default: $Latest_Apache_version): " NEW_Apache_version
+    [ -z "$NEW_Apache_version" ] && NEW_Apache_version=$Latest_Apache_version
+    if [ "$NEW_Apache_version" != "$OLD_Apache_version" ]; then
+      if [ "$Apache_flag" == '24' ]; then
+        src_url=http://archive.apache.org/dist/apr/apr-${apr_version}.tar.gz && Download_src
+        src_url=http://archive.apache.org/dist/apr/apr-util-${apr_util_version}.tar.gz && Download_src
+        tar xzf apr-${apr_version}.tar.gz
+        tar xzf apr-util-${apr_util_version}.tar.gz
+      fi
+      [ ! -e "httpd-$NEW_Apache_version.tar.gz" ] && wget --no-check-certificate -c http://mirrors.linuxeye.com/apache/httpd/httpd-$NEW_Apache_version.tar.gz > /dev/null 2>&1
+      if [ -e "httpd-$NEW_Apache_version.tar.gz" ]; then
+        echo "Download [${CMSG}apache-$NEW_Apache_version.tar.gz${CEND}] successfully! "
+        break
+      else
+        echo "${CWARNING}Apache version does not exist! ${CEND}"
+      fi
+    else
+      echo "${CWARNING}input error! Upgrade Apache version is the same as the old version${CEND}"
+    fi
+  done
+
+  if [ -e "httpd-$NEW_Apache_version.tar.gz" ]; then
+    echo "[${CMSG}httpd-$NEW_Apache_version.tar.gz${CEND}] found"
+    echo "Press Ctrl+c to cancel or Press any key to continue..."
+    char=`get_char`
+    tar xzf httpd-$NEW_Apache_version.tar.gz
+    pushd httpd-$NEW_Apache_version
+    make clean
+    if [ "$Apache_flag" == '24' ]; then
+      /bin/cp -R ../apr-${apr_version} ./srclib/apr
+      /bin/cp -R ../apr-util-${apr_util_version} ./srclib/apr-util
+      LDFLAGS=-ldl LD_LIBRARY_PATH=${openssl_install_dir}/lib ./configure --prefix=${apache_install_dir} --with-mpm=prefork --with-included-apr --enable-headers --enable-deflate --enable-so --enable-dav --enable-rewrite --enable-ssl --with-ssl=${openssl_install_dir} --enable-http2 --with-nghttp2=/usr/local --enable-expires --enable-static-support --enable-suexec --enable-modules=all --enable-mods-shared=all
+    elif [ "$Apache_flag" == '22' ]; then
+      [ "${Ubuntu_version}" == "12" ] && sed -i '@SSL_PROTOCOL_SSLV2@d' modules/ssl/ssl_engine_io.c
+      LDFLAGS=-ldl ./configure --prefix=${apache_install_dir} --with-mpm=prefork --with-included-apr --enable-headers --enable-deflate --enable-so --enable-rewrite --enable-ssl--with-ssl=${openssl_install_dir} --enable-expires --enable-static-support --enable-suexec --enable-modules=all --enable-mods-shared=all
+    fi
+    make -j ${THREAD}
+    if [ -e 'httpd' ]; then
+      [[ -d ${apache_install_dir}.bak && -d ${apache_install_dir} ]] && rm -rf ${apache_install_dir}.bak
+      /etc/init.d/httpd stop
+      /bin/cp -R ${apache_install_dir}{,bak}
+      make install && unset LDFLAGS
+      /etc/init.d/httpd start
+      popd > /dev/null
+      echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_Apache_version${CEND} to ${CWARNING}$NEW_Apache_version${CEND}"
+      rm -rf httpd-$NEW_Apache_version apr-${apr_version} apr-util-${apr_util_version}
+    else
+      echo "${CFAILURE}Upgrade Apache failed! ${CEND}"
+    fi
+  fi
+  popd > /dev/null
+}

+ 7 - 3
upgrade.sh

@@ -44,7 +44,7 @@ IPADDR_COUNTRY=`./include/get_ipaddr_state.py $PUBLIC_IPADDR | awk '{print $1}'`
 Usage(){
   printf "
 Usage: $0 [ ${CMSG}web${CEND} | ${CMSG}db${CEND} | ${CMSG}php${CEND} | ${CMSG}redis${CEND} | ${CMSG}memcached${CEND} | ${CMSG}phpmyadmin${CEND} ]
-${CMSG}web${CEND}            --->Upgrade Nginx/Tengine/OpenResty
+${CMSG}web${CEND}            --->Upgrade Nginx/Tengine/OpenResty/Apache
 ${CMSG}db${CEND}             --->Upgrade MySQL/MariaDB/Percona
 ${CMSG}php${CEND}            --->Upgrade PHP
 ${CMSG}redis${CEND}          --->Upgrade Redis
@@ -58,7 +58,7 @@ Menu(){
   while :; do
     printf "
 What Are You Doing?
-\t${CMSG}1${CEND}. Upgrade Nginx/Tengine/OpenResty
+\t${CMSG}1${CEND}. Upgrade Nginx/Tengine/OpenResty/Apache
 \t${CMSG}2${CEND}. Upgrade MySQL/MariaDB/Percona
 \t${CMSG}3${CEND}. Upgrade PHP
 \t${CMSG}4${CEND}. Upgrade Redis
@@ -69,7 +69,7 @@ What Are You Doing?
     echo
     read -p "Please input the correct option: " Number
     if [[ ! $Number =~ ^[1-6,q]$ ]]; then
-      echo "${CWARNING}input error! Please only input 1,2,3,4,5,6 and q${CEND}"
+      echo "${CWARNING}input error! Please only input 1~6 and q${CEND}"
     else
       case "$Number" in
       1)
@@ -79,6 +79,8 @@ What Are You Doing?
           Upgrade_Tengine
         elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ]; then
           Upgrade_OpenResty
+        elif [ -e "${apache_install_dir}/conf/httpd.conf" ]; then
+          Upgrade_Apache 
         fi
         ;;
       2)
@@ -115,6 +117,8 @@ elif [ $# == 1 ]; then
       Upgrade_Tengine
     elif [ -e "$openresty_install_dir/nginx/sbin/nginx" ]; then
       Upgrade_OpenResty
+    elif [ -e "${apache_install_dir}/conf/httpd.conf" ]; then
+      Upgrade_Apache 
     fi
     ;;
   db)

+ 2 - 2
versions.txt

@@ -28,7 +28,7 @@ mariadb55_version=5.5.58
 
 percona57_version=5.7.19-17
 percona56_version=5.6.37-82.2
-percona55_version=5.5.57-38.9
+percona55_version=5.5.58-38.10
 
 alisql56_version=5.6.32-7
 
@@ -67,7 +67,7 @@ swoole_version=1.9.23
 pureftpd_version=1.0.47
 
 # Redis
-redis_version=4.0.4
+redis_version=4.0.6
 redis_pecl_version=3.1.4
 
 # Memcached