123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- #!/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
- Upgrade_Nginx()
- {
- cd $oneinstack_dir/src
- [ ! -e "$nginx_install_dir/sbin/nginx" ] && echo "${CWARNING}The 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##*/}
- echo
- echo "Current Nginx Version: ${CMSG}$OLD_Nginx_version${CEND}"
- while :
- do
- echo
- read -p "Please input upgrade Nginx Version(example: 1.9.5): " NEW_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
- echo "Download [${CMSG}nginx-$NEW_Nginx_version.tar.gz${CEND}] successfully! "
- break
- else
- echo "${CWARNING}Nginx version does not exist! ${CEND}"
- fi
- else
- echo "${CWARNING}input error! The upgrade Nginx version is the same as the old version${CEND}"
- fi
- done
- if [ -e "nginx-$NEW_Nginx_version.tar.gz" ];then
- echo "[${CMSG}nginx-$NEW_Nginx_version.tar.gz${CEND}] found"
- echo "Press Ctrl+c to cancel or Press any key to continue..."
- char=`get_char`
- tar xzf nginx-$NEW_Nginx_version.tar.gz
- cd nginx-$NEW_Nginx_version
- make clean
- $nginx_install_dir/sbin/nginx -V &> $$
- nginx_configure_arguments=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'`
- rm -rf $$
- ./configure $nginx_configure_arguments
- make
- if [ -f "objs/nginx" ];then
- /bin/mv $nginx_install_dir/sbin/nginx $nginx_install_dir/sbin/nginx$(date +%m%d)
- /bin/cp objs/nginx $nginx_install_dir/sbin/nginx
- kill -USR2 `cat /var/run/nginx.pid`
- kill -QUIT `cat /var/run/nginx.pid.oldbin`
- echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_Nginx_version${CEND} to ${CWARNING}$NEW_Nginx_version${CEND}"
- else
- echo "${CFAILURE}Upgrade Nginx failed! ${CEND}"
- fi
- cd ..
- fi
- cd ..
- }
- Upgrade_Tengine()
- {
- cd $oneinstack_dir/src
- [ ! -e "$tengine_install_dir/sbin/nginx" ] && echo "${CWARNING}The 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}'`"
- 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
- 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
- echo "Download [${CMSG}tengine-$NEW_Tengine_version.tar.gz${CEND}] successfully! "
- break
- else
- echo "${CWARNING}Tengine version does not exist! ${CEND}"
- fi
- else
- echo "${CWARNING}input error! The upgrade Tengine version is the same as the old version${CEND}"
- fi
- done
- if [ -e "tengine-$NEW_Tengine_version.tar.gz" ];then
- echo "[${CMSG}tengine-$NEW_Tengine_version.tar.gz${CEND}] found"
- echo "Press Ctrl+c to cancel or Press any key to continue..."
- char=`get_char`
- tar xzf tengine-$NEW_Tengine_version.tar.gz
- cd tengine-$NEW_Tengine_version
- make clean
- # make[1]: *** [objs/src/event/ngx_event_openssl.o] Error 1
- sed -i 's@\(.*\)this option allow a potential SSL 2.0 rollback (CAN-2005-2969)\(.*\)@#ifdef SSL_OP_MSIE_SSLV2_RSA_PADDING\n\1this option allow a potential SSL 2.0 rollback (CAN-2005-2969)\2@' src/event/ngx_event_openssl.c
- sed -i 's@\(.*\)SSL_CTX_set_options(ssl->ctx, SSL_OP_MSIE_SSLV2_RSA_PADDING)\(.*\)@\1SSL_CTX_set_options(ssl->ctx, SSL_OP_MSIE_SSLV2_RSA_PADDING)\2\n#endif@' src/event/ngx_event_openssl.c
- $tengine_install_dir/sbin/nginx -V &> $$
- tengine_configure_arguments=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'`
- rm -rf $$
- ./configure $tengine_configure_arguments
- make
- if [ -f "objs/nginx" ];then
- /bin/mv $tengine_install_dir/sbin/nginx $tengine_install_dir/sbin/nginx$(date +%m%d)
- /bin/mv $tengine_install_dir/sbin/dso_tool $tengine_install_dir/sbin/dso_tool$(date +%m%d)
- /bin/mv $tengine_install_dir/modules $tengine_install_dir/modules$(date +%m%d)
- /bin/cp objs/nginx $tengine_install_dir/sbin/nginx
- /bin/cp objs/dso_tool $tengine_install_dir/sbin/dso_tool
- chmod +x $tengine_install_dir/sbin/*
- make install
- kill -USR2 `cat /var/run/nginx.pid`
- kill -QUIT `cat /var/run/nginx.pid.oldbin`
- echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_Tengine_version${CEND} to ${CWARNING}$NEW_Tengine_version${CEND}"
- else
- echo "${CFAILURE}Upgrade Tengine failed! ${CEND}"
- fi
- cd ..
- fi
- cd ..
- }
|