]> git.wh0rd.org Git - home.git/commitdiff
add helper script for nsupdate
authorMike Frysinger <vapier@gentoo.org>
Thu, 30 Jun 2011 20:54:28 +0000 (16:54 -0400)
committerMike Frysinger <vapier@gentoo.org>
Sat, 28 Apr 2012 19:36:38 +0000 (15:36 -0400)
.bin/donsupdate [new file with mode: 0755]

diff --git a/.bin/donsupdate b/.bin/donsupdate
new file mode 100755 (executable)
index 0000000..ae7c176
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+[ "$1" = "-u" ] && UPDATE=true || UPDATE=false
+
+IP=`ip a s dev eth0 | sed -n '/inet 10\./s:.*inet \([^/ ]*\).*:\1:p'`
+
+doit() {
+       HOST=$1
+       DOMAIN="ad.analog.com"
+       FQDN="$HOST.$DOMAIN"
+
+       if ${UPDATE} ; then
+               currip=$(dig +short $FQDN)
+               [ "${currip}" = "${IP}" ] && return 0
+       fi
+
+       cat <<-EOF | nsupdate
+       server 10.64.53.110
+       update delete $FQDN A
+       update add $FQDN 86400 A $IP
+       send
+       EOF
+}
+
+doit vapier-adi
+doit vapier