#!/bin/sh
#
# $NetBSD: knot.sh,v 1.3 2015/10/26 19:23:08 pettai Exp $
#
# PROVIDE: knot
# REQUIRE: NETWORKING syslogd
# BEFORE:  DAEMON

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

name="knot"
rcvar=${name}
command="/usr/pkg/sbin/knotc"
knotd="/usr/pkg/sbin/knotd"
command_args=""
pidfile="/var/knot/${name}.pid"
start_precmd="knot_precmd"
extra_commands="reload"
start_cmd="$knotd -d"
stop_cmd="$command stop"
reload_cmd="$command reload"
status_cmd="$command status"

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

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