upgrade.sh 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #!/bin/bash
  2. #Check OS
  3. if grep -Eqi "release 6" /etc/redhat-release ; then
  4. echo "Preparing to update to CentOS 7"
  5. else
  6. echo "OS Running: `cat /etc/redhat-release`: No need to update"
  7. exit
  8. fi
  9. #New Centos Repository
  10. cat > /etc/yum.repos.d/centos-upgrade.repo <<EOF
  11. [centos-upgrade]
  12. name=centos-upgrade
  13. baseurl=https://buildlogs.centos.org/centos/6/upg/x86_64/
  14. enabled=1
  15. gpgcheck=0
  16. EOF
  17. #Install Pre-Upgrade Tool
  18. yum -y install https://buildlogs.centos.org/centos/6/upg/x86_64/Packages/openscap-1.0.8-1.0.1.el6.centos.x86_64.rpm
  19. yum -y install redhat-upgrade-tool preupgrade-assistant-*
  20. #Import CentOS7 PGP Key
  21. rpm --import http://mirror.centos.org/centos/7/os/x86_64/RPM-GPG-KEY-CentOS-7
  22. #Add Mirrorlist to Upgrade
  23. mkdir -pv /var/tmp/system-upgrade/base/ /var/tmp/system-upgrade/extras/ /var/tmp/system-upgrade/updates/
  24. echo http://mirror.centos.org/centos/7/os/x86_64/ >> /var/tmp/system-upgrade/base/mirrorlist.txt
  25. echo http://mirror.centos.org/centos/7/extras/x86_64/ >> /var/tmp/system-upgrade/extras/mirrorlist.txt
  26. echo http://mirror.centos.org/centos/7/updates/x86_64/ >> /var/tmp/system-upgrade/updates/mirrorlist.txt
  27. #Pre-Upgrade
  28. yes | preupg -v
  29. #Run CentOS Upgrade
  30. centos-upgrade-tool-cli --network=7 --instrepo=http://vault.centos.org/7.0.1406/os/x86_64/ << EOF
  31. Y
  32. EOF
  33. #Delete data update
  34. rm -rf preupgrade* upgrade.sh
  35. reboot