Fixed variable check and dns error handling in nsupdate script.

This commit is contained in:
Ossi Salmi 2010-03-23 13:46:24 +02:00 committed by Timo Mkinen
parent b254170d62
commit f5bd639187

View file

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
DNSSERVER="<%= dns_nsupdate_server -%>" DNSSERVER="<%= dns_nsupdate_server -%>"
DNSZONE="<% if defined?(dns_nsupdate_zone) -%><%= dns_nsupdate_zone -%><% end %>" DNSZONE="<% if has_variable?("dns_nsupdate_zone") -%><%= dns_nsupdate_zone -%><% end %>"
MYNAME="<%= dns_nsupdate_name -%>" MYNAME="<%= dns_nsupdate_name -%>"
MYKEY="<%= dns_nsupdate_key -%>" MYKEY="<%= dns_nsupdate_key -%>"
@ -24,7 +24,7 @@ esac
# try to get current addr/name from dns # try to get current addr/name from dns
CURADDR=`dig +noall +answer @${DNSSERVER} ${MYNAME} A | awk '{ print $5 }'` CURADDR=`dig +short @${DNSSERVER} ${MYNAME} A 2>/dev/null`
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
# we should get this only in dns errors so exit quietly # we should get this only in dns errors so exit quietly
exit 1 exit 1
@ -32,7 +32,7 @@ fi
# exit now if we are up to date # exit now if we are up to date
if [ ${CURADDR} = ${MYADDR} ]; then if [ "${CURADDR}" = "${MYADDR}" ]; then
exit 0 exit 0
fi fi