|
|
@@ -71,22 +71,6 @@ if (file_exists("/etc/centos-release")): |
|
|
|
if (" 7." in release): |
|
|
|
# Checking if the release is EL7, if yes then continue. |
|
|
|
print(color.BOLD + color.GREEN + "Starting the upgrade process, the OS is supported" + color.END) |
|
|
|
if(file_exists("/etc/issue")): |
|
|
|
issueFile = open("/etc/issue", "r") |
|
|
|
issue = issueFile.readline() |
|
|
|
issueFile.close() |
|
|
|
if ("Ameyo OS" in issue): |
|
|
|
operatingEnvironment = "ameyos" |
|
|
|
print(color.BOLD + color.GREEN + operatingEnvironment + " detected, proceeding further with the specified tasks." + color.END) |
|
|
|
else: |
|
|
|
operatingEnvironment = "centos" |
|
|
|
print(color.BOLD + color.GREEN + operatingEnvironment + " detected, proceeding further with the specified tasks." + color.END) |
|
|
|
else: |
|
|
|
print(color.BOLD + color.RED + "OS files have been tampered with, couldn't proceed further with the upgrade" + color.END) |
|
|
|
sys.exit(-1) |
|
|
|
elif ("AlmaLinux" in release): |
|
|
|
operatingEnvironment = "alma" |
|
|
|
print(color.BOLD + color.GREEN + operatingEnvironment + " detected, proceeding further with the specified tasks." + color.END) |
|
|
|
else: |
|
|
|
print(color.BOLD + color.RED + "ERROR...! This version of CentOS / AmeyoOS is not supported." + color.END) |
|
|
|
sys.exit(-1) |
|
|
@@ -94,10 +78,16 @@ else: |
|
|
|
print(color.BOLD + color.RED + "OS files have been tampered with, couldn't proceed further with the upgrade" + color.END) |
|
|
|
sys.exit(-1) |
|
|
|
|
|
|
|
print("\n\n") |
|
|
|
print("\n") |
|
|
|
time.sleep(3) |
|
|
|
|
|
|
|
if (int(state) <= 0): |
|
|
|
# Updates the grub configuration file |
|
|
|
print(color.BOLD + color.GREEN + "Updating the grub configuration file." + color.END) |
|
|
|
os.system("rm -rvf /etc/grub2.cfg") |
|
|
|
os.system("grub2-mkconfig -o /boot/grub2/grub.cfg") |
|
|
|
os.system("ln -s /boot/grub2/grub.cfg /etc/grub2.cfg") |
|
|
|
print(color.BOLD + color.GREEN + "Grub menu updated successfully." + color.END) |
|
|
|
# Removing the old repos and installing the new repos |
|
|
|
print(color.BOLD + color.GREEN + "STEP 1 : Removing the yum repositories and restoring the required one." + color.END) |
|
|
|
os.system("rm -rvf /etc/yum.repos.d/*") |
|
|
@@ -161,13 +151,9 @@ if (int(state) <= 1): |
|
|
|
time.sleep(3) |
|
|
|
|
|
|
|
if (int(state) <= 2): |
|
|
|
# Updating the grub menu and restarting the system to boot into the latest kernel |
|
|
|
print(color.BOLD + color.GREEN + "STEP 3 : Updating the grub menu (in case of AmeyOS)" + color.END) |
|
|
|
if (operatingEnvironment == "ameyos"): |
|
|
|
os.system("sudo grub2-mkconfig -o /boot/grub2/grub.cfg") |
|
|
|
# Updating the state in the stateFile. |
|
|
|
# Rebooting our system. |
|
|
|
state = "3" |
|
|
|
print(color.BOLD + color.GREEN + "Step-3 completed, the modified state is : " + state + color.END) |
|
|
|
print(color.BOLD + color.GREEN + "Step-3, the system will REBOOT now." + state + color.END) |
|
|
|
stateFile = open("/osUpgradeEl7/stateFile", "w") |
|
|
|
stateFile.write(state) |
|
|
|
stateFile.close() |
|
|
@@ -196,7 +182,7 @@ if (int(state) <= 4): |
|
|
|
if(os.system("sudo yum install -y http://repo.almalinux.org/elevate/elevate-release-latest-el7.noarch.rpm") != 0): |
|
|
|
print(color.BOLD + color.RED + "Couldn't connect to the internet, please check your internet connection and re-run the script" + color.END) |
|
|
|
sys.exit(-1) |
|
|
|
if(os.system("sudo yum install -y leapp-upgrade leapp-data-almalinux") != 0): |
|
|
|
if(os.system("sudo yum install -y leapp-upgrade leapp-data-rocky") != 0): |
|
|
|
print(color.BOLD + color.RED + "Couldn't connect to the internet, please check your internet connection and re-run the script" + color.END) |
|
|
|
sys.exit(-1) |
|
|
|
# Updating the state in the stateFile. |
|
|
@@ -283,49 +269,13 @@ if (int(state) <= 8): |
|
|
|
|
|
|
|
if (int(state) <= 9): |
|
|
|
# Updating the grub menu and restarting the system to boot into upgrade menu. |
|
|
|
print(color.BOLD + color.GREEN + "STEP 10 : Updating the grub menu and restarting the system to boot into upgrade menu." + color.END) |
|
|
|
os.system("sudo grub2-mkconfig -o /boot/grub2/grub.cfg") |
|
|
|
# Updating the state in the stateFile. |
|
|
|
state = "10" |
|
|
|
print(color.BOLD + color.GREEN + "Step-10 completed, the modified state is : " + state + color.END) |
|
|
|
stateFile = open("/osUpgradeEl7/stateFile", "w") |
|
|
|
stateFile.write(state) |
|
|
|
stateFile.close() |
|
|
|
print("\n\n") |
|
|
|
time.sleep(3) |
|
|
|
os.system("reboot") |
|
|
|
|
|
|
|
if (operatingEnvironment == "alma"): |
|
|
|
if (int(state) <= 10): |
|
|
|
print(color.BOLD + color.GREEN + "STEP 11 : Performing the post-upgrade tasks." + color.END) |
|
|
|
os.system("mkdir -p /etc/yum.repos.d.bkp/") |
|
|
|
os.system("mv /etc/yum.repos.d/* /etc/yum.repos.d.bkp/") |
|
|
|
os.chdir("/etc/yum.repos.d/") |
|
|
|
if(os.system("curl -O https://dms-git.ameyo.net:8265/EL7toEL8/upgrade-el7-el8/raw/branch/master/alma-repo/ameyoosalma8base.repo") != 0): |
|
|
|
print(color.BOLD + color.RED + "Couldn't connect to the internet, please check your internet connection and re-run the script" + color.END) |
|
|
|
sys.exit(-1) |
|
|
|
os.chdir("/osUpgradeEl7/") |
|
|
|
if(os.system("dnf install -y yum-utils python2") !=0): |
|
|
|
print(color.BOLD + color.RED + "Couldn't connect to the internet, please check your internet connection and re-run the script" + color.END) |
|
|
|
sys.exit(-1) |
|
|
|
os.system("alternatives --set python /usr/bin/python2") |
|
|
|
if(os.system("sudo yum update -y") !=0): |
|
|
|
print(color.BOLD + color.RED + "Couldn't connect to the internet, please check your internet connection and re-run the script" + color.END) |
|
|
|
sys.exit(-1) |
|
|
|
os.system("sudo grub2-mkconfig -o /boot/grub2/grub.cfg") |
|
|
|
# Updating the state in the stateFile. |
|
|
|
state = "11" |
|
|
|
print(color.BOLD + color.GREEN + "Step-11 completed, the modified state is : " + state + color.END) |
|
|
|
stateFile = open("/osUpgradeEl7/stateFile", "w") |
|
|
|
stateFile.write(state) |
|
|
|
stateFile.close() |
|
|
|
print("\n\n") |
|
|
|
time.sleep(3) |
|
|
|
os.system("reboot") |
|
|
|
|
|
|
|
print(color.BOLD + color.GREEN + "In-place upgrade is completed, you may use the system." + color.END) |
|
|
|
else: |
|
|
|
print(color.BOLD + color.RED + "Perform the upgrade from the boot menu after restarting your system." + color.END) |
|
|
|
print(color.BOLD + color.GREEN + "Updating the /etc/issue file." + color.END) |
|
|
|
with open("/etc/issue") as issueFile: |
|
|
|
lines = issueFile.readlines() |
|
|
|
lines[0] = "Ameyo OS 8 - Rocky" |
|
|
|
with open("/etc/issue", 'w') as issueFile: |
|
|
|
issueFile.writelines(lines) |
|
|
|
print(color.BOLD + color.RED + "STEP 10 : Restart the system for upgrade." + color.END) |
|
|
|
while(True): |
|
|
|
try: |
|
|
|
input = raw_input |
|
|
@@ -336,7 +286,44 @@ else: |
|
|
|
if((rebootTask == "y") or (rebootTask == "yes")): |
|
|
|
os.system("reboot") |
|
|
|
elif((rebootTask == "n") or (rebootTask == "no")): |
|
|
|
print("You need to manually reboot the system for the upgrade.") |
|
|
|
break |
|
|
|
else: |
|
|
|
pass |
|
|
|
sys.exit(-1) |
|
|
|
# Updating the state in the stateFile. |
|
|
|
state = "10" |
|
|
|
print(color.BOLD + color.GREEN + "Step-10 completed, the modified state is : " + state + color.END) |
|
|
|
stateFile = open("/osUpgradeEl7/stateFile", "w") |
|
|
|
stateFile.write(state) |
|
|
|
stateFile.close() |
|
|
|
print("\n\n") |
|
|
|
time.sleep(3) |
|
|
|
|
|
|
|
# if (int(state) <= 10): |
|
|
|
# print(color.BOLD + color.GREEN + "STEP 11 : Performing the post-upgrade tasks." + color.END) |
|
|
|
# os.system("mkdir -p /etc/yum.repos.d.bkp/") |
|
|
|
# os.system("mv /etc/yum.repos.d/* /etc/yum.repos.d.bkp/") |
|
|
|
# os.chdir("/etc/yum.repos.d/") |
|
|
|
# if(os.system("curl -O https://dms-git.ameyo.net:8265/EL7toEL8/upgrade-el7-el8/raw/branch/master/alma-repo/ameyoosalma8base.repo") != 0): |
|
|
|
# print(color.BOLD + color.RED + "Couldn't connect to the internet, please check your internet connection and re-run the script" + color.END) |
|
|
|
# sys.exit(-1) |
|
|
|
# os.chdir("/osUpgradeEl7/") |
|
|
|
# if(os.system("dnf install -y yum-utils python2") !=0): |
|
|
|
# print(color.BOLD + color.RED + "Couldn't connect to the internet, please check your internet connection and re-run the script" + color.END) |
|
|
|
# sys.exit(-1) |
|
|
|
# os.system("alternatives --set python /usr/bin/python2") |
|
|
|
# if(os.system("sudo yum update -y") !=0): |
|
|
|
# print(color.BOLD + color.RED + "Couldn't connect to the internet, please check your internet connection and re-run the script" + color.END) |
|
|
|
# sys.exit(-1) |
|
|
|
# os.system("sudo grub2-mkconfig -o /boot/grub2/grub.cfg") |
|
|
|
# # Updating the state in the stateFile. |
|
|
|
# state = "11" |
|
|
|
# print(color.BOLD + color.GREEN + "Step-11 completed, the modified state is : " + state + color.END) |
|
|
|
# stateFile = open("/osUpgradeEl7/stateFile", "w") |
|
|
|
# stateFile.write(state) |
|
|
|
# stateFile.close() |
|
|
|
# print("\n\n") |
|
|
|
# time.sleep(3) |
|
|
|
# os.system("reboot") |
|
|
|
|
|
|
|
# print(color.BOLD + color.GREEN + "In-place upgrade is completed, you may use the system." + color.END) |