]> andersk Git - moira.git/blame_incremental - gen/hesiod.sh
Diane Delgado's changes for a fixed table-locking order
[moira.git] / gen / hesiod.sh
... / ...
CommitLineData
1#!/bin/csh -f
2# This script performs updates of hesiod files on hesiod servers.
3# $Header$
4
5set path=(/etc /bin /usr/bin /usr/etc /usr/athena/etc)
6
7# The following exit codes are defined and MUST BE CONSISTENT with the
8# MR error codes the library uses:
9set MR_HESFILE = 47836472
10set MR_MISSINGFILE = 47836473
11set MR_NAMED = 47836475
12set MR_TARERR = 47836476
13
14umask 22
15
16# File that will contain the necessary information to be updated
17set TARFILE=/var/tmp/hesiod.out
18# Directory into which we will empty the tarfile
19set SRC_DIR=/etc/athena/_nameserver
20# Directory into which we will put the final product
21set DEST_DIR=/etc/athena/nameserver
22
23# Create the destination directory if it doesn't exist
24if (! -d $DEST_DIR) then
25 rm -f $DEST_DIR
26 mkdir $DEST_DIR
27 chmod 755 $DEST_DIR
28endif
29
30# If $SRC_DIR does not already exist, make sure that it gets created
31# on the same parition as $DEST_DIR.
32if (! -d $SRC_DIR) then
33 chdir $DEST_DIR
34 mkdir ../_nameserver
35 chdir ../_nameserver
36 if ($SRC_DIR != `pwd`) then
37 ln -s `pwd` $SRC_DIR
38 endif
39endif
40
41# Alert if tarfile doesn't exist
42if (! -r $TARFILE) exit $MR_MISSINGFILE
43
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.
46cd $SRC_DIR
47foreach file (`tar tf $TARFILE | awk '{print $1}' | sed 's;/$;;'`)
48 if (. == $file) continue
49
50 rm -rf $file
51 echo extracting $file
52 tar xf $TARFILE $file
53 # Don't put up with errors extracting the information
54 if ($status) exit $MR_TARERR
55 # Make sure the file is not zero-length
56 if (! -z $file) then
57 mv -f $file $DEST_DIR
58 if ($status != 0) exit $MR_HESFILE
59 else
60 rm -f $file
61 exit $MR_MISSINGFILE
62 endif
63end
64
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.
68
69# First, get statistics
70rm -f /usr/tmp/named.stats
71ln -s /var/named.stats /usr/tmp/named.stats
72kill -6 `cat /etc/named.pid`
73sleep 1
74# Use /bin/kill because, due to a bug in some versions of csh, failure
75# of a builtin will cause the script to abort
76kill -KILL `cat /etc/named.pid`
77rm -f /etc/named.pid
78
79# Restart named.
80# mv /etc/named.pid /etc/named.pid.restart
81#(unlimit; /etc/named&)
82/etc/named
83#sleep 5
84echo named started
85
86# This timeout is implemented by having the shell check TIMEOUT times
87# for the existance of /etc/named.pid and to sleep INTERVAL seconds
88# between each check.
89
90set TIMEOUT=60 # number of INTERVALS until timeout
91set INTERVAL=60 # number of seconds between checks
92set i = 0
93while ($i < $TIMEOUT)
94 sleep $INTERVAL
95 if (-f /etc/named.pid) break
96 @ i++
97end
98echo out of timeout loop
99# Did it time out?
100if ($i == $TIMEOUT) exit $MR_NAMED
101echo no timeout
102# Clean up!
103rm -f $TARFILE
104echo removed tarfile
105rm -f $0
106echo removed self
107
108exit 0
This page took 0.091868 seconds and 5 git commands to generate.