]> andersk Git - moira.git/blob - gen/dhcp.sh
use abstraction barriers to restart dhcpd
[moira.git] / gen / dhcp.sh
1 #! /bin/sh
2 # $Id$
3
4 if [ -d /var/athena ] && [ -w /var/athena ]; then
5     exec >/var/athena/moira_update.log 2>&1
6 else
7     exec >/tmp/moira_update.log 2>&1
8 fi
9
10 # The following exit codes are defined and MUST BE CONSISTENT with the
11 # error codes the library uses:
12 MR_MISSINGFILE=47836473
13 MR_MKCRED=47836474
14 MR_TARERR=47836476
15
16 PATH=/usr/bin:/bin
17 TARFILE=/var/tmp/dhcp.out
18 BOOTGEN=/var/boot/dhcpd.conf.print
19 BOOTHEAD=/var/boot/dhcpd.conf.head
20 BOOTFOOT=/var/boot/dhcpd.conf.foot
21 BOOTFILE=/var/boot/dhcpd.conf
22 PSWDFILE=/var/boot/hp.add
23
24 # Alert if the tar file or other needed files do not exist
25 test -r $TARFILE || exit $MR_MISSINGFILE
26 test -r $BOOTHEAD || exit $MR_MISSINGFILE
27 test -r $BOOTFOOT || exit $MR_MISSINGFILE
28 test -r $PSWDFILE || exit $MR_MISSINGFILE
29
30 cd /
31 tar xf $TARFILE || exit $MR_TARERR
32
33 # Append passwords, etc., to the new files
34 for f in `find /var/boot/hp -name \*.new -print`; do
35     cat $PSWDFILE >> $f
36     mv $f /var/boot/hp/`basename $f .new`
37 done
38
39 # Build full bootptab
40 cat $BOOTHEAD $BOOTGEN $BOOTFOOT > $BOOTFILE
41
42 # kill and rerun dhcpd
43 /etc/init.d/dhcpd stop
44 /etc/init.d/dhcpd start
45
46 # cleanup
47 test -f $TARFILE && rm -f $TARFILE
48 test -f $0 && rm -f $0
49
50 exit 0
This page took 0.04464 seconds and 5 git commands to generate.