wget: 2 tries (default: 20), timout 5 seconds (deault: 900)
authorgregor herrmann <gregoa@debian.org>
Tue, 9 Aug 2016 14:37:32 +0000 (16:37 +0200)
committergregor herrmann <gregoa@debian.org>
Tue, 9 Aug 2016 14:37:32 +0000 (16:37 +0200)
and factor out into variable

bin/client/tdyndns_client

index 9af5af8acb64daf71d5cb04899cbec0053359149..8fe810a115cfb9d7e05b40eacc43be4845e0f5ce 100755 (executable)
@@ -33,6 +33,7 @@ ZONE=dyn.example.com
 FQDN=$HOSTNAME.$USERNAME.$ZONE
 NS=ns.example.com
 URL="http://dyndns.example.com/nic/update?hostname=$FQDN&myip="
+WGET="wget -q --tries=2 --timeout=5"
 
 if [ -z "$HOSTNAME" ] ; then
        die "No hostname found."
@@ -41,8 +42,8 @@ fi
 # data
 
 # alternative: -4 icanhazip.com, -6 icanhazip.com or ipv{4,6}.icanhazip.com
-NEWIPV4=$(wget -q -O- http://ipv4.wtfismyip.com/text)
-NEWIPV6=$(wget -q -O- http://ipv6.wtfismyip.com/text)
+NEWIPV4=$($WGET -O- http://ipv4.wtfismyip.com/text)
+NEWIPV6=$($WGET -O- http://ipv6.wtfismyip.com/text)
 
 if command -v dig >/dev/null ; then
        OLDIPV4=$(dig -t a    +short $FQDN @$NS)
@@ -55,24 +56,24 @@ OLDIPV6=${OLDIPV6:-""}
 
 # old ipv4 gone
 if [ -n "$OLDIPV4" -a -z "$NEWIPV4" ] ; then
-       $DOIT wget -q -O/dev/null --user=$USERNAME --password=$PASSWORD "${URL}${OLDIPV4}&offline=yes"
+       $DOIT $WGET -O/dev/null --user=$USERNAME --password=$PASSWORD "${URL}${OLDIPV4}&offline=yes"
        $DOIT logger -t${0##*/} -perr -- "removing $FQDN / $OLDIPV4"
 fi
 
 # old ipv6 gone
 if [ -n "$OLDIPV6" -a -z "$NEWIPV6" ] ; then
-       $DOIT wget -q -O/dev/null --user=$USERNAME --password=$PASSWORD "${URL}${OLDIPV6}&offline=yes"
+       $DOIT $WGET -O/dev/null --user=$USERNAME --password=$PASSWORD "${URL}${OLDIPV6}&offline=yes"
        $DOIT logger -t${0##*/} -perr -- "removing $FQDN / $OLDIPV6"
 fi
 
 # new ipv4
 if [ -n "$NEWIPV4" -a "$NEWIPV4" != "$OLDIPV4" ] ; then
-       $DOIT wget -q -O/dev/null --user=$USERNAME --password=$PASSWORD "${URL}${NEWIPV4}"
+       $DOIT $WGET -O/dev/null --user=$USERNAME --password=$PASSWORD "${URL}${NEWIPV4}"
        $DOIT logger -t${0##*/} -perr -- "updating $FQDN to $NEWIPV4"
 fi
 
-# new ipv6
+# newipv6
 if [ -n "$NEWIPV6" -a "$NEWIPV6" != "$OLDIPV6" ] ; then
-       $DOIT wget -q -O/dev/null --user=$USERNAME --password=$PASSWORD "${URL}${NEWIPV6}"
+       $DOIT $WGET -O/dev/null --user=$USERNAME --password=$PASSWORD "${URL}${NEWIPV6}"
        $DOIT logger -t${0##*/} -perr -- "updating $FQDN to $NEWIPV6"
 fi