upgrade_oneinstack.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # BLOG: https://blog.linuxeye.cn
  4. #
  5. # Notes: OneinStack for CentOS/RadHat 6+ Debian 6+ and Ubuntu 12+
  6. #
  7. # Project home page:
  8. # https://oneinstack.com
  9. # https://github.com/lj2007331/oneinstack
  10. Upgrade_OneinStack() {
  11. pushd ${oneinstack_dir} > /dev/null
  12. Latest_OneinStack_MD5=$(curl -s http://mirrors.linuxeye.com/md5sum.txt | grep oneinstack.tar.gz | awk '{print $1}')
  13. [ ! -e install.sh ] && install_flag=n
  14. #[ -e /etc/ld.so.conf.d/*openssl.conf ] && { /bin/mv /etc/ld.so.conf.d/{openssl.conf,z_openssl.conf}; ldconfig; }
  15. if [ "$oneinstack_md5" != "$Latest_OneinStack_MD5" ]; then
  16. /bin/mv options.conf /tmp
  17. sed -i '/oneinstack_dir=/d' /tmp/options.conf
  18. [ -e /tmp/oneinstack.tar.gz ] && rm -rf /tmp/oneinstack.tar.gz
  19. wget -qc http://mirrors.linuxeye.com/oneinstack.tar.gz -O /tmp/oneinstack.tar.gz
  20. if [ -n "`echo ${oneinstack_dir} | grep lnmp`" ]; then
  21. tar xzf /tmp/oneinstack.tar.gz -C /tmp
  22. /bin/cp -R /tmp/oneinstack/* ${oneinstack_dir}/
  23. /bin/rm -rf /tmp/oneinstack
  24. else
  25. tar xzf /tmp/oneinstack.tar.gz -C ../
  26. fi
  27. IFS=$'\n'
  28. for L in `grep -vE '^#|^$' /tmp/options.conf`
  29. do
  30. IFS=$IFS_old
  31. Key="`echo ${L%%=*}`"
  32. Value="`echo ${L#*=}`"
  33. sed -i "s@^${Key}=.*@${Key}=${Value}@" ./options.conf
  34. done
  35. rm -rf /tmp/{oneinstack.tar.gz,options.conf}
  36. [ "${install_flag}" == 'n' ] && rm -rf install.sh LICENSE README.md
  37. sed -i "s@^oneinstack_md5=.*@oneinstack_md5=${Latest_OneinStack_MD5}@" ./options.conf
  38. echo
  39. echo "${CSUCCESS}Congratulations! OneinStack upgrade successful! ${CEND}"
  40. echo
  41. else
  42. echo "${CWARNING}Your OneinStack already has the latest version or does not need to be upgraded! ${CEND}"
  43. fi
  44. popd > /dev/null
  45. }