diff --git a/scripts/functions.sh b/scripts/functions.sh index d2fb184..7202f52 100755 --- a/scripts/functions.sh +++ b/scripts/functions.sh @@ -23,7 +23,7 @@ locate_printer_cfg(){ ok_msg "printer.cfg location: '$PRINTER_CFG'" else PRINTER_CFG="" - warn_msg "Couldn't locate printer.cfg - File not found!" + warn_msg "Can't read /etc/default/klipper - File not found!" fi } diff --git a/scripts/install_moonraker.sh b/scripts/install_moonraker.sh index 42d1af4..b921fcb 100755 --- a/scripts/install_moonraker.sh +++ b/scripts/install_moonraker.sh @@ -216,6 +216,15 @@ moonraker_setup(){ #backup a possible existing printer.cfg at the old location #and before patching in the new location backup_printer_cfg + patch_klipper_sysfile + #re-run printer.cfg location function to read the new path for the printer.cfg + locate_printer_cfg + echo + ok_msg "Moonraker successfully installed!" +} + +patch_klipper_sysfile(){ + status_msg "Checking /etc/default/klipper for necessary entries ..." #patching new printer.cfg location to /etc/default/klipper if ! grep -q "/klipper_config/printer.cfg" $KLIPPER_SERVICE2; then status_msg "Patching new printer.cfg location to /etc/default/klipper ..." @@ -229,10 +238,8 @@ moonraker_setup(){ sudo sed -i "/KLIPPY_ARGS/s/\.log/\.log -a \/tmp\/klippy_uds/" $KLIPPER_SERVICE2 ok_msg "Patching done!" fi - #re-run printer.cfg location function to read the new path for the printer.cfg - locate_printer_cfg + ok_msg "Check complete!" echo - ok_msg "Moonraker successfully installed!" } check_for_folder_moonraker(){ diff --git a/scripts/update.sh b/scripts/update.sh index 627b3e2..a02d547 100755 --- a/scripts/update.sh +++ b/scripts/update.sh @@ -70,6 +70,10 @@ update_moonraker(){ else cd $MOONRAKER_DIR && git pull fi + #read default printer.cfg location for the patch function + locate_printer_cfg + #patch /etc/default/klipper if entries don't match + patch_klipper_sysfile ok_msg "Update complete!" start_moonraker && sleep 2 && start_klipper }