upgrade_oneinstack.sh 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. 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 -qc http://mirrors.linuxeye.com/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. [ "${install_flag}" == 'n' ] && rm -rf install.sh LICENSE README.md
  36. sed -i "s@^oneinstack_md5=.*@oneinstack_md5=${Latest_OneinStack_MD5}@" ./options.conf
  37. echo
  38. echo "${CSUCCESS}Congratulations! OneinStack upgrade successful! ${CEND}"
  39. echo
  40. else
  41. echo "${CWARNING}Your OneinStack already has the latest version or does not need to be upgraded! ${CEND}"
  42. fi
  43. popd > /dev/null
  44. }