Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

naywatch: fix procd handling #729

Merged
merged 1 commit into from Oct 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 26 additions & 2 deletions 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
Expand Down Expand Up @@ -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
}