-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·38 lines (31 loc) · 1.17 KB
/
Copy pathuninstall.sh
File metadata and controls
executable file
·38 lines (31 loc) · 1.17 KB
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
#!/usr/bin/env sh
set -eu
# Removes the lookout service and binary. Keeps config and the service user by
# default so a reinstall preserves your settings.
#
# Usage (as root):
# sudo sh uninstall.sh # remove service + binary, keep config
# sudo sh uninstall.sh --purge # also remove /etc/lookout and the user
BIN_DIR="/usr/local/bin"
CONF_DIR="/etc/lookout"
UNIT_FILE="/etc/systemd/system/lookout.service"
SERVICE_USER="lookout"
PURGE=0
[ "${1:-}" = "--purge" ] && PURGE=1
fail() { echo "error: $*" >&2; exit 1; }
[ "$(id -u)" -eq 0 ] || fail "please run as root (e.g. with sudo)"
if command -v systemctl >/dev/null 2>&1; then
systemctl stop lookout 2>/dev/null || true
systemctl disable lookout 2>/dev/null || true
fi
rm -f "$UNIT_FILE"
command -v systemctl >/dev/null 2>&1 && systemctl daemon-reload || true
rm -f "${BIN_DIR}/lookout"
echo "Removed service and binary."
if [ "$PURGE" -eq 1 ]; then
rm -rf "$CONF_DIR"
id "$SERVICE_USER" >/dev/null 2>&1 && userdel "$SERVICE_USER" 2>/dev/null || true
echo "Purged config (${CONF_DIR}) and user '${SERVICE_USER}'."
else
echo "Kept config (${CONF_DIR}) and user '${SERVICE_USER}'. Use --purge to remove them."
fi