summaryrefslogtreecommitdiffstats
path: root/uninstall.lexd_spool.sh
blob: 39a863a030e2d606f8e082cb774eeb94a30f1e97 (plain)
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
#!/bin/ksh
#
# uninstall.lexd_spool.sh - remove lexd-spool binary and rc.d script.
#
# Usage: doas ./uninstall.lexd_spool.sh

set -e

BIN_DST="/usr/local/bin/lexd-spool"
RC_DST="/etc/rc.d/lexd_spool"
SERVICE="lexd_spool"

if [ "$(id -u)" -ne 0 ]; then
	echo "error: this script must be run as root" >&2
	exit 1
fi

# stop the service if it's running 
if [ -e "$RC_DST" ] && rcctl check "$SERVICE" >/dev/null 2>&1; then
	echo "stopping $SERVICE"
	rcctl stop "$SERVICE"
fi

# disable the service if it's enabled 
if [ -e "$RC_DST" ] && rcctl ls on | grep -qx "$SERVICE"; then
	echo "disabling $SERVICE"
	rcctl disable "$SERVICE"
fi

# remove the rc.d script 
if [ -e "$RC_DST" ]; then
	echo "removing $RC_DST"
	rm -f "$RC_DST"
else
	echo "$RC_DST not present, skipping"
fi

# remove the binary 
if [ -e "$BIN_DST" ]; then
	echo "removing $BIN_DST"
	rm -f "$BIN_DST"
else
	echo "$BIN_DST not present, skipping"
fi

echo "done."