#!/bin/sh # # $FreeBSD$ # # PROVIDE: knot # REQUIRE: SERVERS cleanvar # KEYWORD: shutdown # # Add the following lines to /etc/rc.conf to enable knot: # # knot_enable="YES": Set to NO by default. # Set it to YES to enable knot. # knot_config="": Set to /usr/local/etc/knot/knot.conf # by default. . /etc/rc.subr name=knot rcvar=knot_enable load_rc_config ${name} : ${knot_enable:=NO} : ${knot_config="%%PREFIX%%/etc/knot/knot.conf"} command=%%PREFIX%%/sbin/knotd command_args="-c ${knot_config} -d" control=%%PREFIX%%/sbin/knotc pidfile=/var/run/knot/knot.pid required_files=${knot_config} extra_commands=reload reload_cmd="${name}_reload" start_precmd="${name}_prestart" knot_prestart() { if [ ! -d /var/run/knot ]; then install -d -o %%USERS%% -g %%GROUPS%% /var/run/knot fi if [ ! -d /var/db/knot ]; then install -d -o %%USERS%% -g %%GROUPS%% /var/db/knot fi grep -v '#' ${knot_config} | grep -q -E 'knot.knot;|bind.bind;' if [ $? -ne 0 ]; then echo "Notice: not running as uid.gid knot.knot or bind.bind" fi ${control} -c ${knot_config} checkconf } knot_reload() { echo "Reloading ${name}." ${control} -c ${knot_config} reload } run_rc_command "$1"