#! /bin/sh
#
# Start or stop dhcpd daemon
#
#
# chkconfig: 2345 20 20
#
PATH=/bin:/usr/bin:/sbin:/usr/sbin

test -x /usr/sbin/dhcpd || exit 0

# Set run_dhcpd to 1 to start dhcpd at boot or 0 to disable it.
run_dhcpd=1

if [ $run_dhcpd = 0 ]; then
	cat <<EOF

Please edit the file /etc/dhcpd.conf according to your needs. The current
/etc/dhcpd.conf is just the sample file that is provided with the DHCP
package from the Internet Software Consortium, so it will not be useful
at all for you.

After you have edited /etc/dhcpd.conf you will have to edit
/etc/init.d/dhcp as well. There you will have to set the variable
run_dhcpd to 1, and then type "/etc/init.d/dhcp start" to start the
dhcpd daemon.

EOF
	exit 0
fi

DHCPDPID=/var/run/dhcpd.pid
INTERFACES=eth1

case "$1" in
	start)
		start-stop-daemon --start --quiet --pidfile $DHCPDPID \
			--exec /usr/sbin/dhcpd -- -q $INTERFACES
		;;
	stop)
		start-stop-daemon --stop --quiet --pidfile $DHCPDPID
		;;
	restart)
		start-stop-daemon --stop --quiet --pidfile $DHCPDPID
		sleep 2
		start-stop-daemon --start --quiet --pidfile $DHCPDPID \
			--exec /usr/sbin/dhcpd -- -q
		;;
	*)
		echo "Usage: /etc/init.d/dhcp {start|stop|restart}"
		exit 1 
esac

exit 0
