The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,224 other subscribers

Getting a fresh root hint file on SUSE 12.x

Posted by jpluimers on 2013/07/31

Wrote a small script that goes into my monthly crontab.

It gets ftp://ftp.internic.net/domain/named.cache into /var/lib/named/named.cache.new, and logs when you need to copy it over into /var/lib/named/root.hint

#! /bin/sh
#

RootHint=root.hint
NamedCache=named.cache
NamedCacheDownloadPath=ftp.internic.net/domain/$NamedCache
FtpNamedCacheDownloadPath=ftp://$NamedCacheDownloadPath
VarLibNamed=/var/lib/named/
VarLibNamedNamedCache=$VarLibNamed$NamedCache
VarLibNamedRootHint=$VarLibNamed$RootHint
VarLibNamedNamedCacheNew=$VarLibNamed$NamedCache.new

#echo "$RootHint"
#echo "$NamedCacheDownloadPath"
#echo "ftp://ftp.internic.net/domain"
#echo "$FtpNamedCacheDownloadPath"
#echo "$VarLibNamedNamedCache"
#echo "$VarLibNamedNamedCacheNew"

cd $VarLibNamed
wget -q -N ftp://$NamedCacheDownloadPath

if (test -e $VarLibNamedNamedCache) ; then

  diff $VarLibNamedNamedCache $VarLibNamedNamedCacheNew

  if [ "$?" -ne "0" ] ; then
  # if $VarLibNamedNamedCacheNew does not exist, or $VarLibNamedNamedCache is different from $VarLibNamedNamedCacheNew

    cp -f $VarLibNamedNamedCache $VarLibNamedNamedCacheNew
    echo "There is a fresh $VarLibNamedNamedCacheNew file that you might want to update into $VarLibNamedRootHint"
  fi

  diff $VarLibNamedRootHint $VarLibNamedNamedCacheNew

  if [ "$?" -ne "0" ] ; then
  # if $VarLibNamedNamedCacheNew does not exist, or $VarLibNamedRootHint is different from $VarLibNamedNamedCacheNew

#    rcnamed restart
    echo "$VarLibNamedRootHint is different from $VarLibNamedNamedCacheNew, you might need to update $VarLibNamedRootHint, then perform rcnamed restart "
  fi

  rm -f $VarLibNamedNamedCache
fi

–jeroen

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: