upgrade_oneinstack.sh 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 -c http://mirrors.linuxeye.com/oneinstack.tar.gz -O /tmp/oneinstack.tar.gz > /dev/null 2>&1
  19. tar xzf /tmp/oneinstack.tar.gz -C ../
  20. IFS=$'\n'
  21. for L in `grep -vE '^#|^$' /tmp/options.conf`
  22. do
  23. IFS=$IFS_old
  24. Key="`echo ${L%%=*}`"
  25. Value="`echo ${L#*=}`"
  26. sed -i "s@^${Key}=.*@${Key}=${Value}@" ./options.conf
  27. done
  28. rm -rf /tmp/{oneinstack.tar.gz,options.conf}
  29. [ "$install_flag" == 'n' ] && rm -rf install.sh LICENSE README.md
  30. sed -i "s@^oneinstack_md5=.*@oneinstack_md5=${Latest_OneinStack_MD5}@" ./options.conf
  31. echo
  32. echo "${CSUCCESS}Congratulations! OneinStack upgrade successful! ${CEND}"
  33. echo
  34. else
  35. echo "${CWARNING}Your OneinStack already has the latest version or does not need to be upgraded! ${CEND}"
  36. fi
  37. popd > /dev/null
  38. }