From 0823398458b88a320a51b42c653bdc505d14fcf6 Mon Sep 17 00:00:00 2001 From: Angaddeep Singh <159604852+Angxddeep@users.noreply.github.com> Date: Wed, 30 Oct 2024 04:12:26 +0530 Subject: [PATCH 01/15] 1st commit --- .../system-setup/fedora/fedora-upgrade.sh | 85 +++++++++++++++++++ core/tabs/system-setup/tab_data.toml | 6 ++ 2 files changed, 91 insertions(+) create mode 100644 core/tabs/system-setup/fedora/fedora-upgrade.sh diff --git a/core/tabs/system-setup/fedora/fedora-upgrade.sh b/core/tabs/system-setup/fedora/fedora-upgrade.sh new file mode 100644 index 000000000..e5fe26284 --- /dev/null +++ b/core/tabs/system-setup/fedora/fedora-upgrade.sh @@ -0,0 +1,85 @@ +#!/bin/sh -e + +. ../../common-script.sh + +# Global version variables +current_version=$(rpm -E '%{fedora}') +next_version=$((current_version + 1)) +previous_version=$((current_version - 1)) + +# Function to update Fedora +update() { + printf "%b\n" "${RED}Make sure your system is fully updated; if not, update first and reboot once.${RC}" + printf "%b\n" "${CYAN}Your current Fedora version is $current_version.${RC}" + printf "%b\n" "${CYAN}The next available version is $next_version.${RC}" + + printf "%b\n" "${YELLOW}Do you want to update to Fedora version $next_version? (y/n): ${RC}" + read -r response + + if [[ "$response" =~ ^[Yy]$ ]]; then + printf "%b\n" "${CYAN}Preparing to update to Fedora version $next_version...${RC}" + + # Install the system upgrade plugin + if ! "$ESCALATION_TOOL" "$PACKAGER" install dnf-plugin-system-upgrade -y; then + printf "%b\n" "${RED}Failed to install dnf-plugin-system-upgrade.${RC}" + exit 1 + fi + + # Download the upgrade packages + if ! "$ESCALATION_TOOL" "$PACKAGER" system-upgrade download --releasever="$next_version"; then + printf "%b\n" "${RED}Failed to download the upgrade packages.${RC}" + exit 1 + fi + + #Asking for rebooting + printf "%b\n" "${YELLOW}Do you want to reboot now to apply the upgrade? (y/n): ${RC}" + read -r reboot_response + + if [[ "$reboot_response" =~ ^[Yy]$ ]]; then + printf "%b\n" "${GREEN}Rebooting to apply the upgrade...${RC}" + "$ESCALATION_TOOL" "$PACKAGER" system-upgrade reboot + else + printf "%b\n" "${YELLOW}You can reboot later to apply the upgrade.${RC}" + fi + else + printf "%b\n" "${RED}No upgrade performed.${RC}" + fi +} + +# Function to run post-upgrade tasks +post_upgrade() { + printf "%b\n" "${YELLOW}Running post-upgrade tasks...${RC}" + + case "$PACKAGER" in + dnf) + "$ESCALATION_TOOL" "$PACKAGER" autoremove + "$ESCALATION_TOOL" "$PACKAGER" distro-sync -y + ;; + *) + printf "%b\n" "${RED}Unsupported package manager: $PACKAGER.${RC}" + exit 1 + ;; + esac +} + +# Main menu +checkEnv +checkEscalationTool + +printf "%b\n" "${YELLOW}Select an option:${RC}" +printf "%b\n" "${GREEN}1. Upgrade to the next Fedora version${RC}" +printf "%b\n" "${GREEN}2. Run post-upgrade tasks${RC}" +read -r choice + +case "$choice" in + 1) + update + ;; + 2) + post_upgrade + ;; + *) + printf "%b\n" "${RED}Invalid option. Please select 1 or 2.${RC}" + exit 1 + ;; +esac diff --git a/core/tabs/system-setup/tab_data.toml b/core/tabs/system-setup/tab_data.toml index 080c06d99..95ee58e73 100644 --- a/core/tabs/system-setup/tab_data.toml +++ b/core/tabs/system-setup/tab_data.toml @@ -59,6 +59,12 @@ description = "RPM Fusion provides software that the Fedora Project or Red Hat d script = "fedora/rpm-fusion-setup.sh" task_list = "MP" +[[data.entries]] +name = "Upgrade to a New Fedora Release" +description = "Upgrades the System to next fedora release" +script = "fedora/fedora-upgrade.sh" +task_list = "MP" + [[data.entries]] name = "Virtualization" description = "Enables Virtualization through dnf" From d7ef9404c138497d77c1883c1c209fbca767f74b Mon Sep 17 00:00:00 2001 From: Angaddeep Singh <159604852+Angxddeep@users.noreply.github.com> Date: Wed, 30 Oct 2024 04:21:54 +0530 Subject: [PATCH 02/15] Update tab_data.toml --- core/tabs/system-setup/tab_data.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/tabs/system-setup/tab_data.toml b/core/tabs/system-setup/tab_data.toml index 95ee58e73..c512189fe 100644 --- a/core/tabs/system-setup/tab_data.toml +++ b/core/tabs/system-setup/tab_data.toml @@ -61,7 +61,7 @@ task_list = "MP" [[data.entries]] name = "Upgrade to a New Fedora Release" -description = "Upgrades the System to next fedora release" +description = "Upgrades the System to the next fedora release" script = "fedora/fedora-upgrade.sh" task_list = "MP" From fdc96087bcaffc1c79e09a84c81d2829a2757ff7 Mon Sep 17 00:00:00 2001 From: Angaddeep Singh <159604852+Angxddeep@users.noreply.github.com> Date: Wed, 30 Oct 2024 04:25:45 +0530 Subject: [PATCH 03/15] bashism fix --- core/tabs/system-setup/fedora/fedora-upgrade.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/tabs/system-setup/fedora/fedora-upgrade.sh b/core/tabs/system-setup/fedora/fedora-upgrade.sh index e5fe26284..2c0835ce7 100644 --- a/core/tabs/system-setup/fedora/fedora-upgrade.sh +++ b/core/tabs/system-setup/fedora/fedora-upgrade.sh @@ -16,7 +16,7 @@ update() { printf "%b\n" "${YELLOW}Do you want to update to Fedora version $next_version? (y/n): ${RC}" read -r response - if [[ "$response" =~ ^[Yy]$ ]]; then + if [ "$response" =~ ^[Yy]$ ]; then printf "%b\n" "${CYAN}Preparing to update to Fedora version $next_version...${RC}" # Install the system upgrade plugin @@ -35,7 +35,7 @@ update() { printf "%b\n" "${YELLOW}Do you want to reboot now to apply the upgrade? (y/n): ${RC}" read -r reboot_response - if [[ "$reboot_response" =~ ^[Yy]$ ]]; then + if [ "$reboot_response" =~ ^[Yy]$ ]; then printf "%b\n" "${GREEN}Rebooting to apply the upgrade...${RC}" "$ESCALATION_TOOL" "$PACKAGER" system-upgrade reboot else From 29c9b0df917fedd7a991fae9bfc10e93c311c0c0 Mon Sep 17 00:00:00 2001 From: Angaddeep Singh Date: Wed, 30 Oct 2024 09:18:18 +0530 Subject: [PATCH 04/15] Update core/tabs/system-setup/fedora/fedora-upgrade.sh Co-authored-by: Adam Perkowski --- core/tabs/system-setup/fedora/fedora-upgrade.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/core/tabs/system-setup/fedora/fedora-upgrade.sh b/core/tabs/system-setup/fedora/fedora-upgrade.sh index 2c0835ce7..88f1a48e2 100644 --- a/core/tabs/system-setup/fedora/fedora-upgrade.sh +++ b/core/tabs/system-setup/fedora/fedora-upgrade.sh @@ -2,7 +2,6 @@ . ../../common-script.sh -# Global version variables current_version=$(rpm -E '%{fedora}') next_version=$((current_version + 1)) previous_version=$((current_version - 1)) From f7aee7c096f59d71abb9a26d0f91dc3b43eca8f5 Mon Sep 17 00:00:00 2001 From: Angaddeep Singh Date: Wed, 30 Oct 2024 09:18:37 +0530 Subject: [PATCH 05/15] Update core/tabs/system-setup/fedora/fedora-upgrade.sh Co-authored-by: Adam Perkowski --- core/tabs/system-setup/fedora/fedora-upgrade.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/core/tabs/system-setup/fedora/fedora-upgrade.sh b/core/tabs/system-setup/fedora/fedora-upgrade.sh index 88f1a48e2..40fe97a36 100644 --- a/core/tabs/system-setup/fedora/fedora-upgrade.sh +++ b/core/tabs/system-setup/fedora/fedora-upgrade.sh @@ -6,7 +6,6 @@ current_version=$(rpm -E '%{fedora}') next_version=$((current_version + 1)) previous_version=$((current_version - 1)) -# Function to update Fedora update() { printf "%b\n" "${RED}Make sure your system is fully updated; if not, update first and reboot once.${RC}" printf "%b\n" "${CYAN}Your current Fedora version is $current_version.${RC}" From ea0ec8eb1ca853f9a6505d380abb5df273a4eab2 Mon Sep 17 00:00:00 2001 From: Angaddeep Singh Date: Wed, 30 Oct 2024 09:18:45 +0530 Subject: [PATCH 06/15] Update core/tabs/system-setup/fedora/fedora-upgrade.sh Co-authored-by: Adam Perkowski --- core/tabs/system-setup/fedora/fedora-upgrade.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/core/tabs/system-setup/fedora/fedora-upgrade.sh b/core/tabs/system-setup/fedora/fedora-upgrade.sh index 40fe97a36..315783c0f 100644 --- a/core/tabs/system-setup/fedora/fedora-upgrade.sh +++ b/core/tabs/system-setup/fedora/fedora-upgrade.sh @@ -44,7 +44,6 @@ update() { fi } -# Function to run post-upgrade tasks post_upgrade() { printf "%b\n" "${YELLOW}Running post-upgrade tasks...${RC}" From bc02407b469a44831b2178fa29b228030a01e93e Mon Sep 17 00:00:00 2001 From: Angaddeep Singh Date: Wed, 30 Oct 2024 09:18:52 +0530 Subject: [PATCH 07/15] Update core/tabs/system-setup/fedora/fedora-upgrade.sh Co-authored-by: Adam Perkowski --- core/tabs/system-setup/fedora/fedora-upgrade.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/core/tabs/system-setup/fedora/fedora-upgrade.sh b/core/tabs/system-setup/fedora/fedora-upgrade.sh index 315783c0f..4f119b611 100644 --- a/core/tabs/system-setup/fedora/fedora-upgrade.sh +++ b/core/tabs/system-setup/fedora/fedora-upgrade.sh @@ -59,7 +59,6 @@ post_upgrade() { esac } -# Main menu checkEnv checkEscalationTool From 4ad8d766ecef458a048f87acc07a2dc2388ea1d6 Mon Sep 17 00:00:00 2001 From: Angaddeep Singh Date: Wed, 30 Oct 2024 09:19:06 +0530 Subject: [PATCH 08/15] Update core/tabs/system-setup/tab_data.toml Co-authored-by: Adam Perkowski --- core/tabs/system-setup/tab_data.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/tabs/system-setup/tab_data.toml b/core/tabs/system-setup/tab_data.toml index c512189fe..850ef38ed 100644 --- a/core/tabs/system-setup/tab_data.toml +++ b/core/tabs/system-setup/tab_data.toml @@ -61,7 +61,7 @@ task_list = "MP" [[data.entries]] name = "Upgrade to a New Fedora Release" -description = "Upgrades the System to the next fedora release" +description = "Upgrades system to the next Fedora release" script = "fedora/fedora-upgrade.sh" task_list = "MP" From 85cffe73b1b969eabe823b802cba37de840009b7 Mon Sep 17 00:00:00 2001 From: Angaddeep Singh Date: Wed, 30 Oct 2024 09:19:15 +0530 Subject: [PATCH 09/15] Update core/tabs/system-setup/fedora/fedora-upgrade.sh Co-authored-by: Adam Perkowski --- core/tabs/system-setup/fedora/fedora-upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/tabs/system-setup/fedora/fedora-upgrade.sh b/core/tabs/system-setup/fedora/fedora-upgrade.sh index 4f119b611..0c270dde3 100644 --- a/core/tabs/system-setup/fedora/fedora-upgrade.sh +++ b/core/tabs/system-setup/fedora/fedora-upgrade.sh @@ -7,7 +7,7 @@ next_version=$((current_version + 1)) previous_version=$((current_version - 1)) update() { - printf "%b\n" "${RED}Make sure your system is fully updated; if not, update first and reboot once.${RC}" + printf "%b\n" "${RED}Make sure your system is fully updated; if not, update it first and reboot once.${RC}" printf "%b\n" "${CYAN}Your current Fedora version is $current_version.${RC}" printf "%b\n" "${CYAN}The next available version is $next_version.${RC}" From d5ed0cb13b9ebe5778d148ad2a46fb86683d4900 Mon Sep 17 00:00:00 2001 From: Angaddeep Singh Date: Wed, 30 Oct 2024 09:19:37 +0530 Subject: [PATCH 10/15] Update core/tabs/system-setup/fedora/fedora-upgrade.sh Co-authored-by: Adam Perkowski --- core/tabs/system-setup/fedora/fedora-upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/tabs/system-setup/fedora/fedora-upgrade.sh b/core/tabs/system-setup/fedora/fedora-upgrade.sh index 0c270dde3..e563dba79 100644 --- a/core/tabs/system-setup/fedora/fedora-upgrade.sh +++ b/core/tabs/system-setup/fedora/fedora-upgrade.sh @@ -11,7 +11,7 @@ update() { printf "%b\n" "${CYAN}Your current Fedora version is $current_version.${RC}" printf "%b\n" "${CYAN}The next available version is $next_version.${RC}" - printf "%b\n" "${YELLOW}Do you want to update to Fedora version $next_version? (y/n): ${RC}" + printf "%b\n" "${YELLOW}Do you want to update to $next_version? (y/n): ${RC}" read -r response if [ "$response" =~ ^[Yy]$ ]; then From 79ceae9f3724a35c33c38f4c8d24e2c0d1d1bd74 Mon Sep 17 00:00:00 2001 From: Angaddeep Singh Date: Wed, 30 Oct 2024 09:21:46 +0530 Subject: [PATCH 11/15] Update core/tabs/system-setup/fedora/fedora-upgrade.sh Co-authored-by: Adam Perkowski --- .../system-setup/fedora/fedora-upgrade.sh | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/core/tabs/system-setup/fedora/fedora-upgrade.sh b/core/tabs/system-setup/fedora/fedora-upgrade.sh index e563dba79..dd9376fb0 100644 --- a/core/tabs/system-setup/fedora/fedora-upgrade.sh +++ b/core/tabs/system-setup/fedora/fedora-upgrade.sh @@ -14,34 +14,38 @@ update() { printf "%b\n" "${YELLOW}Do you want to update to $next_version? (y/n): ${RC}" read -r response - if [ "$response" =~ ^[Yy]$ ]; then - printf "%b\n" "${CYAN}Preparing to update to Fedora version $next_version...${RC}" + case "$response" in + y|Y) + printf "%b\n" "${CYAN}Preparing to update to $next_version...${RC}" - # Install the system upgrade plugin - if ! "$ESCALATION_TOOL" "$PACKAGER" install dnf-plugin-system-upgrade -y; then - printf "%b\n" "${RED}Failed to install dnf-plugin-system-upgrade.${RC}" - exit 1 - fi + if ! "$ESCALATION_TOOL" "$PACKAGER" install dnf-plugin-system-upgrade -y; then + printf "%b\n" "${RED}Failed to install dnf-plugin-system-upgrade.${RC}" + exit 1 + fi - # Download the upgrade packages - if ! "$ESCALATION_TOOL" "$PACKAGER" system-upgrade download --releasever="$next_version"; then - printf "%b\n" "${RED}Failed to download the upgrade packages.${RC}" - exit 1 - fi + if ! "$ESCALATION_TOOL" "$PACKAGER" system-upgrade download --releasever="$next_version"; then + printf "%b\n" "${RED}Failed to download the upgrade packages.${RC}" + exit 1 + fi - #Asking for rebooting - printf "%b\n" "${YELLOW}Do you want to reboot now to apply the upgrade? (y/n): ${RC}" - read -r reboot_response + printf "%b\n" "${YELLOW}Do you want to reboot now to apply the upgrade? (y/n): ${RC}" + read -r reboot_response - if [ "$reboot_response" =~ ^[Yy]$ ]; then - printf "%b\n" "${GREEN}Rebooting to apply the upgrade...${RC}" - "$ESCALATION_TOOL" "$PACKAGER" system-upgrade reboot - else - printf "%b\n" "${YELLOW}You can reboot later to apply the upgrade.${RC}" - fi - else - printf "%b\n" "${RED}No upgrade performed.${RC}" - fi + case "$reboot_response" in + y|Y) + printf "%b\n" "${GREEN}Rebooting to apply the upgrade...${RC}" + "$ESCALATION_TOOL" "$PACKAGER" system-upgrade reboot + ;; + *) + printf "%b\n" "${YELLOW}You can reboot later to apply the upgrade.${RC}" + ;; + esac + ;; + *) + printf "%b\n" "${RED}No upgrade performed.${RC}" + ;; + esac +} } post_upgrade() { From eda8c458b73c90a914eb76142265bf54c561d600 Mon Sep 17 00:00:00 2001 From: Angaddeep Singh Date: Wed, 30 Oct 2024 09:28:04 +0530 Subject: [PATCH 12/15] Update core/tabs/system-setup/fedora/fedora-upgrade.sh Co-authored-by: Adam Perkowski --- core/tabs/system-setup/fedora/fedora-upgrade.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/core/tabs/system-setup/fedora/fedora-upgrade.sh b/core/tabs/system-setup/fedora/fedora-upgrade.sh index dd9376fb0..6a9605e8c 100644 --- a/core/tabs/system-setup/fedora/fedora-upgrade.sh +++ b/core/tabs/system-setup/fedora/fedora-upgrade.sh @@ -4,7 +4,6 @@ current_version=$(rpm -E '%{fedora}') next_version=$((current_version + 1)) -previous_version=$((current_version - 1)) update() { printf "%b\n" "${RED}Make sure your system is fully updated; if not, update it first and reboot once.${RC}" From 3f57c2d2ee7ede5fdc984158d3fc4bd83426b472 Mon Sep 17 00:00:00 2001 From: Angaddeep Singh <159604852+Angxddeep@users.noreply.github.com> Date: Wed, 30 Oct 2024 17:40:01 +0530 Subject: [PATCH 13/15] update --- core/tabs/system-setup/fedora/fedora-upgrade.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/core/tabs/system-setup/fedora/fedora-upgrade.sh b/core/tabs/system-setup/fedora/fedora-upgrade.sh index 6a9605e8c..213d3bc00 100644 --- a/core/tabs/system-setup/fedora/fedora-upgrade.sh +++ b/core/tabs/system-setup/fedora/fedora-upgrade.sh @@ -45,7 +45,6 @@ update() { ;; esac } -} post_upgrade() { printf "%b\n" "${YELLOW}Running post-upgrade tasks...${RC}" From 97823663486c01236494d49ce2894e9d77e6deb7 Mon Sep 17 00:00:00 2001 From: Angaddeep Singh Date: Wed, 30 Oct 2024 18:39:49 +0530 Subject: [PATCH 14/15] Apply suggestions from code review Co-authored-by: JEEVITHA KANNAN K S --- core/tabs/system-setup/fedora/fedora-upgrade.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/tabs/system-setup/fedora/fedora-upgrade.sh b/core/tabs/system-setup/fedora/fedora-upgrade.sh index 213d3bc00..b3cb1b356 100644 --- a/core/tabs/system-setup/fedora/fedora-upgrade.sh +++ b/core/tabs/system-setup/fedora/fedora-upgrade.sh @@ -6,7 +6,7 @@ current_version=$(rpm -E '%{fedora}') next_version=$((current_version + 1)) update() { - printf "%b\n" "${RED}Make sure your system is fully updated; if not, update it first and reboot once.${RC}" + printf "%b\n" "${YELLOW}Make sure your system is fully updated; if not, update it first and reboot once.${RC}" printf "%b\n" "${CYAN}Your current Fedora version is $current_version.${RC}" printf "%b\n" "${CYAN}The next available version is $next_version.${RC}" @@ -32,7 +32,7 @@ update() { case "$reboot_response" in y|Y) - printf "%b\n" "${GREEN}Rebooting to apply the upgrade...${RC}" + printf "%b\n" "${YELLOW}Rebooting to apply the upgrade...${RC}" "$ESCALATION_TOOL" "$PACKAGER" system-upgrade reboot ;; *) From df38d66d535198757f1b016efd318ac92704957b Mon Sep 17 00:00:00 2001 From: Angaddeep Singh <159604852+Angxddeep@users.noreply.github.com> Date: Wed, 30 Oct 2024 18:41:36 +0530 Subject: [PATCH 15/15] Update fedora-upgrade.sh --- core/tabs/system-setup/fedora/fedora-upgrade.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/tabs/system-setup/fedora/fedora-upgrade.sh b/core/tabs/system-setup/fedora/fedora-upgrade.sh index b3cb1b356..47f1e0612 100644 --- a/core/tabs/system-setup/fedora/fedora-upgrade.sh +++ b/core/tabs/system-setup/fedora/fedora-upgrade.sh @@ -22,7 +22,7 @@ update() { exit 1 fi - if ! "$ESCALATION_TOOL" "$PACKAGER" system-upgrade download --releasever="$next_version"; then + if ! "$ESCALATION_TOOL" "$PACKAGER" system-upgrade download --releasever="$next_version" -y ; then printf "%b\n" "${RED}Failed to download the upgrade packages.${RC}" exit 1 fi