-#!/bin/csh -f -x
+#!/bin/csh -f
# This script performs updates of hesiod files on hesiod servers.
-# $Source$
-echo '$Header$'
+# $Header$
+
+set path=(/etc /bin /usr/bin /usr/etc /usr/athena/etc)
# The following exit codes are defined and MUST BE CONSISTENT with the
-# SMS error codes the library uses:
-set SMS_HESFILE = 47836472
-set SMS_MISSINGFILE = 47836473
-set SMS_NAMED = 47836475
-set SMS_TARERR = 47836476
+# MR error codes the library uses:
+set MR_HESFILE = 47836472
+set MR_MISSINGFILE = 47836473
+set MR_NAMED = 47836475
+set MR_TARERR = 47836476
umask 22
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-if empty, no check is done
-set CHECKFILES=""
# Create the destination directory if it doesn't exist
if (! -d $DEST_DIR) then
- /bin/rm -f $DEST_DIR
- /bin/mkdir $DEST_DIR
- /bin/chmod 755 $DEST_DIR
+ rm -f $DEST_DIR
+ mkdir $DEST_DIR
+ chmod 755 $DEST_DIR
endif
# If $SRC_DIR does not already exist, make sure that it gets created
chdir $DEST_DIR
mkdir ../_nameserver
chdir ../_nameserver
- if ($SRC_DIR != `pwd`) ln -s `pwd` $SRC_DIR
+ if ($SRC_DIR != `pwd`) then
+ ln -s `pwd` $SRC_DIR
+ endif
endif
# Alert if tarfile doesn't exist
-if (! -r $TARFILE) exit $SMS_MISSINGFILE
+if (! -r $TARFILE) exit $MR_MISSINGFILE
# Empty the tar file one file at a time and move each file to the
# appropriate place only if it is not zero length.
cd $SRC_DIR
-foreach file (`/bin/tar tf $TARFILE | awk '{print $1}' | sed 's;/$;;'`)
+foreach file (`tar tf $TARFILE | awk '{print $1}' | sed 's;/$;;'`)
if (. == $file) continue
rm -rf $file
echo extracting $file
- /bin/tar xf $TARFILE $file
+ tar xf $TARFILE $file
# Don't put up with errors extracting the information
- if ($status) exit $SMS_TARERR
+ if ($status) exit $MR_TARERR
# Make sure the file is not zero-length
if (! -z $file) then
- /bin/mv -f $file $DEST_DIR
- if ($status != 0) exit $SMS_HESFILE
+ mv -f $file $DEST_DIR
+ if ($status != 0) exit $MR_HESFILE
else
- /bin/rm -f $file
- exit $SMS_MISSINGFILE
+ rm -f $file
+ exit $MR_MISSINGFILE
endif
end
# important that this file be removed since the script uses its
# existance as evidence that named as has been successfully restarted.
+# First, get statistics
+ln -s /site/named.stats /usr/tmp/named.stats
+kill -IOT `cat /etc/named.pid`
+sleep 1
# Use /bin/kill because, due to a bug in some versions of csh, failure
# of a builtin will cause the script to abort
-/bin/kill -KILL `/bin/cat /etc/named.pid`
+kill -KILL `cat /etc/named.pid`
rm -f /etc/named.pid
# Restart named.
-(unlimit; /etc/named)
+(unlimit; /etc/named&)
+sleep 5
+mv /etc/named.pid /etc/named.pid.restart
# This timeout is implemented by having the shell check TIMEOUT times
# for the existance of /etc/named.pid and to sleep INTERVAL seconds
end
# 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
+if ($i == $TIMEOUT) exit $MR_NAMED
# Clean up!
-/bin/rm -f $TARFILE
-/bin/rm -f $0
+rm -f $TARFILE
+rm -f $0
exit 0