From bd90677cfaa76afcffc73939552e4d492a8a7197 Mon Sep 17 00:00:00 2001 From: th33xitus <> Date: Wed, 29 Jul 2020 21:12:07 +0200 Subject: [PATCH] add moonraker update function + ui stuff --- kiauh.sh | 6 ++++++ scripts/backup.sh | 21 ++++++++++++++++----- scripts/status.sh | 26 ++++++++++++++++++++++++++ scripts/ui.sh | 7 ++++--- scripts/update.sh | 21 +++++++++++++-------- 5 files changed, 65 insertions(+), 16 deletions(-) diff --git a/kiauh.sh b/kiauh.sh index 01cefc2..dc9a4c2 100755 --- a/kiauh.sh +++ b/kiauh.sh @@ -237,6 +237,12 @@ update_menu(){ print_msg && clear_msg update_ui;; 4) + clear + print_header + update_moonraker && ui_print_versions + print_msg && clear_msg + update_ui;; + 5) clear print_header update_mainsail && ui_print_versions diff --git a/scripts/backup.sh b/scripts/backup.sh index 2f98411..beced5d 100644 --- a/scripts/backup.sh +++ b/scripts/backup.sh @@ -10,7 +10,7 @@ backup_printer_cfg(){ if [ -f $PRINTER_CFG ]; then get_date status_msg "Create backup of printer.cfg ..." - cp $PRINTER_CFG $BACKUP_DIR/printer.cfg."$current_date".backup && ok_msg "Backup created!" + cp $PRINTER_CFG $BACKUP_DIR/printer.cfg."$current_date".backup && ok_msg "Backup complete!" else ok_msg "No printer.cfg found! Skipping backup ..." fi @@ -53,8 +53,7 @@ backup_klipper(){ get_date status_msg "Timestamp: $current_date" mkdir -p $BACKUP_DIR/klipper-backups/"$current_date" - cp -r $KLIPPER_DIR $_ && cp -r $KLIPPY_ENV_DIR $_ - ok_msg "Backup complete!" + cp -r $KLIPPER_DIR $_ && cp -r $KLIPPY_ENV_DIR $_ && ok_msg "Backup complete!" else ERROR_MSG=" Can't backup klipper and/or klipper-env directory! Not found!" fi @@ -67,8 +66,7 @@ backup_dwc2(){ get_date status_msg "Timestamp: $current_date" mkdir -p $BACKUP_DIR/dwc2-backups/"$current_date" - cp -r $DWC2FK_DIR $_ && cp -r $DWC2_DIR $_ - ok_msg "Backup complete!" + cp -r $DWC2FK_DIR $_ && cp -r $DWC2_DIR $_ && ok_msg "Backup complete!" else ERROR_MSG=" Can't backup dwc2-for-klipper and/or dwc2 directory!\n Not found!" fi @@ -87,6 +85,19 @@ backup_mainsail(){ fi } +backup_moonraker(){ + if [ -d $MOONRAKER_DIR ] && [ -d $MOONRAKER_ENV_DIR ]; then + status_msg "Creating Moonraker backup ..." + check_for_backup_dir + get_date + status_msg "Timestamp: $current_date" + mkdir -p $BACKUP_DIR/moonraker-backups/"$current_date" + cp -r $MOONRAKER_DIR $_ && cp -r $MOONRAKER_ENV_DIR $_ && ok_msg "Backup complete!" + else + ERROR_MSG=" Can't backup moonraker and/or moonraker-env directory! Not found!" + fi +} + backup_octoprint(){ if [ -d $OCTOPRINT_DIR ] && [ -d $OCTOPRINT_CFG_DIR ]; then status_msg "Creating OctoPrint backup ..." diff --git a/scripts/status.sh b/scripts/status.sh index 65b2779..4a6aa57 100644 --- a/scripts/status.sh +++ b/scripts/status.sh @@ -265,9 +265,35 @@ compare_mainsail_versions(){ fi } +read_moonraker_versions(){ + if [ -d $MOONRAKER_DIR ] && [ -d $MOONRAKER_DIR/.git ]; then + cd $MOONRAKER_DIR + git fetch origin master -q + LOCAL_MOONRAKER_COMMIT=$(git rev-parse --short=8 HEAD) + REMOTE_MOONRAKER_COMMIT=$(git rev-parse --short=8 origin/master) + else + LOCAL_MOONRAKER_COMMIT="${red}--------${default}" + REMOTE_MOONRAKER_COMMIT="${red}--------${default}" + fi +} + +compare_moonraker_versions(){ + read_moonraker_versions + #echo "Local: $LOCAL_MOONRAKER_COMMIT" + #echo "Remote: $REMOTE_MOONRAKER_COMMIT" + if [ "$LOCAL_MOONRAKER_COMMIT" != "$REMOTE_MOONRAKER_COMMIT" ]; then + LOCAL_MOONRAKER_COMMIT="${yellow}$LOCAL_MOONRAKER_COMMIT${default}" + REMOTE_MOONRAKER_COMMIT="${green}$REMOTE_MOONRAKER_COMMIT${default}" + else + LOCAL_MOONRAKER_COMMIT="${green}$LOCAL_MOONRAKER_COMMIT${default}" + REMOTE_MOONRAKER_COMMIT="${green}$REMOTE_MOONRAKER_COMMIT${default}" + fi +} + ui_print_versions(){ compare_klipper_versions compare_dwc2fk_versions compare_dwc2_versions + compare_moonraker_versions compare_mainsail_versions } \ No newline at end of file diff --git a/scripts/ui.sh b/scripts/ui.sh index 49a9a81..22d879d 100644 --- a/scripts/ui.sh +++ b/scripts/ui.sh @@ -77,11 +77,12 @@ update_ui(){ echo -e "| Firmware: | | | " echo -e "| 1) [Klipper] | $(echo "$LOCAL_COMMIT") | $(echo "$REMOTE_COMMIT") | " echo -e "| | | | " - echo -e "| Webinterface: | | | " + echo -e "| Webinterface: |---------------|--------------| " echo -e "| 2) [DWC2-for-Klipper] | $(echo "$LOCAL_DWC2FK_COMMIT") | $(echo "$REMOTE_DWC2FK_COMMIT") | " echo -e "| 3) [DWC2 Web UI] | $(echo "$DWC2_LOCAL_VER") | $(echo "$DWC2_REMOTE_VER") | " - echo -e "| 4) [Mainsail] | $(echo "$MAINSAIL_LOCAL_VER") | $(echo "$MAINSAIL_REMOTE_VER") | " - echo -e "| | | | " + echo -e "| |---------------|--------------| " + echo -e "| 4) [Moonraker] | $(echo "$LOCAL_MOONRAKER_COMMIT") | $(echo "$REMOTE_MOONRAKER_COMMIT") | " + echo -e "| 5) [Mainsail] | $(echo "$MAINSAIL_LOCAL_VER") | $(echo "$MAINSAIL_REMOTE_VER") | " quit_footer } diff --git a/scripts/update.sh b/scripts/update.sh index 16a4aa7..b054e2d 100644 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -1,11 +1,3 @@ -#TODO -# - version checks before updating - -update_check(){ - read_local_commit - read_remote_commit -} - update_kiauh(){ if [ $KIAUH_UPDATE_AVAIL = 1 ]; then status_msg "Updating KIAUH ..." @@ -65,4 +57,17 @@ update_mainsail(){ status_msg "Updating Mainsail ..." install_mainsail start_klipper +} + +update_moonraker(){ + stop_klipper && sleep 2 && stop_moonraker + bb4u "moonraker" + status_msg "Updating Moonraker ..." + if [ ! -d $MOONRAKER_DIR ]; then + cd ${HOME} && git clone $MOONRAKER_REPO + else + cd $MOONRAKER_DIR && git pull + fi + ok_msg "Update complete!" + start_moonraker && sleep 2 && start_klipper } \ No newline at end of file