diff options
Diffstat (limited to 'uninstall.lexd_spool.sh')
| -rw-r--r-- | uninstall.lexd_spool.sh | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/uninstall.lexd_spool.sh b/uninstall.lexd_spool.sh new file mode 100644 index 0000000..39a863a --- /dev/null +++ b/uninstall.lexd_spool.sh @@ -0,0 +1,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." |
