add: support to install klipper as systemd service

This commit is contained in:
th33xitus
2020-10-28 12:08:02 +01:00
parent 911d0d37e5
commit 5fd19aef0b
5 changed files with 59 additions and 13 deletions

View File

@@ -13,17 +13,24 @@ check_euid(){
locate_printer_cfg(){
unset PRINTER_CFG
status_msg "Locating printer.cfg via /etc/default/klipper ..."
if [ -f $KLIPPER_SERVICE2 ]; then
if [ -e $KLIPPER_SERVICE2 ]; then
status_msg "Locating printer.cfg via $KLIPPER_SERVICE2 ..."
#reads /etc/default/klipper and gets the default printer.cfg location
KLIPPY_ARGS_LINE="$(grep "KLIPPY_ARGS=" /etc/default/klipper)"
KLIPPY_ARGS_COUNT="$(grep -o " " <<< "$KLIPPY_ARGS_LINE" | wc -l)"
i=1
PRINTER_CFG=$(while [ "$i" != "$KLIPPY_ARGS_COUNT" ]; do grep -E "(\/[A-Za-z0-9\_-]+)+\/printer\.cfg" /etc/default/klipper | cut -d" " -f"$i"; i=$(( $i + 1 )); done | grep "printer.cfg")
ok_msg "printer.cfg location: '$PRINTER_CFG'"
elif [ -e $KLIPPER_SERVICE3 ]; then
#reads /etc/systemd/system/klipper.service and gets the default printer.cfg location
KLIPPY_ARGS_LINE="$(grep "ExecStart=" /etc/systemd/system/klipper.service)"
KLIPPY_ARGS_COUNT="$(grep -o " " <<< "$KLIPPY_ARGS_LINE" | wc -l)"
i=1
PRINTER_CFG=$(while [ "$i" != "$KLIPPY_ARGS_COUNT" ]; do grep -E "(\/[A-Za-z0-9\_-]+)+\/printer\.cfg" /etc/systemd/system/klipper.service | cut -d" " -f"$i"; i=$(( $i + 1 )); done | grep "printer.cfg")
ok_msg "printer.cfg location: '$PRINTER_CFG'"
else
PRINTER_CFG=""
warn_msg "Can't read /etc/default/klipper - File not found!"
warn_msg "Can't read printer.cfg location!"
fi
}