-#!/bin/csh -f
+#!/bin/csh -f -x
# This script performs updates of hesiod files on hesiod servers.
+# $Source$
+echo '$Header$'
# The following exit codes are defined and MUST BE CONSISTENT with the
# SMS error codes the library uses:
set SMS_NAMED = 47836475
set SMS_TARERR = 47836476
+umask 22
+
# File that will contain the necessary information to be updated
set TARFILE=/tmp/hesiod.out
# Directory into which we will empty the tarfile
set SRC_DIR=/etc/athena/_nameserver
# Directory into which we will put the final product
set DEST_DIR=/etc/athena/nameserver
+# Files to verify nameserver loaded
+set CHECKFILES="passwd.db pobox.db cluster.db grplist.db group.db"
# Create the destination directory if it doesn't exist
if (! -d $DEST_DIR) then
/bin/chmod 755 $DEST_DIR
endif
-# There is reason for $SRC_DIR and $DEST_DIR to be on the same disk
-# parition, so find out where $DEST_DIR is and put $SRC_DIR there too.
-set old = $cwd
-chdir $DEST_DIR
-# Don't use $cwd; it won't follow the link
-set CUR_DIR = `pwd`
-set SRC_DIR_TMP = $CUR_DIR:h/_nameserver
-if (! -d $SRC_DIR_TMP) then
- /bin/rm -f $SRC_DIR_TMP
- /bin/mkdir $SRC_DIR_TMP
- /bin/chmod 755 $SRC_DIR_TMP
+# If $SRC_DIR does not already exist, make sure that it gets created
+# on the same parition as $DEST_DIR.
+if (! -d $SRC_DIR) then
+ chdir $DEST_DIR
+ mkdir ../_nameserver
+ chdir ../_nameserver
+ if ($SRC_DIR != `pwd`) ln -s `pwd` $SRC_DIR
endif
-if ($SRC_DIR_TMP != $SRC_DIR) ln -s $SRC_DIR_TMP $SRC_DIR
-cd $old
-unset old SRC_DIR_TMP
# Alert if tarfile doesn't exist
if (! -r $TARFILE) exit $SMS_MISSINGFILE
# Restart named.
(unlimit; /etc/named)
-# Before trying to reimpliment this timeout mechanism using interrupts,
-# be sure to check and make sure that it will work on both types of
-# machines. As of 6.0B, RT csh didn't respond correctly to onintr.
-#
# This timeout is implemented by having the shell check TIMEOUT times
# for the existance of /etc/named.pid and to sleep INTERVAL seconds
# between each check.
# Did it time out?
if ($i == $TIMEOUT) exit $SMS_NAMED
+# Verify that the nameserver is answering queries for the new data
+cd $DEST_DIR
+foreach f ( $CHECKFILES )
+ set temp=`tac $f | egrep -v '^;' | head -1`
+ set hes=`/bin/echo $temp | awk '{print $1}'`
+ set ent=`echo $hes | rev | sed 's/\(.*\)\.\(.*\)/\2/' | rev`
+ set type=`echo $hes | rev | sed 's/\(.*\)\.\(.*\)/\1/' | rev`
+ hesinfo $ent $type > /dev/null
+ if ($status == 1) then
+ exit $SMS_HESFILE
+ endif
+end
+
# Clean up!
/bin/rm -f $TARFILE
/bin/rm -f $0
exit 0
-
-#
-# $Source$
-# $Header$
-#