#!/bin/sh
#
# $NetBSD: isc_dhcpd6.sh,v 1.1 2013/12/13 16:34:17 jakllsch Exp $
#

# PROVIDE: dhcpd6
# REQUIRE: DAEMON
# BEFORE:  LOGIN

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

name="isc_dhcpd6"
rcvar="${name}"
command="/usr/pkg/sbin/dhcpd"
command_args="-6 -cf /usr/pkg/etc/dhcp/dhcpd6.conf"
pidfile="/var/run/isc-dhcp/isc-dhcpd6.pid"
required_files="/usr/pkg/etc/dhcp/dhcpd6.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/dhcpd6.leases ]; then
		/bin/mkdir -p /var/db/isc-dhcp
		/usr/bin/touch /var/db/isc-dhcp/dhcpd6.leases
		/bin/chmod 0640 /var/db/isc-dhcp/dhcpd6.leases
	fi
}

load_rc_config $rcvar
run_rc_command "$1"
