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