2 # This script performs updates of hesiod files on hesiod servers.
6 # The following exit codes are defined and MUST BE CONSISTENT with the
7 # SMS error codes the library uses:
8 set SMS_HESFILE = 47836472
9 set SMS_MISSINGFILE = 47836473
10 set SMS_NAMED = 47836475
11 set SMS_TARERR = 47836476
15 # File that will contain the necessary information to be updated
16 set TARFILE=/tmp/hesiod.out
17 # Directory into which we will empty the tarfile
18 set SRC_DIR=/etc/athena/_nameserver
19 # Directory into which we will put the final product
20 set DEST_DIR=/etc/athena/nameserver
21 # Files to verify nameserver loaded
22 set CHECKFILES="passwd.db pobox.db cluster.db grplist.db group.db"
24 # Create the destination directory if it doesn't exist
25 if (! -d $DEST_DIR) then
28 /bin/chmod 755 $DEST_DIR
31 # If $SRC_DIR does not already exist, make sure that it gets created
32 # on the same parition as $DEST_DIR.
33 if (! -d $SRC_DIR) then
37 if ($SRC_DIR != `pwd`) ln -s `pwd` $SRC_DIR
40 # Alert if tarfile doesn't exist
41 if (! -r $TARFILE) exit $SMS_MISSINGFILE
43 # Empty the tar file one file at a time and move each file to the
44 # appropriate place only if it is not zero length.
46 foreach file (`/bin/tar tf $TARFILE | awk '{print $1}' | sed 's;/$;;'`)
47 if (. == $file) continue
51 /bin/tar xf $TARFILE $file
52 # Don't put up with errors extracting the information
53 if ($status) exit $SMS_TARERR
54 # Make sure the file is not zero-length
56 /bin/mv -f $file $DEST_DIR
57 if ($status != 0) exit $SMS_HESFILE
64 # Kill off the current named and remove the named.pid file. It is
65 # important that this file be removed since the script uses its
66 # existance as evidence that named as has been successfully restarted.
68 # Use /bin/kill because, due to a bug in some versions of csh, failure
69 # of a builtin will cause the script to abort
70 /bin/kill -KILL `/bin/cat /etc/named.pid`
76 # This timeout is implemented by having the shell check TIMEOUT times
77 # for the existance of /etc/named.pid and to sleep INTERVAL seconds
80 set TIMEOUT=60 # number of INTERVALS until timeout
81 set INTERVAL=60 # number of seconds between checks
85 if (-f /etc/named.pid) break
90 if ($i == $TIMEOUT) exit $SMS_NAMED
92 # Verify that the nameserver is answering queries for the new data
94 foreach f ( $CHECKFILES )
95 set temp=`tac $f | egrep -v '^;' | head -1`
96 set hes=`/bin/echo $temp | awk '{print $1}'`
97 set ent=`echo $hes | rev | sed 's/\(.*\)\.\(.*\)/\2/' | rev`
98 set type=`echo $hes | rev | sed 's/\(.*\)\.\(.*\)/\1/' | rev`
99 hesinfo $ent $type > /dev/null
100 if ($status == 1) then