upgrade_web.sh 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RadHat 5+ Debian 6+ and Ubuntu 12+
  6. #
  7. # Project home page:
  8. # http://oneinstack.com
  9. # https://github.com/lj2007331/oneinstack
  10. Upgrade_Nginx()
  11. {
  12. cd $oneinstack_dir/src
  13. [ ! -e "$nginx_install_dir/sbin/nginx" ] && echo "${CWARNING}The Nginx is not installed on your system! ${CEND}" && exit 1
  14. OLD_Nginx_version_tmp=`$nginx_install_dir/sbin/nginx -v 2>&1`
  15. OLD_Nginx_version=${OLD_Nginx_version_tmp##*/}
  16. echo
  17. echo "Current Nginx Version: ${CMSG}$OLD_Nginx_version${CEND}"
  18. while :
  19. do
  20. echo
  21. read -p "Please input upgrade Nginx Version(example: 1.9.5): " NEW_Nginx_version
  22. if [ "$NEW_Nginx_version" != "$OLD_Nginx_version" ];then
  23. [ ! -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
  24. if [ -e "nginx-$NEW_Nginx_version.tar.gz" ];then
  25. echo "Download [${CMSG}nginx-$NEW_Nginx_version.tar.gz${CEND}] successfully! "
  26. break
  27. else
  28. echo "${CWARNING}Nginx version does not exist! ${CEND}"
  29. fi
  30. else
  31. echo "${CWARNING}input error! The upgrade Nginx version is the same as the old version${CEND}"
  32. fi
  33. done
  34. if [ -e "nginx-$NEW_Nginx_version.tar.gz" ];then
  35. echo "[${CMSG}nginx-$NEW_Nginx_version.tar.gz${CEND}] found"
  36. echo "Press Ctrl+c to cancel or Press any key to continue..."
  37. char=`get_char`
  38. tar xzf nginx-$NEW_Nginx_version.tar.gz
  39. cd nginx-$NEW_Nginx_version
  40. make clean
  41. $nginx_install_dir/sbin/nginx -V &> $$
  42. nginx_configure_arguments=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'`
  43. rm -rf $$
  44. ./configure $nginx_configure_arguments
  45. make
  46. if [ -f "objs/nginx" ];then
  47. /bin/mv $nginx_install_dir/sbin/nginx $nginx_install_dir/sbin/nginx$(date +%m%d)
  48. /bin/cp objs/nginx $nginx_install_dir/sbin/nginx
  49. kill -USR2 `cat /var/run/nginx.pid`
  50. kill -QUIT `cat /var/run/nginx.pid.oldbin`
  51. echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_Nginx_version${CEND} to ${CWARNING}$NEW_Nginx_version${CEND}"
  52. else
  53. echo "${CFAILURE}Upgrade Nginx failed! ${CEND}"
  54. fi
  55. cd ..
  56. fi
  57. cd ..
  58. }
  59. Upgrade_Tengine()
  60. {
  61. cd $oneinstack_dir/src
  62. [ ! -e "$tengine_install_dir/sbin/nginx" ] && echo "${CWARNING}The Tengine is not installed on your system! ${CEND}" && exit 1
  63. OLD_Tengine_version_tmp=`$tengine_install_dir/sbin/nginx -v 2>&1`
  64. OLD_Tengine_version="`echo ${OLD_Tengine_version_tmp#*/} | awk '{print $1}'`"
  65. echo
  66. echo "Current Tengine Version: ${CMSG}$OLD_Tengine_version${CEND}"
  67. while :
  68. do
  69. echo
  70. read -p "Please input upgrade Tengine Version(example: 2.1.15): " NEW_Tengine_version
  71. if [ "$NEW_Tengine_version" != "$OLD_Tengine_version" ];then
  72. [ ! -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
  73. if [ -e "tengine-$NEW_Tengine_version.tar.gz" ];then
  74. echo "Download [${CMSG}tengine-$NEW_Tengine_version.tar.gz${CEND}] successfully! "
  75. break
  76. else
  77. echo "${CWARNING}Tengine version does not exist! ${CEND}"
  78. fi
  79. else
  80. echo "${CWARNING}input error! The upgrade Tengine version is the same as the old version${CEND}"
  81. fi
  82. done
  83. if [ -e "tengine-$NEW_Tengine_version.tar.gz" ];then
  84. echo "[${CMSG}tengine-$NEW_Tengine_version.tar.gz${CEND}] found"
  85. echo "Press Ctrl+c to cancel or Press any key to continue..."
  86. char=`get_char`
  87. tar xzf tengine-$NEW_Tengine_version.tar.gz
  88. cd tengine-$NEW_Tengine_version
  89. make clean
  90. # make[1]: *** [objs/src/event/ngx_event_openssl.o] Error 1
  91. 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
  92. 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
  93. $tengine_install_dir/sbin/nginx -V &> $$
  94. tengine_configure_arguments=`cat $$ | grep 'configure arguments:' | awk -F: '{print $2}'`
  95. rm -rf $$
  96. ./configure $tengine_configure_arguments
  97. make
  98. if [ -f "objs/nginx" ];then
  99. /bin/mv $tengine_install_dir/sbin/nginx $tengine_install_dir/sbin/nginx$(date +%m%d)
  100. /bin/mv $tengine_install_dir/sbin/dso_tool $tengine_install_dir/sbin/dso_tool$(date +%m%d)
  101. /bin/mv $tengine_install_dir/modules $tengine_install_dir/modules$(date +%m%d)
  102. /bin/cp objs/nginx $tengine_install_dir/sbin/nginx
  103. /bin/cp objs/dso_tool $tengine_install_dir/sbin/dso_tool
  104. chmod +x $tengine_install_dir/sbin/*
  105. make install
  106. kill -USR2 `cat /var/run/nginx.pid`
  107. kill -QUIT `cat /var/run/nginx.pid.oldbin`
  108. echo "You have ${CMSG}successfully${CEND} upgrade from ${CWARNING}$OLD_Tengine_version${CEND} to ${CWARNING}$NEW_Tengine_version${CEND}"
  109. else
  110. echo "${CFAILURE}Upgrade Tengine failed! ${CEND}"
  111. fi
  112. cd ..
  113. fi
  114. cd ..
  115. }