Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: cf1f06a401
Fetching contributors…

Cannot retrieve contributors at this time

executable file 83 lines (71 sloc) 2.456 kb
#!/bin/sh
# $Id$
LIST=${HOME}/.ianawhois-list
ENCODING=UTF-8
MAINTAINER=Stephane.Bortzmeyer@nic.fr
ROOTNAMESERVER=F
date=`date +%Y-%m-%d`
PREVIOUS_TLDS=$(ls [A-Z][A-Z0-9\-]*)
PATH=${HOME}/bin:${PATH}
LOG=/tmp/get-whois.$$.log
DIFF=/tmp/get-whois.$$.diff
TLDFILE=/tmp/get-whois.$$.tlds
trap "rm -f $LOG $DIFF $TLDFILE; exit 1" 1 2 3 15
trap "rm -f $LOG $DIFF $TLDFILE" EXIT
if [ ! -e $LIST ]; then
sendemail.py -t $MAINTAINER -f $MAINTAINER -s "Cannot find $LIST" < /dev/null
fi
(dig @${ROOTNAMESERVER}.root-servers.net AXFR . | awk -F. '/^[A-Za-z][A-Za-z0-9-]+\.\t.*NS/ {print toupper($1)}' | sort | uniq > $TLDFILE) 2> $LOG
# dig does not set a proper return code
if [ ! -z "$(cat $LOG)" ]; then
sendemail.py -t $MAINTAINER -f $MAINTAINER -s "Cannot retrieve the list of TLDs" < $LOG
exit 1
fi
TLDS=$(cat $TLDFILE)
if [ -z "$TLDS" ]; then
sendemail.py -t $MAINTAINER -f $MAINTAINER -s "List of TLDs is empty" < $LOG
exit 1
fi
svn update -q
for tld in $PREVIOUS_TLDS; do
if ! grep "^$tld" $TLDFILE > /dev/null; then
./iana-twitter.py $tld "deleted TLD \$tld"
svn delete $tld > $LOG 2>&1
svn commit -m "Last version ($date)" $tld >> $LOG 2>&1
fi
done
for tld in $TLDS; do
new=0
if [ ! -e $tld ]; then # New Top Level Domain
touch $tld
# TODO: add a text to explain that, since IANA database is
# always *behind* the actual root, we may not have info. yet?
svn add $tld > $LOG 2>&1
new=1
fi
whois -h whois.iana.org $tld > $tld 2> $LOG
if [ $? != 0 ]; then
sendemail.py -t $MAINTAINER -f $MAINTAINER -s "Cannot retrieve IANA whois" < $LOG
exit 1
fi
if [ -z "`cat $tld`" ]; then
# Disk full or some other problem
svn revert $tld >> $LOG 2>&1
sendemail.py -t $MAINTAINER -f $MAINTAINER -s "Cannot retrieve or store IANA whois: empty file" < $LOG
sleep 300
continue
fi
if [ $new == 0 ]; then
svn diff $tld > $DIFF 2>&1
if [ -s $DIFF ]; then
sendemail.py -t $(cat $LIST) -f $MAINTAINER -e $ENCODING -h "X-IANA-monitoring: whois" -s "IANA whois update for $tld" < $DIFF
svn commit -m "New copy of $date" $tld > $LOG 2>&1
./iana-twitter.py $tld "update for \$tld"
fi
else
sendemail.py -t $(cat $LIST) -f $MAINTAINER -e $ENCODING -h "X-IANA-monitoring: whois" -s "New TLD in IANA whois: $tld" < $tld
svn commit -m "First version ($date)" $tld > $LOG 2>&1
./iana-twitter.py $tld "new TLD \$tld"
fi
sleep 300
done
Jump to Line
Something went wrong with that request. Please try again.