#!/bin/csh -x set tmpl="host-mod.tmpl" set ons="who\..*" set nns="whine.osd.bsdi.com" set nnsip=`host -t a $nns | sed "s/$nns has address \(.*\)/\1/"` set ct="Individual" set tmp="/tmp" # FIXME: get from env foreach dom ($*) echo "===> $dom" echo "=> Finding old nameserver..." set tfn="`mktemp $tmp/XXXXXX.whois`" whois $dom > $tfn echo $tfn set ns=`egrep -i "^ $ons" < $tfn | awk '{print $1;}'` set email=`awk 'BEGIN {cf=0;} $1 ~ /^(Administrative|Technical)$/ $2 == "Contact," {cf=1;} $0 ~ /^[ \t]+.*, .* (.*) .*@.*$/ {if (cf) {print "Found"; exit;}}' < $tfn` set ch=`sed -e 's/^ .*, .* (\(.*\)) .*@.*$/\1/' < $tfn` rm $tfn if ("$ns" == "") then echo "Cannot find old name server entry for $dom." exit 1 endif if ("$email" == "") then echo "Cannot find email address in whois info." exit 1 endif if ("$ch" == "") then echo "Cannot get contact handle from whois info." exit 1 endif echo "$dom has an outdated NS record for $ns." echo "=> Getting host handle for $ns..." set hh=`whois -i "host $ns" | grep -i '^\[.*\] \(.*-HST\)' | sed -e 's/^\[.*\] (\(.*-HST\))$/\1/'` echo "$ns has NSI host handle $hh." set fn="mod-$dom.form" echo "=> Writing $fn." sed -e "s/%EMAIL%/$email/" -e "s/%NNS%/$nns/" \ -e "s/%NNSIP%/$nnsip/" -e "s/%HH%/$hh/" \ -e "s/%CH%/$ch/" -e "s/%CT%/$ct/" < $tmpl > $fn end