-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·107 lines (86 loc) · 3.21 KB
/
install.sh
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/bin/bash
CONFIG_PATH="${HOME}/printer_data/config"
REPO_PATH="${HOME}/klicky"
OVERRIDES=("HOMING" "Z_TILT_ADJUST" "PROBE" "PROBE_ACCURACY" "PROBE_CALIBRATE" "BED_MESH_CALIBRATE" "QUAD_GANTRY_LEVEL")
VARIABLES=("park" "homing" "probe" "klicky" "bed_mesh")
set -eu
export LC_ALL=C
function preflight_checks {
if [ "$EUID" -eq 0 ]; then
echo "[PRE-CHECK] This script must not be run as root!"
exit -1
fi
if [ "$(sudo systemctl list-units --full -all -t service --no-legend | grep -F 'klipper.service')" ]; then
printf "[PRE-CHECK] Klipper service found! Continuing...\n\n"
else
echo "[ERROR] Klipper service not found, please install Klipper first!"
exit -1
fi
}
function check_download {
local klickydirname klickybasename
klickydirname="$(dirname ${REPO_PATH})"
klickybasename="$(basename ${REPO_PATH})"
if [ ! -d "${REPO_PATH}" ]; then
echo "[DOWNLOAD] Downloading Klicky repository..."
if git -C $klickydirname clone https://github.com/LynxCrew/Klicky.git $klickybasename; then
chmod +x ${REPO_PATH}/install.sh
chmod +x ${REPO_PATH}/update.sh
chmod +x ${REPO_PATH}/uninstall.sh
printf "[DOWNLOAD] Download complete!\n\n"
else
echo "[ERROR] Download of Klicky git repository failed!"
exit -1
fi
else
printf "[DOWNLOAD] Klicky repository already found locally. Continuing...\n\n"
fi
}
function link_extension {
echo "[INSTALL] Linking extension to Klipper..."
if [ -d "${CONFIG_PATH}/Klicky" ]; then
chmod -R 777 "${CONFIG_PATH}/Klicky"
rm -R "${CONFIG_PATH}/Klicky"
fi
cp -rf "${REPO_PATH}/Klicky" "${CONFIG_PATH}/Klicky"
chmod 755 "${CONFIG_PATH}/Klicky"
for FILE in "${CONFIG_PATH}/Klicky/*"; do
chmod 644 $FILE
done
mkdir -p "${CONFIG_PATH}/Overrides"
for OVERRIDE in ${OVERRIDES[@]}; do
if [ -f "${CONFIG_PATH}/Overrides/override_${OVERRIDE}.cfg" ]; then
chmod -R 777 "${CONFIG_PATH}/Overrides/override_${OVERRIDE}.cfg"
rm -R "${CONFIG_PATH}/Overrides/override_${OVERRIDE}.cfg"
fi
cp -rf "${REPO_PATH}/Overrides/override_${OVERRIDE}.cfg" "${CONFIG_PATH}/Overrides/override_${OVERRIDE}.cfg"
done
chmod 755 "${CONFIG_PATH}/Overrides"
for FILE in "${CONFIG_PATH}/Overrides/*"; do
chmod 644 $FILE
done
mkdir -p "${CONFIG_PATH}/Variables"
for VARIABLE in ${VARIABLES[@]}; do
if [ ! -f "${CONFIG_PATH}/Variables/${VARIABLE}_variables.cfg" ]; then
cp -f "${REPO_PATH}/Variables/${VARIABLE}_variables.cfg" "${CONFIG_PATH}/Variables/${VARIABLE}_variables.cfg"
else
echo "${VARIABLE}-variables file already exists"
fi
done
chmod 755 "${CONFIG_PATH}/Variables"
for FILE in "${CONFIG_PATH}/Variables/*"; do
chmod 644 $FILE
done
}
function restart_klipper {
echo "[POST-INSTALL] Restarting Klipper..."
sudo systemctl restart klipper
}
printf "\n======================================\n"
echo "- Klicky install script -"
printf "======================================\n\n"
# Run steps
preflight_checks
check_download
link_extension
restart_klipper