forked from phillipdavidstearns/simcom_wwan-setup
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuninstall.sh
executable file
·75 lines (64 loc) · 1.63 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
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# Uninstall files and scripts for [email protected]
SCRIPT_PATH="/etc/simcom_wwan"
SERVICE_PATH="/lib/systemd/system"
SERVICE_FILE="[email protected]"
IFACE="wwan0"
SERVICE="simcom_wwan@$IFACE.service"
if [ "$EUID" -ne 0 ]
then echo "[!] Please run as root"
exit 1
fi
# Remove the service file
if [[ -f "$SERVICE_PATH/$SERVICE_FILE" ]]; then
echo "[*] Stopping $SERVICE_FILE"
if (systemctl stop "$SERVICE"); then
echo "[+] Stopped $SERVICE_FILE"
else
echo "[!] Failed to stop $SERVICE_FILE"
exit 1
fi
echo "[*] Disabling $SERVICE"
if (systemctl disable "$SERVICE"); then
echo "[+] Disabled $SERVICE"
else
echo "[!] Failed to disable $SERVICE"
exit 1
fi
echo "[*] Removing $SERVICE_PATH/$SERVICE_FILE"
if (rm "$SERVICE_PATH/$SERVICE_FILE"); then
echo "[+] Removed $SERVICE_PATH/$SERVICE_FILE"
else
echo "[!] Failed to remove $SERVICE_PATH/$SERVICE_FILE"
exit 1
fi
else
echo "[-] $SERVICE_PATH/$SERVICE_FILE doesn't exist"
fi
# Remove Scripts
if [[ -d "$SCRIPT_PATH" && "$SCRIPT_PATH" != '/' ]]; then
echo "[*] Removing $SCRIPT_PATH"
if (rm -rf "$SCRIPT_PATH"); then
echo "[+] Removed $SCRIPT_PATH"
else
echo "[!] Failed to remove $SCRIPT_PATH"
exit 1
fi
else
echo "[-] Invalid path. $SCRIPT_PATH doesn't exist or is \'/\'"
fi
echo "[*] Reloading systemd configuration"
if (systemctl daemon-reload); then
echo "[+] Successfully reloaded systemd configuration"
else
echo "[!] Failed to reload systemd configuration"
exit 1
fi
echo "[*] Restarting systemd"
if (systemctl daemon-reexec); then
echo "[+] Successfully restarted systemd"
else
echo "[!] Failed to restart systemd"
exit 1
fi
exit 0