#!/bin/sh
#
# $NetBSD: nlnsd.sh,v 1.1 2019/01/29 14:54:03 ryoon Exp $
#
# PROVIDE: nlnsd
# REQUIRE: DAEMON
#

. /etc/rc.subr

name="nlnsd"
rcvar=${name}

command=/usr/pkg/sbin/nsd
pidfile=/var/run/nsd/nsd.pid
required_files="/usr/pkg/etc/nsd/nsd.conf"
start_precmd="nsd_precmd"

nsd_precmd()
{
	if [ ! -d /var/run/nsd ]; then
		/bin/mkdir -p /var/run/nsd
		/bin/chmod 0750 /var/run/nsd
		/usr/sbin/chown nsd:nsd /var/run/nsd
	fi
}

nsd_flags=${nsd_flags:-""}

if [ -f /etc/rc.subr ]; then
	load_rc_config ${name}
	run_rc_command "$1"
else
	echo -n " ${name}"
	${command} ${nsd_flags}
fi
