mirror of https://github.com/OpenIPC/firmware.git
66 lines
1.0 KiB
Bash
Executable File
66 lines
1.0 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
DAEMON="watchdog"
|
|
|
|
WATCHDOG_ENABLED=false
|
|
WATCHDOG_TIMEOUT=60
|
|
|
|
SUPPORTED_VENDORS="ingenic"
|
|
WATCHDOG_ARGS="-T $WATCHDOG_TIMEOUT /dev/watchdog"
|
|
WATCHDOG_VENDOR=$(ipcinfo -v)
|
|
|
|
vendor_supported() {
|
|
for vendor in $SUPPORTED_VENDORS; do
|
|
[ "$WATCHDOG_VENDOR" = "$vendor" ] && return 0
|
|
done
|
|
return 1
|
|
}
|
|
|
|
start()
|
|
{
|
|
if [ "$(cli -g .watchdog.enabled)" = "true" ]; then
|
|
printf "Starting ${DAEMON}: "
|
|
echo "majestic watchdog enabled"
|
|
exit 0
|
|
fi
|
|
|
|
if vendor_supported && [ "$WATCHDOG_ENABLED" = "true" ]; then
|
|
printf "Starting ${DAEMON}: "
|
|
start-stop-daemon -b -S -q -x "/sbin/${DAEMON}" -- ${WATCHDOG_ARGS}
|
|
if [ $? = 0 ]; then
|
|
echo "OK"
|
|
else
|
|
echo "FAIL"
|
|
fi
|
|
else
|
|
echo "Watchdog: System 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
|