forked from manu7irl/klipper-DWC2-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathklipper-uninstall.sh
executable file
·72 lines (65 loc) · 1.88 KB
/
klipper-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
63
64
65
66
67
68
69
70
71
#!/bin/bash
# Uninstall script for raspbian/debian type installations
clear
report_status()
{
echo -e "\n\n###### $1"
}
verify_ready()
{
if [ "$EUID" -eq 0 ]; then
report_status "This script must not run as root"
exit -1
fi
}
# Force script to exit if an error occurs
set -e
verify_ready
installLocation=/home/$userSelect
PrinterFarm=$installLocation/PrinterFarm
KlipperFarm=$PrinterFarm/KlipperFarm
OctoPrintFarm=$PrinterFarm/OctoPrintFarm
OCTOPRINT=$PrinterFarm/octoprint
KLIPPER=$PrinterFarm/klipper
GITSRC=$PrinterFarm/git_source
PYTHONDIR="$KLIPPER/klippy-env"
SYSTEMDDIR="/etc/systemd/system"
KLIPPER_USER=$userSelect
KLIPPER_GROUP=$userSelect
SDCARD=$PRINTER_FOLDER/sdcard
SERV_F=$GITSRC/service_files
# Stop Klipper Service
report_status "#### Stopping Klipper Service..."
sleep 3
session_num=${find /etc/systemd/system -type f -name 'klipper-*' -printf x | wc -c}
#sudo service klipper stop
printer_num=0
while (( $printer_num <= $session_num ))
do
report_status "Stopping klipper-$printer_num service..."
sudo systemctl stop klipper-$printer_num
sleep 1
report_status "Disabling klipper-$printer_num service..."
sudo systemctl disable klipper-$printer_num
sleep 1
report_status "Removing klipper-$printer_num service..."
sudo rm /etc/systemd/system/klipper-$printer_num
sleep 1
report_status "Your printer-$printer_num.cfg is still available, under $KlipperFarm/printer-$printer-num..."
sleep 3
printer_num=$(( printer_num+1 ))
done
# Remove Klipper from Services
sleep 3
report_status "#### Removing Klipper Service.."
#sudo rm -f /etc/init.d/klipper /etc/default/klipper
sudo rm /etc/systemd/system/klipper.service
sleep 3
# Notify user of method to remove Klipper source code
sleep 3
report_status "The Klipper & DWC system files have been removed."
rm -vRf $KLIPPER $SDCARD/dwc2
sleep 3
report_status "~/sdcard folder has not been removed"
sleep 3
exit