#!/bin/sh
#
# $NetBSD: unbound.sh,v 1.5 2015/12/28 13:48:30 bsiegert Exp $
#
# PROVIDE: unbound
# REQUIRE: DAEMON
#

. /etc/rc.subr

name="unbound"
rcvar=${name}

command=/usr/pkg/sbin/${name}
pidfile=/var/run/${name}/${name}.pid
required_files="/usr/pkg/etc/unbound/unbound.conf"
extra_commands="reload"
start_precmd="unbound_precmd"

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

unbound_flags=${unbound_flags:-""}

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