From cce6ac3c880345c058446c0e200c589ade988f1a Mon Sep 17 00:00:00 2001 From: th33xitus Date: Fri, 26 Mar 2021 18:09:05 +0100 Subject: [PATCH] feat: add system upgrade --- scripts/status.sh | 12 ++++++++++ scripts/ui/update_menu.sh | 47 +++++++++++++++++++++++---------------- scripts/update.sh | 10 +++++++++ 3 files changed, 50 insertions(+), 19 deletions(-) diff --git a/scripts/status.sh b/scripts/status.sh index 4583e4f..3633e42 100755 --- a/scripts/status.sh +++ b/scripts/status.sh @@ -10,6 +10,17 @@ kiauh_status(){ fi } +check_system_updates(){ + SYS_UPDATE=$(apt list --upgradeable 2>/dev/null | sed "1d") + if [ ! -z "$SYS_UPDATE" ]; then + SYS_UPDATE_AVAIL="true" + DISPLAY_SYS_UPDATE="${yellow}System upgrade available!${default}" + else + SYS_UPDATE_AVAIL="false" + DISPLAY_SYS_UPDATE="${green}System up to date! ${default}" + fi +} + klipper_status(){ kcount=0 klipper_data=( @@ -514,6 +525,7 @@ NONE="${red}$(printf "%-12s" "--------")${default}" ui_print_versions(){ unset update_arr + check_system_updates compare_klipper_versions compare_dwc2fk_versions compare_dwc2_versions diff --git a/scripts/ui/update_menu.sh b/scripts/ui/update_menu.sh index 6c5c94b..c399169 100755 --- a/scripts/ui/update_menu.sh +++ b/scripts/ui/update_menu.sh @@ -2,35 +2,38 @@ update_ui(){ top_border echo -e "| ${green}~~~~~~~~~~~~~~ [ Update Menu ] ~~~~~~~~~~~~~~${default} | " hr - echo -e "| Check the following website for important software | " - echo -e "| changes to the config file before updating Klipper: | " - echo -e "| | " - echo -e "| ${yellow}https://www.klipper3d.org/Config_Changes.html${default} | " - bottom_border - top_border + #echo -e "| Check the following website for important software | " + #echo -e "| changes to the config file before updating Klipper: | " + #echo -e "| | " + #echo -e "| ${yellow}https://www.klipper3d.org/Config_Changes.html${default} | " + #bottom_border + #top_border echo -e "| 0) $BB4U_STATUS| " hr - echo -e "| a) [Update all] | Local Vers: | Remote Vers: | " - echo -e "| | | | " - echo -e "| Firmware: | | | " + echo -e "| a) [Update all] | | | " + echo -e "| | Local Vers: | Remote Vers: | " + echo -e "| Klipper/Klipper API: |---------------|--------------| " echo -e "| 1) [Klipper] | $LOCAL_COMMIT | $REMOTE_COMMIT | " + echo -e "| 2) [Moonraker] | $LOCAL_MOONRAKER_COMMIT | $REMOTE_MOONRAKER_COMMIT | " echo -e "| | | | " - echo -e "| Webinterface: |---------------|--------------| " - echo -e "| 2) [DWC2-for-Klipper] | $LOCAL_DWC2FK_COMMIT | $REMOTE_DWC2FK_COMMIT | " - echo -e "| 3) [DWC2 Web UI] | $DWC2_LOCAL_VER | $DWC2_REMOTE_VER | " - echo -e "| |---------------|--------------| " - echo -e "| 4) [Moonraker] | $LOCAL_MOONRAKER_COMMIT | $REMOTE_MOONRAKER_COMMIT | " - echo -e "| 5) [Mainsail] | $MAINSAIL_LOCAL_VER | $MAINSAIL_REMOTE_VER | " - echo -e "| 6) [Fluidd] | $FLUIDD_LOCAL_VER | $FLUIDD_REMOTE_VER | " + echo -e "| Klipper Webinterface: |---------------|--------------| " + echo -e "| 3) [Mainsail] | $MAINSAIL_LOCAL_VER | $MAINSAIL_REMOTE_VER | " + echo -e "| 4) [Fluidd] | $FLUIDD_LOCAL_VER | $FLUIDD_REMOTE_VER | " echo -e "| | | | " - echo -e "| HDMI Screen: |---------------|--------------| " - echo -e "| 7) [KlipperScreen] | $LOCAL_KLIPPERSCREEN_COMMIT | $REMOTE_KLIPPERSCREEN_COMMIT | " + echo -e "| Touchscreen GUI: |---------------|--------------| " + echo -e "| 5) [KlipperScreen] | $LOCAL_KLIPPERSCREEN_COMMIT | $REMOTE_KLIPPERSCREEN_COMMIT | " + echo -e "| | | | " + echo -e "| Other: |---------------|--------------| " + echo -e "| 6) [DWC2-for-Klipper] | $LOCAL_DWC2FK_COMMIT | $REMOTE_DWC2FK_COMMIT | " + echo -e "| 7) [DWC2 Web UI] | $DWC2_LOCAL_VER | $DWC2_REMOTE_VER | " + echo -e "| |------------------------------| " + echo -e "| 8) [System] | $DISPLAY_SYS_UPDATE | " quit_footer } update_menu(){ print_header - #compare versions + #check system updates and compare component versions ui_print_versions print_msg && clear_msg read_bb4u_stat @@ -86,6 +89,12 @@ update_menu(){ update_klipperscreen && ui_print_versions print_msg && clear_msg update_ui;; + 8) + clear + print_header + update_system && ui_print_versions + print_msg && clear_msg + update_ui;; a) clear print_header diff --git a/scripts/update.sh b/scripts/update.sh index 60955e7..616a541 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -39,6 +39,9 @@ update_all(){ if [ "$KLIPPERSCREEN_UPDATE_AVAIL" = "true" ]; then echo -e "| ${cyan}● KlipperScreen${default} |" fi + if [ "$SYS_UPDATE_AVAIL" = "true" ]; then + echo -e "| ${cyan}● System${default} |" + fi bottom_border if [ "${#update_arr[@]}" != "0" ]; then read -p "${cyan}###### Do you want to proceed? (Y/n):${default} " yn @@ -166,3 +169,10 @@ update_klipperscreen(){ ok_msg "Update complete!" start_klipperscreen } + +update_system(){ + status_msg "Updating System ..." + sudo apt-get update && sudo apt-get upgrade -y + ok_msg "Update complete! Check the log above!" + ok_msg "KIAUH won't do any dist-upgrades!\n" +} \ No newline at end of file