#!/bin/sh
#
# unbound freebsd startup rc.d script, modified from the named script.
# uses the default unbound installation path and pidfile location.
# copy this to /etc/rc.d/unbound
# and put unbound_enable="YES" into rc.conf
#

# PROVIDE: unbound
# REQUIRE: SERVERS cleanvar
# KEYWORD: shutdown

. /etc/rc.subr

name="unbound"
rcvar=unbound_enable

command="/usr/local/sbin/unbound"
extra_commands="reload"
start_precmd="start_precmd"

load_rc_config $name

pidfile=${unbound_pidfile:-"/usr/local/etc/unbound/unbound.pid"}
unbound_enable=${unbound_enable:-"NO"}

start_precmd()
{
	/usr/local/sbin/unbound-checkconf && \
	echo -n "Obtaining a trust anchor:" && \
	su -m unbound -c /usr/local/sbin/unbound-anchor && \
	echo .
}

run_rc_command "$1"
