forked from protoloft/klipper_z_calibration
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·76 lines (66 loc) · 1.85 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·76 lines (66 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
KLIPPER_PATH="${HOME}/klipper"
SYSTEMDDIR="/etc/systemd/system"
# Step 1: Verify Klipper has been installed
check_klipper()
{
if [ "$(sudo systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ]; then
echo "Klipper service found!"
else
echo "Klipper service not found, please install Klipper first"
exit -1
fi
}
# Step 2: link extension to Klipper
link_extension()
{
echo "Linking extension to Klipper..."
ln -sf "${SRCDIR}/offset_calibration.py" "${KLIPPER_PATH}/klippy/extras/offset_calibration.py"
}
## Step 3: Remove old dummy system service
#remove_service()
#{
# SERVICE_FILE="${SYSTEMDDIR}/offset_calibration.service"
# if [ -f $SERVICE_FILE ]; then
# echo -e "Removing system service..."
# sudo service offset_calibration stop
# sudo systemctl disable offset_calibration.service
# sudo rm "$SERVICE_FILE"
# fi
# OLD_SERVICE_FILE="${SYSTEMDDIR}/klipper_offset_calibration.service"
# if [ -f $OLD_SERVICE_FILE ]; then
# echo -e "Removing old system service..."
# sudo service klipper_offset_calibration stop
# sudo systemctl disable klipper_offset_calibration.service
# sudo rm "$OLD_SERVICE_FILE"
# fi
#}
# Step 4: restarting Klipper
restart_klipper()
{
echo "Restarting Klipper..."
sudo systemctl restart klipper
}
# Helper functions
verify_ready()
{
if [ "$EUID" -eq 0 ]; then
echo "This script must not run as root"
exit -1
fi
}
# Force script to exit if an error occurs
set -e
# Find SRCDIR from the pathname of this script
SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/ && pwd )"
# Parse command line arguments
while getopts "k:" arg; do
case $arg in
k) KLIPPER_PATH=$OPTARG;;
esac
done
# Run steps
verify_ready
link_extension
#remove_service
restart_klipper