#!/bin/sh # # updates felnet.de Host Record in BIND via nsupdate (dynamic DNS) # ## variables - please set TMPDIR=/tmp/zoneupdate_$1 ZONEFILES=/jail/named/etc/bind/*-template ## prepare temporary directory /bin/mkdir ${TMPDIR} /bin/chmod 700 ${TMPDIR} ## construct instructions for nsupdate for i in `ls -1 ${ZONEFILES}`; do { ZONEFILE=$i DOMAIN=`echo ${ZONEFILE} | sed -e "s/.*\///g" | sed -e "s/-template//g"` cat ${ZONEFILE} | grep dynamic | sed -e "s/[^A-Za-z@].*//g" > ${TMPDIR}/hostnames.txt for i in `cat ${TMPDIR}/hostnames.txt`; do if [ ${i} == "@" ]; then i=""; else i="${i}." fi echo "update delete ${i}${DOMAIN} A" >> ${TMPDIR}/commands.txt echo >> ${TMPDIR}/commands.txt echo "update add ${i}${DOMAIN} 86400 A $1" >> ${TMPDIR}/commands.txt echo >> ${TMPDIR}/commands.txt done } done cat ${TMPDIR}/commands.txt ## now finally run our nsupdate /usr/local/bin/nsupdate ${TMPDIR}/commands.txt ## finished, unlink temporary directory /bin/rm -rf ${TMPDIR}