source: trunk/third/moira/gen/dhcp.sh @ 25455

Revision 25455, 1.3 KB checked in by jdreed, 12 years ago (diff)
In moira: * Re-snapshot moira at r4073 to pick up new changes to clients; the eunice issue described in the previous entry is no longer relevant
  • Property svn:executable set to *
Line 
1#! /bin/sh
2# $Id: dhcp.sh 4058 2011-11-16 21:32:41Z zacheiss $
3
4if [ -d /var/athena ] && [ -w /var/athena ]; then
5    exec >/var/athena/moira_update.log 2>&1
6else
7    exec >/tmp/moira_update.log 2>&1
8fi
9
10# The following exit codes are defined and MUST BE CONSISTENT with the
11# error codes the library uses:
12MR_MISSINGFILE=47836473
13MR_MKCRED=47836474
14MR_TARERR=47836476
15
16PATH=/usr/bin:/bin
17TARFILE=/var/tmp/dhcp.out
18BOOTGEN=/var/boot/dhcpd.conf.print
19BOOTHEAD=/var/boot/dhcpd.conf.head
20BOOTFOOT=/var/boot/dhcpd.conf.foot
21BOOTFILE=/var/boot/dhcpd.conf
22PSWDFILE=/var/boot/hp.add
23ACLFILE=/var/boot/ip-acl.add
24
25# Alert if the tar file or other needed files do not exist
26test -r $TARFILE || exit $MR_MISSINGFILE
27test -r $BOOTHEAD || exit $MR_MISSINGFILE
28test -r $BOOTFOOT || exit $MR_MISSINGFILE
29test -r $PSWDFILE || exit $MR_MISSINGFILE
30
31cd /
32tar xf $TARFILE || exit $MR_TARERR
33
34# Append passwords, etc., to the new files
35for f in `find /var/boot/hp -name \*.new -print`; do
36    grep '^allow:' $f >/dev/null 2>&1
37    if [ $? = 0 ]; then
38        cat $ACLFILE >> $f
39    fi
40    cat $PSWDFILE >> $f
41    mv $f /var/boot/hp/`basename $f .new`
42done
43
44# Build full bootptab
45cat $BOOTHEAD $BOOTGEN $BOOTFOOT > $BOOTFILE
46
47# kill and rerun dhcpd
48/etc/init.d/dhcpd stop
49/etc/init.d/dhcpd start
50
51# cleanup
52test -f $TARFILE && rm -f $TARFILE
53test -f $0 && rm -f $0
54
55exit 0
Note: See TracBrowser for help on using the repository browser.