[ddns-gargoyle] update 25-ddns hotplug script

Discuss the technical details of Gargoyle and ongoing development

Moderator: Moderators

Post Reply
User avatar
braveheartleo
Posts: 47
Joined: Sun Dec 13, 2009 9:50 am

[ddns-gargoyle] update 25-ddns hotplug script

Post by braveheartleo »

Hi,

I wish to propose an update to the hotplug script that works on both the default Gargoyle setup (uclibc), and my custom OpenWRT trunk dual-WAN setup (musl).

The problem with the default script under my custom compile is that whenever the hotplug system reaches 25-ddns, it suspends the execution of other scripts, because the hotplug is waiting for /usr/bin/ddns_gargoyle -P /etc/ddns_providers.conf -C /etc/ddns_gargoyle.conf to finish, which seemed to hang. Killing the process resumes hotplug execution of other scripts.

I haven't done any deeper look into what might be the cause for the hang (could be some musl libc thing), but I found that I could improve the hotplug script as follows:

Code: Select all

#!/bin/sh

[ "$ACTION" = "ifup" ] && /etc/init.d/ddns_gargoyle enabled || exit 0

[ "$INTERFACE" = "wan" ] && [ -f /var/run/ddns_updaterd.pid ] && /usr/bin/ddns_gargoyle
The default script DOES NOT respect disabling the service via /etc/init.d/ddns_gargoyle disable, thus ddns_gargoyle still process ddns updates whenever a hotplug event is triggered for it.

qos-scripts, ddns-scripts, sqm-scripts, miniupnpd, and privoxy, to name a few, understand this and have checks in their hotplug scripts to not start a service if said service is disabled.

If you will notice ddns_gargoyle --help:

Code: Select all

USAGE: ddns_gargoyle [OPTIONS] [SERVICE NAMES]
	-C [SERVICE_CONFIG_FILE] specifies location of file containing configuration information
	-P [SERVICE_PROVIDER_FILE] specifies location of file containing service provider definitions
	-d start daemon mode
	-f forces update for standalone or when daemon first starts -- default is just to check and update if necessary
	-h for non-daemon mode display output in human readable format
	-m for non-daemon mode display output in simple machine parsable format: a list of numbers, one for each service
		where 0=failure to update, 1= update not needed, 2=success
	-u print usage and exit
Based on actual testing, it is NOT NECESSARY to supply the service files when calling ddns_gargoyle from the hotplug script. Perhaps this might be what's hanging ddns_garogyle, compiled against musl, when called from the hotplug script.

Just calling the binary WITHOUT any further parameters is sufficient, as it communicates with the already running daemon, which is started with the appropriate -C and -P service files parameters, and it instructs the daemon to either check or force an update depending upon whether -f is passed to it.

I added an additional check in the hotplug script to make sure that the daemon is running before calling ddns_gargoyle, for good measure.

Like I said, this works in Gargoyle and OpenWRT trunk, no matter if having multi-WAN or not. Also, ddns_gargoyle compiles successfully using musl libc.

I'm sharing my changes, hoping that it benefits the community and improves Gargoyle in general. ;)

ispyisail
Moderator
Posts: 5185
Joined: Mon Apr 06, 2009 3:15 am
Location: New Zealand

Re: [ddns-gargoyle] update 25-ddns hotplug script

Post by ispyisail »

Thanks

User avatar
braveheartleo
Posts: 47
Joined: Sun Dec 13, 2009 9:50 am

Re: [ddns-gargoyle] update 25-ddns hotplug script

Post by braveheartleo »

You're welcome, and thank you for looking into this. :-D

Post Reply