2023-06-13 12:50:12 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
DAEMON="pb-discover"
|
|
|
|
PIDFILE="/var/run/$DAEMON.pid"
|
|
|
|
|
|
|
|
# shellcheck source=/dev/null
|
2023-10-09 17:17:24 +02:00
|
|
|
[ -r "/etc/default/petitboot" ] && . "/etc/default/petitboot"
|
2023-06-13 12:50:12 +02:00
|
|
|
|
|
|
|
if [ "$(pb-config debug)" = "enabled" ] ; then
|
|
|
|
PB_DISCOVER_ARGS="$PB_DISCOVER_ARGS --verbose"
|
|
|
|
fi
|
|
|
|
|
|
|
|
start() {
|
|
|
|
printf 'Starting %s: ' "$DAEMON"
|
2023-10-09 17:17:24 +02:00
|
|
|
mkdir -p /var/log/petitboot
|
|
|
|
|
2023-06-13 12:50:12 +02:00
|
|
|
# shellcheck disable=SC2086 # we need the word splitting
|
2023-10-09 17:17:23 +02:00
|
|
|
start-stop-daemon -S -q -b -m -p "$PIDFILE" -x "/usr/sbin/$DAEMON" \
|
2023-06-13 12:50:12 +02:00
|
|
|
-- $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
|
2023-10-09 17:17:23 +02:00
|
|
|
rm -f "$PIDFILE"
|
2023-06-13 12:50:12 +02:00
|
|
|
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
|