]> andersk Git - moira.git/blame - gen/hesiod.sh
Fix setting of mailroutingaddress.
[moira.git] / gen / hesiod.sh
CommitLineData
ce52ba53 1#!/bin/sh
5eaef520 2# This script performs updates of hesiod files on hesiod servers.
f8f5fe16 3# $Header$
4
f4f32185 5if [ -d /var/athena ] && [ -w /var/athena ]; then
6 exec >/var/athena/moira_update.log 2>&1
7else
8 exec >/tmp/moira_update.log 2>&1
9fi
10
ce52ba53 11set -x
12
13PATH=/etc:/bin:/usr/bin:/usr/etc:/usr/athena/etc
14export PATH
39f6c9df 15
16# The following exit codes are defined and MUST BE CONSISTENT with the
59ec8dae 17# error codes the library uses:
ce52ba53 18MR_HESFILE=47836472
19MR_MISSINGFILE=47836473
20MR_NAMED=47836475
21MR_TARERR=47836476
39f6c9df 22
ce52ba53 23umask 022
abe0e1b9 24
39f6c9df 25# File that will contain the necessary information to be updated
80349f41 26TARFILE=/var/tmp/hesiod.out
39f6c9df 27# Directory into which we will empty the tarfile
ce52ba53 28SRC_DIR=/etc/athena/_nameserver
39f6c9df 29# Directory into which we will put the final product
ce52ba53 30DEST_DIR=/etc/athena/nameserver
31
32NAMED=/etc/athena/named
33NAMED_PID=/var/athena/named.pid
39f6c9df 34
35# Create the destination directory if it doesn't exist
ce52ba53 36if test ! -d $DEST_DIR
37then
f8f5fe16 38 rm -f $DEST_DIR
39 mkdir $DEST_DIR
40 chmod 755 $DEST_DIR
ce52ba53 41fi
39f6c9df 42
abe0e1b9 43# If $SRC_DIR does not already exist, make sure that it gets created
44# on the same parition as $DEST_DIR.
ce52ba53 45if test ! -d $SRC_DIR
46then
52a20deb 47 # Tell linux cd/pwd not to be so "helpful".
48 # This will generate an ignorable error on older platforms.
49 set -P
50
f2a412ca 51 cd $DEST_DIR
abe0e1b9 52 mkdir ../_nameserver
f2a412ca 53 cd ../_nameserver
ce52ba53 54 if test $SRC_DIR != `pwd`
55 then
f8f5fe16 56 ln -s `pwd` $SRC_DIR
ce52ba53 57 fi
58fi
59
60# make sure SRC_DIR is empty
61/bin/rm -rf $SRC_DIR/*
39f6c9df 62
63# Alert if tarfile doesn't exist
ce52ba53 64if test ! -r $TARFILE
65then
66 exit $MR_MISSINGFILE
67fi
39f6c9df 68
de56407f 69cd $SRC_DIR
ce52ba53 70tar xvf $TARFILE
71# Don't put up with errors extracting the information
72if test $? -ne 0
73then
74 exit $MR_TARERR
75fi
76for file in *
77do
39f6c9df 78 # Make sure the file is not zero-length
ce52ba53 79 if test ! -z $file
80 then
f8f5fe16 81 mv -f $file $DEST_DIR
ce52ba53 82 if test $? -ne 0
83 then
84 exit $MR_HESFILE
85 fi
39f6c9df 86 else
f8f5fe16 87 rm -f $file
2ce085d2 88 exit $MR_MISSINGFILE
ce52ba53 89 fi
90done
de56407f 91
39f6c9df 92# Kill off the current named and remove the named.pid file. It is
93# important that this file be removed since the script uses its
94# existance as evidence that named as has been successfully restarted.
95
f8f5fe16 96# First, get statistics
0041862d 97/usr/athena/etc/rndc stats
f8f5fe16 98sleep 1
ce52ba53 99kill -KILL `cat $NAMED_PID`
100rm -f $NAMED_PID
39f6c9df 101
102# Restart named.
ce52ba53 103$NAMED
d7e5ee08 104echo named started
39f6c9df 105
ce52ba53 106sleep 1
39f6c9df 107# This timeout is implemented by having the shell check TIMEOUT times
ce52ba53 108# for the existance of $NAMED_PID and to sleep INTERVAL seconds
39f6c9df 109# between each check.
110
ce52ba53 111TIMEOUT=60 # number of INTERVALS until timeout
112INTERVAL=60 # number of seconds between checks
113i=0
114while test $i -lt $TIMEOUT
115do
116 if test -f $NAMED_PID
117 then
118 break
119 fi
39f6c9df 120 sleep $INTERVAL
ce52ba53 121 i=`expr $i + 1`
122done
d7e5ee08 123echo out of timeout loop
39f6c9df 124# Did it time out?
ce52ba53 125if test $i -eq $TIMEOUT
126then
127 exit $MR_NAMED
128fi
d7e5ee08 129echo no timeout
39f6c9df 130# Clean up!
f8f5fe16 131rm -f $TARFILE
d7e5ee08 132echo removed tarfile
f8f5fe16 133rm -f $0
d7e5ee08 134echo removed self
f89684dc 135
39f6c9df 136exit 0
This page took 0.118601 seconds and 5 git commands to generate.