Script to check ddns service is running and if not start it

Hi, I have TP-Link Archer C6U, ver.1 with OpenWrt 21.02. Ive installed ddns and when I start it manually it is running normally, but when the router reboots ddns service doesnt start automatically. Ive executed /etc/init.d/ddns enable many times, but ddns service doesnt start after reboot.
So I need help to write a shell script, which can check if ddns service is running and if not start it. I intend to put this script in cron and run the script every 3 minutes.
I wrote a short script, but it doesn`t seem to work:

#!/bin/sh /etc/rc.common
 cat << "EOF" > /usr/lib/ddns/dynamic_dns_updater.sh
if ! pgrep ddns
then /etc/init.d/ddns reload
fi
EOF

Thank you for your help!

Maybe the fact that DDNS is not running should be looked at, rather than working around it.

3 Likes

It is running, when started manually, but it doesnt autostart after reboot.

May be a race condition.

SSH in and run the following -

service list | grep ddns

ls -1 /etc/rc.d

Post the results in preformatted text.

1 Like

Reboot the router, then have a look at the logs, to see why it failed to start.

2 Likes

While trying to fix the problem, router got lazy, i.e. 1 min. after login to Luci the router started to lose connection and luci and ssh got unreachable. I couldn`t fix this, so I reset the router to default, then I started installing everything on the router again, i.e. dddns, mwan3, oscam, etc. and this time ddns autostart worked as it should work.

So maybe it was some kind of bad installation last time.

10x

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.