From 08f9ef84a65735f9893cc6816753129a5869951e Mon Sep 17 00:00:00 2001 From: th33xitus Date: Wed, 20 Apr 2022 11:59:17 +0200 Subject: [PATCH] refactor(utilities.sh): refactor system updates - remove unused restart_nginx function Signed-off-by: Dominik Willner th33xitus@gmail.com --- scripts/ui/update_menu.sh | 2 +- scripts/utilities.sh | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/scripts/ui/update_menu.sh b/scripts/ui/update_menu.sh index e126a27..893a339 100755 --- a/scripts/ui/update_menu.sh +++ b/scripts/ui/update_menu.sh @@ -34,7 +34,7 @@ function update_ui(){ echo -e "| 6) [PrettyGCode] |$(compare_prettygcode_versions)| " echo -e "| 7) [Telegram Bot] |$(compare_telegram_bot_versions)| " echo -e "| |------------------------------| " - echo -e "| 8) [System] | $DISPLAY_SYS_UPDATE | " + echo -e "| 8) [System] | $(check_system_updates) | " back_footer } diff --git a/scripts/utilities.sh b/scripts/utilities.sh index ee71ed9..6c93b54 100644 --- a/scripts/utilities.sh +++ b/scripts/utilities.sh @@ -535,22 +535,26 @@ function fetch_webui_ports(){ #================================================# function check_system_updates(){ - SYS_UPDATE=$(apt list --upgradeable 2>/dev/null | sed "1d") - if [ ! -z "$SYS_UPDATE" ]; then + local updates_avail info_msg + updates_avail=$(apt list --upgradeable 2>/dev/null | sed "1d") + if [ -n "${updates_avail}" ]; then # add system updates to the update all array for the update all function in the updater SYS_UPDATE_AVAIL="true" && update_arr+=(update_system) - DISPLAY_SYS_UPDATE="${yellow}System upgrade available!${white}" + info_msg="${yellow}System upgrade available!${white}" else SYS_UPDATE_AVAIL="false" - DISPLAY_SYS_UPDATE="${green}System up to date! ${white}" + info_msg="${green}System up to date! ${white}" fi + echo "${info_msg}" } function update_system(){ status_msg "Updating System ..." - sudo apt-get update --allow-releaseinfo-change && sudo apt-get upgrade -y - CONFIRM_MSG="Update complete! Check the log above!\n ${yellow}KIAUH will not install any dist-upgrades or\n any packages which have been kept back!${green}" - print_msg && clear_msg + if sudo apt-get update --allow-releaseinfo-change && sudo apt-get upgrade -y; then + print_confirm "Update complete! Check the log above!\n ${yellow}KIAUH will not install any dist-upgrades or\n any packages which have been kept back!${green}" + else + print_error "System update failed! Please watch for any errors printed above!" + fi } function check_usergroups(){