[no ci] overlay-files: add watchdog option to init.d (#1191)

pull/1194/head
gtxaspec 2023-12-10 14:01:28 -08:00 committed by GitHub
parent 278c93d3d7
commit 63a3d15ab1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,54 @@
#!/bin/sh
DAEMON="watchdog"
WATCHDOG_VENDOR=$(ipcinfo -v)
WATCHDOG_ENABLED=false
WATCHDOG_TIMEOUT=60
WATCHDOG_ARGS="-T $WATCHDOG_TIMEOUT /dev/watchdog"
SUPPORTED_VENDORS="ingenic"
vendor_supported() {
for vendor in $SUPPORTED_VENDORS; do
[ "$WATCHDOG_VENDOR" = "$vendor" ] && return 0
done
return 1
}
start()
{
if vendor_supported && [ "$(cli -g .watchdog.enabled)" = "false" ] && [ "$WATCHDOG_ENABLED" = "true" ]; then
printf "Starting ${DAEMON}: "
start-stop-daemon -S -q -x "/sbin/${DAEMON}" -- ${WATCHDOG_ARGS}
[ $? = 0 ] && echo "OK" || echo "FAIL"
else
echo "Watchdog: Unsupported vendor or Majestic Watchdog is enabled/standalone watchdog disabled"
exit 0
fi
}
stop()
{
printf "Stopping ${DAEMON}: "
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