-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
49 lines (41 loc) · 1.17 KB
/
update.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
#!/bin/bash
REPO_PATH="${HOME}/nozzle-wipe"
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 update_repo {
cd ${REPO_PATH}
git fetch origin
if [ `git rev-list HEAD...origin/main --count` != 0 ]; then
echo "[UPDATE] Updating Nozzle-Wipe repository..."
if git pull origin; then
printf "[UPDATE] Download complete!\n\n"
else
echo "[ERROR] Download of Nozzle-Wipe git repository failed!"
exit -1
fi
else
echo "[UPDATE] Repo already up to date."
exit 0
fi
}
function install {
chmod +x ${REPO_PATH}/install.sh
chmod +x ${REPO_PATH}/update.sh
chmod +x ${REPO_PATH}/uninstall.sh
bash ${REPO_PATH}/install.sh
}
preflight_checks
update_repo
install