Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions core/tabs/system-setup/fedora/fedora-upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/bin/sh -e

. ../../common-script.sh

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" "${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 $next_version? (y/n): ${RC}"
read -r response

case "$response" in
y|Y)
printf "%b\n" "${CYAN}Preparing to update to $next_version...${RC}"

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" system-upgrade download --releasever="$next_version"; then
printf "%b\n" "${RED}Failed to download the upgrade packages.${RC}"
exit 1
fi

printf "%b\n" "${YELLOW}Do you want to reboot now to apply the upgrade? (y/n): ${RC}"
read -r reboot_response

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() {
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
}

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
6 changes: 6 additions & 0 deletions core/tabs/system-setup/tab_data.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 system to the next Fedora release"
script = "fedora/fedora-upgrade.sh"
task_list = "MP"

[[data.entries]]
name = "Virtualization"
description = "Enables Virtualization through dnf"
Expand Down