upgrade_oneinstack.sh 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://linuxeye.com
  4. #
  5. # Notes: OneinStack for CentOS/RedHat 7+ Debian 9+ and Ubuntu 16+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/oneinstack/oneinstack
  10. Upgrade_OneinStack() {
  11. pushd ${oneinstack_dir} > /dev/null
  12. Latest_OneinStack_MD5=$(curl --connect-timeout 3 -m 5 -s ${mirror_link}/md5sum.txt | grep oneinstack.tar.gz | awk '{print $1}')
  13. [ ! -e README.md ] && ois_flag=n
  14. if [ "${oneinstack_md5}" != "${Latest_OneinStack_MD5}" ]; then
  15. /bin/mv options.conf /tmp
  16. sed -i '/oneinstack_dir=/d' /tmp/options.conf
  17. [ -e /tmp/oneinstack.tar.gz ] && rm -rf /tmp/oneinstack.tar.gz
  18. wget --no-check-certificate -qc ${mirror_link}/oneinstack.tar.gz -O /tmp/oneinstack.tar.gz
  19. if [ -n "`echo ${oneinstack_dir} | grep lnmp`" ]; then
  20. tar xzf /tmp/oneinstack.tar.gz -C /tmp
  21. /bin/cp -R /tmp/oneinstack/* ${oneinstack_dir}/
  22. /bin/rm -rf /tmp/oneinstack
  23. else
  24. tar xzf /tmp/oneinstack.tar.gz -C ../
  25. fi
  26. IFS=$'\n'
  27. for L in `grep -vE '^#|^$' /tmp/options.conf`
  28. do
  29. IFS=$IFS_old
  30. Key="`echo ${L%%=*}`"
  31. Value="`echo ${L#*=}`"
  32. sed -i "s|^${Key}=.*|${Key}=${Value}|" ./options.conf
  33. done
  34. rm -rf /tmp/{oneinstack.tar.gz,options.conf}
  35. [ "${ois_flag}" == "n" ] && rm -f ss.sh LICENSE README.md
  36. sed -i "s@^oneinstack_md5=.*@oneinstack_md5=${Latest_OneinStack_MD5}@" ./options.conf
  37. if [ -e "change_jdk_version.sh" ]; then
  38. rm -f change_jdk_version.sh
  39. wget -qc ${mirror_link}/scripts/change_jdk_version.sh
  40. chmod +x change_jdk_version.sh
  41. fi
  42. if [ -e "${php_install_dir}/sbin/php-fpm" ]; then
  43. [ -n "`grep ^cgi.fix_pathinfo=0 ${php_install_dir}/etc/php.ini`" ] && sed -i 's@^cgi.fix_pathinfo.*@;&@' ${php_install_dir}/etc/php.ini
  44. [ -e "/usr/local/php53/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php53/etc/php.ini 2>/dev/null
  45. [ -e "/usr/local/php54/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php54/etc/php.ini 2>/dev/null
  46. [ -e "/usr/local/php55/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php55/etc/php.ini 2>/dev/null
  47. [ -e "/usr/local/php56/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php56/etc/php.ini 2>/dev/null
  48. [ -e "/usr/local/php70/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php70/etc/php.ini 2>/dev/null
  49. [ -e "/usr/local/php71/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php71/etc/php.ini 2>/dev/null
  50. [ -e "/usr/local/php72/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php72/etc/php.ini 2>/dev/null
  51. [ -e "/usr/local/php73/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php73/etc/php.ini 2>/dev/null
  52. [ -e "/usr/local/php74/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php74/etc/php.ini 2>/dev/null
  53. [ -e "/usr/local/php80/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php80/etc/php.ini 2>/dev/null
  54. [ -e "/usr/local/php81/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php81/etc/php.ini 2>/dev/null
  55. [ -e "/usr/local/php82/etc/php.ini" ] && sed -i 's@^cgi.fix_pathinfo=0@;&@' /usr/local/php82/etc/php.ini 2>/dev/null
  56. fi
  57. [ -e "/lib/systemd/system/php-fpm.service" ] && { sed -i 's@^PrivateTmp.*@#&@g' /lib/systemd/system/php-fpm.service; systemctl daemon-reload; }
  58. echo
  59. echo "${CSUCCESS}Congratulations! OneinStack upgrade successful! ${CEND}"
  60. echo
  61. else
  62. echo "${CWARNING}Your OneinStack already has the latest version or does not need to be upgraded! ${CEND}"
  63. fi
  64. [ ! -e "${oneinstack_dir}/options.conf" ] && [ -e "/tmp/options.conf" ] && /bin/cp /tmp/options.conf ${oneinstack_dir}/options.conf
  65. popd > /dev/null
  66. }