upgrade_oneinstack.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. # 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. /bin/mv backup*.sh /tmp
  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. for L in `grep -vE '^#|^$' /tmp/options.conf`
  21. do
  22. Key=`echo $L | awk -F= '{print $1}'`
  23. Value=`echo $L | awk -F= '{print $2}'`
  24. sed -i "s@^${Key}=.*@${Key}=${Value}@" ./options.conf
  25. done
  26. rm -rf /tmp/{oneinstack.tar.gz,options.conf}
  27. [ "$install_flag" == 'n' ] && { /bin/mv /tmp/backup*.sh .; rm -rf install.sh LICENSE README.md; }
  28. sed -i "s@^oneinstack_md5=.*@oneinstack_md5=${Latest_OneinStack_MD5}@" ./options.conf
  29. echo
  30. echo "${CSUCCESS}Congratulations! OneinStack successful! ${CEND}"
  31. echo
  32. else
  33. echo "${CWARNING}Your OneinStack already has the latest version or does not need to be upgraded! ${CEND}"
  34. fi
  35. popd > /dev/null
  36. }