ddns-scripts: fix issue (#337) current/registered ip never match
authorChristian Schoenebeck <redacted>
Mon, 22 Sep 2014 14:32:56 +0000 (16:32 +0200)
committerChristian Schoenebeck <redacted>
Mon, 22 Sep 2014 14:32:56 +0000 (16:32 +0200)
new extraction of IP inside function get_registered_ip for host and nslookup
thanks to jow for the sed

Signed-off-by: Christian Schoenebeck <redacted>
net/ddns-scripts/files/usr/lib/ddns/dynamic_dns_functions.sh

index 057fe9258d765aec8e34f0be2f8488d258ea56d4..e643c7559840c7fd4323b91b6154d847d5f0e0ec 100644 (file)
@@ -672,7 +672,7 @@ get_registered_ip() {
                } || {
                        # we need to run twice because multi-line output needs to be directly piped to grep because
                        # pipe returns return code of last prog in pipe but we need errors from host command
-                       __IP=$(eval $__RUNPROG | grep "^$domain" | grep -m 1 -o "$__REGEX")
+                       __IP=$(eval $__RUNPROG | awk -F "address " '/has/ {print $2; exit}' )
                }
 
        elif [ -x /usr/bin/nslookup ]; then     # last use BusyBox nslookup
@@ -692,7 +692,7 @@ get_registered_ip() {
                } || {
                        # we need to run twice because multi-line output needs to be directly piped to grep because
                        # pipe returns return code of last prog in pipe but we need errors from nslookup command
-                       __IP=$(eval $__RUNPROG | sed '1,2d' | grep -o "Name:\|Address.*" | grep -m 1 -o "$__REGEX")
+                       __IP=$(eval $__RUNPROG | sed -ne "3,\$ { s/^Address [0-9]*: \($__REGEX\).*$/\\1/p }" )
                }
 
        else                                    # there must be an error
git clone https://git.99rst.org/PROJECT