#!/bin/sh
#
# $NetBSD: isc_dhcpd.sh,v 1.1 2009/01/04 00:58:42 adrianp Exp $
#

# PROVIDE: dhcpd
# REQUIRE: DAEMON
# BEFORE:  LOGIN

if [ -f /etc/rc.subr ]; then
        . /etc/rc.subr
fi

name="isc_dhcpd"
rcvar="${name}"
command="/usr/pkg/sbin/dhcpd"
pidfile="/var/run/isc-dhcp/isc-dhcpd.pid"
required_files="/usr/pkg/etc/dhcp/dhcpd.conf"
start_precmd="isc_dhcpd_precmd"

isc_dhcpd_precmd()
{
	if [ ! -d /var/run/isc-dhcp ]; then
		/bin/mkdir -p /var/run/isc-dhcp
		/bin/chmod 0770 /var/run/isc-dhcp
	fi

	if [ ! -f /var/db/isc-dhcp/dhcpd.leases ]; then
		/bin/mkdir -p /var/db/isc-dhcp
		/usr/bin/touch /var/db/isc-dhcp/dhcpd.leases
		/bin/chmod 0640 /var/db/isc-dhcp/dhcpd.leases
	fi
}

load_rc_config $rcvar
run_rc_command "$1"
