add moonraker update function + ui stuff

This commit is contained in:
th33xitus
2020-07-29 21:12:07 +02:00
parent e75df6d46c
commit bd90677cfa
5 changed files with 65 additions and 16 deletions

View File

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

View File

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

View File

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

View File

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

View File

@@ -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 ..."
@@ -66,3 +58,16 @@ update_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
}