#!/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."