summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Hainke <vincent@systemli.org>2021-10-01 10:55:36 +0200
committerNick Hainke <vincent@systemli.org>2021-10-01 12:12:47 +0200
commitd8b445726723e90df7d8858787051f262ad3ba9e (patch)
tree41a735768c55033117885502219559b98f013fd1
parentc30b5d5df352e7040d15d9a891e04fd0e9daff33 (diff)
naywatch: fix procd handling
Sometimes, naywatch can not handover the watchdog to procd again using ubus. We need to call the same ubus command multiple times until procd takes over control again. Signed-off-by: Nick Hainke <vincent@systemli.org> (cherry picked from commit e35255710bda08f162a185be8c460b6a80e19fb1)
-rw-r--r--naywatch/files/naywatch.init28
1 files changed, 26 insertions, 2 deletions
diff --git a/naywatch/files/naywatch.init b/naywatch/files/naywatch.init
index ac39a99..82f53c6 100644
--- a/naywatch/files/naywatch.init
+++ b/naywatch/files/naywatch.init
@@ -1,5 +1,7 @@
#!/bin/sh /etc/rc.common
+. /usr/share/libubox/jshn.sh
+
USE_PROCD=1
START=95
STOP=01
@@ -58,8 +60,30 @@ stop_service() {
sync && wait
}
+watchdog_procd_runnig() {
+ watch=$(ubus call system watchdog)
+ json_load "$watch"
+ json_get_var watchdogstatus status
+ if [[ "$watchdogstatus" == "running" ]] ; then
+ echo "1"
+ return
+ fi
+ echo "0"
+}
+
service_stopped() {
log "Naywatch Stopped!"
- log "Handover Watchdog to procd again:"
- ubus call system watchdog '{"magicclose":true,"stop":false}' > /dev/null
+ log "Try to handover watchdog to procd again."
+ for i in 1 2 3 4 5 6 7 8 9 10 ; do
+ sleep 5
+ ubus call system watchdog '{"stop":false}' > /dev/null
+ if [[ $(watchdog_procd_runnig) == "1" ]] ; then
+ break
+ fi
+ done
+ if [[ $(watchdog_procd_runnig) == "1" ]] ; then
+ log "Handover sucessfully!"
+ else
+ log "Handover to procd failed! Device can reboot!"
+ fi
}