#! /bin/sh
#
# Generate the DHCP configuration file, compare it with the current one.
# If they differ then make the new file the current file and restart DHCPD.
#
# $Log: make.dhcp,v $
# Revision 1.2  1997/04/09 05:30:08  david
# Fixed so that if we call it manually in /etc/cron.hourly it won't loop
# infinitely because of search path not set up correctly.
#
# Revision 1.1  1997/04/06 17:50:56  david
# Initial revision
#
#

move()
{
echo "Generating new DHCP Configuration file."
mv $TMP $CONF_FILE
/etc/rc.d/init.d/dhcpd stop
sleep 5
/etc/rc.d/init.d/dhcpd start
}

# MAIN

CONF_FILE=/etc/dhcpd.conf
TMP=/tmp/$$

/usr/sbin/dhcpgen dns.jonesnet.org jonesnet.org > $TMP

if [ -f $CONF_FILE ]; then
   d=`diff $TMP $CONF_FILE`
   if [ "$d"x != "x" ]; then
      move
   fi
 else
   move
fi

rm -rf $TMP

exit 0
