From 1c112e8ee9d9a54e2e48c1021e4ecd2b113003ce Mon Sep 17 00:00:00 2001 From: Titus Meyer Date: Tue, 1 Jun 2021 22:51:45 +0200 Subject: [PATCH] add dummy service description for moonraker update manager --- README.md | 5 ++++- install.sh | 38 +++++++++++++++++++++++++++++--------- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index b7ee5fb..d831260 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ And, if you like my work and would like to support me, please feel free to donat # News -- **v0.6.1**: As desired, added Moonraker Update possibility. +- **v0.6.2**: As desired, added Moonraker Update possibility. - **v0.5**: Added compatibility for newer Klipper versions. - **v0.4**: The "calibrate_z:probe_bed_x|y" settings can be omitted in the configuration and the "mesh:relative_reference_index" of the bed mesh is taken as default instead. @@ -281,6 +281,9 @@ install_script: install.sh The script assumes that Klipper is in `${HOME}/klipper`. +> **NOTE:** Currently, there is a dummy systemd service installed to satisfy moonraker's +> update manager. + ## How To Test It Do not bother too much about absolute values of the calculated offsets. These can vary a lot. diff --git a/install.sh b/install.sh index ad98a79..8e281ea 100755 --- a/install.sh +++ b/install.sh @@ -1,5 +1,6 @@ #!/bin/bash KLIPPER_PATH="${HOME}/klipper" +SYSTEMDDIR="/etc/systemd/system" # Step 1: Verify Klipper has been installed check_klipper() @@ -16,23 +17,41 @@ check_klipper() # Step 2: copy extension to Klipper copy_extension() { - report_status "Copying extension to Klipper..." + echo "Copying extension to Klipper..." cp "${SRCDIR}/z_calibration.py" "${KLIPPER_PATH}/klippy/extras/z_calibration.py" } -# Step 3: restarting Klipper -restart_klipper() +# Step 3: Install startup script +install_script() { - report_status "Restarting Klipper..." - sudo systemctl restart klipper +# Create systemd service file + SERVICE_FILE="${SYSTEMDDIR}/klipper_z_calibration.service" + [ -f $SERVICE_FILE ] && return + echo "Installing system start script..." + sudo /bin/sh -c "cat > ${SERVICE_FILE}" << EOF +[Unit] +Description=Dummy Service for klipper_z_calibration plugin +After=klipper.service +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/bin/bash -c 'exec -a klipper_z_calibration sleep 1' +[Install] +WantedBy=multi-user.target +EOF +# Use systemctl to enable the systemd service script + sudo systemctl daemon-reload + sudo systemctl enable klipper_z_calibration.service } -# Helper functions -report_status() +# Step 4: restarting Klipper +restart_klipper() { - echo -e "\n\n###### $1" + echo "Restarting Klipper..." + sudo systemctl restart klipper } +# Helper functions verify_ready() { if [ "$EUID" -eq 0 ]; then @@ -57,4 +76,5 @@ done # Run steps verify_ready copy_extension -restart_klipper \ No newline at end of file +install_script +restart_klipper