-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.sh
executable file
·62 lines (54 loc) · 1.84 KB
/
uninstall.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
#!/bin/bash
CONFIG_PATH="${HOME}/printer_data/config"
REPO_PATH="${HOME}/intelligent_beacon_model"
OVERRIDES=("BEACON_MODEL_SELECT")
green=$(echo -en "\e[92m")
red=$(echo -en "\e[91m")
cyan=$(echo -en "\e[96m")
white=$(echo -en "\e[39m")
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 uninstall_macros {
local yn
while true; do
read -p "${cyan}Do you really want to uninstall IntelligentBeaconModel? (Y/n):${white} " yn
case "${yn}" in
Y|y|Yes|yes)
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"
echo "${green}${OVERRIDE} override removed"
else
echo "${red}override_${OVERRIDE}.cfg not found!"
fi
done
if [ -d "${REPO_PATH}" ]; then
chmod -R 777 "${REPO_PATH}"
rm -R "${REPO_PATH}"
echo "${green}Intelligent Beacon Model folder removed"
else
echo "${red}Intelligent Beacon Model folder not found!"
fi
break;;
N|n|No|no|"")
exit 0;;
*)
echo "${red}Invalid Input!";;
esac
done
}
preflight_checks
uninstall_macros