Add update_script option to specify a custom script which is used to update the
dns. The script takes 2 arguments:
        first is the domain to be updated
        second is the actual ip address

here is an example script which use nsupdate to update bind directly:

        #!/bin/sh

        domain=`echo "$1" | sed s/\\\\.\\\\?$/./`
        zone=`echo "$domain" | sed s/^[^.]*\\\\.//`
        ip=$2

        nsupdate -k /etc/ddns.key <<NSSCRIPT
        zone $zone
        update del $domain
        update add $domain 600  IN A $ip
        send
        NSSCRIPT

Signed-off-by: Zang MingJie <zealot0...@gmail.com>
---
 .../files/usr/lib/ddns/dynamic_dns_updater.sh      | 45 ++++++++++++----------
 1 file changed, 25 insertions(+), 20 deletions(-)

diff --git a/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh 
b/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh
index e6d2987..d2e8ffc 100755
--- a/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh
+++ b/net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_updater.sh
@@ -298,26 +298,31 @@ do
        then
                verbose_echo "update necessary, performing update ..."
 
-               #do replacement
-               final_url=$update_url
-               for option_var in $ALL_OPTION_VARIABLES
-               do
-                       if [ "$option_var" != "update_url" ]
-                       then
-                               replace_name=$(echo "\[$option_var\]" | tr 
'a-z' 'A-Z')
-                               replace_value=$(eval echo "\$$option_var")
-                               replace_value=$(echo $replace_value | sed -f 
/usr/lib/ddns/url_escape.sed)
-                               final_url=$(echo $final_url | sed 
s^"$replace_name"^"$replace_value"^g )
-                       fi
-               done
-               final_url=$(echo $final_url | sed 
s^"\[HTTPAUTH\]"^"${username//^/\\^}${password:+:${password//^/\\^}}"^g )
-               final_url=$(echo $final_url | sed s/"\[IP\]"/"$current_ip"/g )
-
-
-               verbose_echo "updating with url=\"$final_url\""
-
-               #here we actually connect, and perform the update
-               update_output=$( $retrieve_prog "$final_url" )
+               if [ -n $update_script ]
+               then
+                       update_output=$( $update_script "$domain" "$current_ip" 
)
+               else
+                       #do replacement
+                       final_url=$update_url
+                       for option_var in $ALL_OPTION_VARIABLES
+                       do
+                               if [ "$option_var" != "update_url" ]
+                               then
+                                       replace_name=$(echo "\[$option_var\]" | 
tr 'a-z' 'A-Z')
+                                       replace_value=$(eval echo 
"\$$option_var")
+                                       replace_value=$(echo $replace_value | 
sed -f /usr/lib/ddns/url_escape.sed)
+                                       final_url=$(echo $final_url | sed 
s^"$replace_name"^"$replace_value"^g )
+                               fi
+                       done
+                       final_url=$(echo $final_url | sed 
s^"\[HTTPAUTH\]"^"${username//^/\\^}${password:+:${password//^/\\^}}"^g )
+                       final_url=$(echo $final_url | sed 
s/"\[IP\]"/"$current_ip"/g )
+
+
+                       verbose_echo "updating with url=\"$final_url\""
+
+                       #here we actually connect, and perform the update
+                       update_output=$( $retrieve_prog "$final_url" )
+               fi
                if [ $? -gt 0 ]
                then
                        syslog_echo "update failed, retrying in 
$retry_interval_seconds seconds"
-- 
1.8.3.4 (Apple Git-47)
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to