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>
master
Laurent Vivier 2023-06-13 12:50:12 +02:00 committed by Arnout Vandecappelle
parent 66681bd4a6
commit 4c8ab13b96
2 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,57 @@
#!/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

View File

@ -53,6 +53,10 @@ define PETITBOOT_POST_INSTALL
$(TARGET_DIR)/etc/petitboot/boot.d/01-create-default-dtb
$(INSTALL) -D -m 0755 $(@D)/utils/hooks/90-sort-dtb \
$(TARGET_DIR)/etc/petitboot/boot.d/90-sort-dtb
$(INSTALL) -m 0755 -D $(PETITBOOT_PKGDIR)/S15pb-discover \
$(TARGET_DIR)/etc/init.d/S15pb-discover
ln -sf /usr/sbin/pb-udhcpc \
$(TARGET_DIR)/usr/share/udhcpc/default.script.d/
endef
PETITBOOT_POST_INSTALL_TARGET_HOOKS += PETITBOOT_POST_INSTALL