feat: add system upgrade

This commit is contained in:
th33xitus
2021-03-26 18:09:05 +01:00
parent b9fe29068d
commit cce6ac3c88
3 changed files with 50 additions and 19 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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"
}