forked from garethgeorge/backrest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall.sh
executable file
·48 lines (38 loc) · 1.29 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
#! /bin/bash
cd "$(dirname "$0")" # cd to the directory of this script
uninstall_unix() {
echo "Uninstalling backrest from /usr/local/bin/backrest"
sudo rm -f /usr/local/bin/backrest
}
remove_systemd_service() {
if [ ! -d /etc/systemd/system ]; then
echo "Systemd not found. This script is only for systemd based systems."
exit 1
fi
echo "Removing systemd service at /etc/systemd/system/backrest.service"
sudo systemctl stop backrest
sudo systemctl disable backrest
sudo rm -f /etc/systemd/system/backrest.service
echo "Reloading systemd daemon"
sudo systemctl daemon-reload
}
remove_launchd_plist() {
echo "Removing launchd plist at /Library/LaunchAgents/com.backrest.plist"
launchctl unload /Library/LaunchAgents/com.backrest.plist || true
sudo rm /Library/LaunchAgents/com.backrest.plist
}
OS=$(uname -s)
if [ "$OS" = "Darwin" ]; then
echo "Uninstalling on Darwin"
uninstall_unix
remove_launchd_plist
echo "Done -- run `launchctl list | grep backrest` to check the service installation."
elif [ "$OS" = "Linux" ]; then
echo "Unnstalling on Linux"
uninstall_unix
remove_systemd_service
echo "Done -- run `systemctl status backrest` to check the status of the service."
else
echo "Unknown OS: $OS. This script only supports Darwin and Linux."
exit 1
fi