Created
March 29, 2023 05:54
-
-
Save 0x5e/13508ac931c1ad0329066e13c50b265d to your computer and use it in GitHub Desktop.
OpenWrt DDNS service watchdog. Auto restart service when it exited unexpectedly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Run this script from cron every 10 minutes: | |
# echo '*/10 * * * * /path/to/ddns_watchdog.sh' >> /etc/crontabs/root | |
. /lib/functions.sh | |
handle_ddns_service() { | |
local cfg="$1" | |
local enabled | |
config_get enabled "${cfg}" enabled | |
[ $enabled != "1" ] && return 0; | |
pid=`cat /tmp/run/ddns/$cfg.pid` | |
[ -n "$(ps | awk '{print $1}' | grep $pid)" ] && return 0; | |
logger -t "ddns_monitor" "service $cfg not running. launching..." | |
/bin/sh /usr/lib/ddns/dynamic_dns_updater.sh -v 0 -S $cfg -- start & | |
} | |
config_load ddns | |
config_foreach handle_ddns_service service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment