kumquat-buildroot/package/petitboot/S15pb-discover
Laurent Vivier 4c8ab13b96 petitboot: add pb-discover daemon
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Joel Stanley <joel@jms.id.au>
[Arnout: also source /etc/default file]
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
2023-06-19 21:43:02 +02:00

58 lines
956 B
Bash

#!/bin/sh
DAEMON="pb-discover"
PIDFILE="/var/run/$DAEMON.pid"
LOGFILE="/var/log/$DAEMON.log"
PB_DISCOVER_ARGS="-l $LOGFILE"
# shellcheck source=/dev/null
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
if [ "$(pb-config debug)" = "enabled" ] ; then
PB_DISCOVER_ARGS="$PB_DISCOVER_ARGS --verbose"
fi
start() {
printf 'Starting %s: ' "$DAEMON"
# shellcheck disable=SC2086 # we need the word splitting
start-stop-daemon -S -q -b -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \
-- $PB_DISCOVER_ARGS
status=$?
if [ "$status" -eq 0 ]; then
echo "OK"
else
echo "FAIL"
fi
return "$status"
}
stop() {
printf 'Stopping %s: ' "$DAEMON"
start-stop-daemon -K -q -p "$PIDFILE"
status=$?
if [ "$status" -eq 0 ]; then
echo "OK"
else
echo "FAIL"
fi
return "$status"
}
restart() {
stop
sleep 1
start
}
case "$1" in
start|stop|restart)
"$1";;
reload)
restart;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
;;
esac