2 # This script performs updates of hesiod files on hesiod servers.
4 # The following exit codes are defined and MUST BE CONSISTENT with the
5 # SMS error codes the library uses:
6 set SMS_HESFILE = 47836472
7 set SMS_MISSINGFILE = 47836473
8 set SMS_NAMED = 47836475
9 set SMS_TARERR = 47836476
11 # File that will contain the necessary information to be updated
12 set TARFILE=/tmp/hesiod.out
13 # Directory into which we will empty the tarfile
14 set SRC_DIR=/etc/athena/_nameserver
15 # Directory into which we will put the final product
16 set DEST_DIR=/etc/athena/nameserver
18 # Create the destination directory if it doesn't exist
19 if (! -d $DEST_DIR) then
22 /bin/chmod 755 $DEST_DIR
25 # There is reason for $SRC_DIR and $DEST_DIR to be on the same disk
26 # parition, so find out where $DEST_DIR is and put $SRC_DIR there too.
29 # Don't use $cwd; it won't follow the link
31 set SRC_DIR_TMP = $CUR_DIR:h/_nameserver
32 if (! -d $SRC_DIR_TMP) then
33 /bin/rm -f $SRC_DIR_TMP
34 /bin/mkdir $SRC_DIR_TMP
35 /bin/chmod 755 $SRC_DIR_TMP
37 if ($SRC_DIR_TMP != $SRC_DIR) ln -s $SRC_DIR_TMP $SRC_DIR
41 # Alert if tarfile doesn't exist
42 if (! -r $TARFILE) exit $SMS_MISSINGFILE
44 # Empty the tar file one file at a time and move each file to the
45 # appropriate place only if it is not zero length.
47 foreach file (`/bin/tar tf $TARFILE | awk '{print $1}' | sed 's;/$;;'`)
48 if (. == $file) continue
52 /bin/tar xf $TARFILE $file
53 # Don't put up with errors extracting the information
54 if ($status) exit $SMS_TARERR
55 # Make sure the file is not zero-length
57 /bin/mv -f $file $DEST_DIR
58 if ($status != 0) exit $SMS_HESFILE
65 # Kill off the current named and remove the named.pid file. It is
66 # important that this file be removed since the script uses its
67 # existance as evidence that named as has been successfully restarted.
69 # Use /bin/kill because, due to a bug in some versions of csh, failure
70 # of a builtin will cause the script to abort
71 /bin/kill -KILL `/bin/cat /etc/named.pid`
77 # Before trying to reimpliment this timeout mechanism using interrupts,
78 # be sure to check and make sure that it will work on both types of
79 # machines. As of 6.0B, RT csh didn't respond correctly to onintr.
81 # This timeout is implemented by having the shell check TIMEOUT times
82 # for the existance of /etc/named.pid and to sleep INTERVAL seconds
85 set TIMEOUT=60 # number of INTERVALS until timeout
86 set INTERVAL=60 # number of seconds between checks
90 if (-f /etc/named.pid) break
95 if ($i == $TIMEOUT) exit $SMS_NAMED