Skip to content

Commit

Permalink
add dummy service description for moonraker update manager
Browse files Browse the repository at this point in the history
  • Loading branch information
TitusLabs committed Jun 1, 2021
1 parent 83b4a9a commit 1c112e8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
38 changes: 29 additions & 9 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
KLIPPER_PATH="${HOME}/klipper"
SYSTEMDDIR="/etc/systemd/system"

# Step 1: Verify Klipper has been installed
check_klipper()
Expand All @@ -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
Expand All @@ -57,4 +76,5 @@ done
# Run steps
verify_ready
copy_extension
restart_klipper
install_script
restart_klipper

0 comments on commit 1c112e8

Please sign in to comment.