#!/bin/sh
#
# $Id: dhcp.init.d,v 1.3.2.2 2002/08/11 22:11:54 peloy Exp $
#

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

# Defaults
INTERFACES="eth0"

# Reads config file (will override defaults above)
[ -r /etc/default/dhcp ] && . /etc/default/dhcp

DHCPDPID=/var/run/dhcpd.pid

case "$1" in
	start)
		echo -n "Starting DHCP server: "
		start-stop-daemon --start --quiet --pidfile $DHCPDPID \
			--exec /usr/sbin/dhcpd -- -q $INTERFACES
		sleep 2

		if [ -f "$DHCPDPID" ] && ps h `cat "$DHCPDPID"` >/dev/null; then
			echo "dhcpd."
		else
			echo "dhcpd failed to start - check syslog for diagnostics."
		fi
		;;
	stop)
		echo -n "Stopping DHCP server: dhcp"
		start-stop-daemon --stop --quiet --pidfile $DHCPDPID
		echo "."
		;;
	restart | force-reload)
		$0 stop
		sleep 2
		$0 start
		;;
	*)
		echo "Usage: /etc/init.d/dhcp {start|stop|restart|force-reload}"
		exit 1 
esac

exit 0
