From e9deec75a96964586f137565f352d27ed0070fb3 Mon Sep 17 00:00:00 2001 From: gtxaspec Date: Sun, 10 Dec 2023 00:58:54 -0800 Subject: [PATCH] [no ci] overlay-files: add watchdog option to init.d --- general/overlay/etc/init.d/S99watchdog | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 general/overlay/etc/init.d/S99watchdog diff --git a/general/overlay/etc/init.d/S99watchdog b/general/overlay/etc/init.d/S99watchdog new file mode 100755 index 00000000..b89eceb8 --- /dev/null +++ b/general/overlay/etc/init.d/S99watchdog @@ -0,0 +1,42 @@ +#!/bin/sh + +DAEMON="watchdog" + +WATCHDOG_ENABLED=false +WATCHDOG_TIMEOUT=60 +WATCHDOG_ARGS="-T $WATCHDOG_TIMEOUT /dev/watchdog" + +start() +{ + [ "$(cli -g .watchdog.enabled)" = "false" ] && [ "$WATCHDOG_ENABLED" = "true" ] || { echo "Watchdog: Majestic Watchdog is enabled or standalone watchdog disabled"; exit 0; } + + printf "Starting ${NAME}: " + start-stop-daemon -S -q -x "/sbin/${DAEMON}" -- ${WATCHDOG_ARGS} + [ $? = 0 ] && echo "OK" || echo "FAIL" +} + +stop() +{ + printf "Stopping ${NAME}: " + if start-stop-daemon -K -q -s KILL -n "${DAEMON}"; then + echo "OK" + else + echo "FAIL" + fi +} + +case "$1" in + start|stop) + "$1" + ;; + + restart|reload) + stop + start + ;; + + *) + echo "Usage: $0 {start|stop|restart|reload}" >&2 + exit 1 + ;; +esac