From 4c8ab13b960edcd290ea5ca7a7e739cb993fb863 Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Tue, 13 Jun 2023 12:50:12 +0200 Subject: [PATCH] petitboot: add pb-discover daemon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Laurent Vivier Reviewed-by: Cédric Le Goater Reviewed-by: Joel Stanley [Arnout: also source /etc/default file] Signed-off-by: Arnout Vandecappelle --- package/petitboot/S15pb-discover | 57 ++++++++++++++++++++++++++++++++ package/petitboot/petitboot.mk | 4 +++ 2 files changed, 61 insertions(+) create mode 100644 package/petitboot/S15pb-discover diff --git a/package/petitboot/S15pb-discover b/package/petitboot/S15pb-discover new file mode 100644 index 0000000000..7ecc12e991 --- /dev/null +++ b/package/petitboot/S15pb-discover @@ -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 diff --git a/package/petitboot/petitboot.mk b/package/petitboot/petitboot.mk index a798e7ca61..4d56b73938 100644 --- a/package/petitboot/petitboot.mk +++ b/package/petitboot/petitboot.mk @@ -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