#!/bin/sh
#
# PROVIDE: fabrixd
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable fabrixd:
#
# fabrixd_enable="YES"
#
# fabrixd_enable (bool):    Set to NO by default.
#                           Set it to YES to enable fabrixd.
# fabrixd_config (path):    Set to /usr/local/etc/fabrixd.conf by default.
#                           Path to configuration file.

. /etc/rc.subr

name="fabrixd"
rcvar="${name}_enable"

load_rc_config $name

: ${fabrixd_enable:="NO"}
: ${fabrixd_config="/usr/local/etc/fabrixd.conf"}

pidfile="/var/run/${name}/${name}.pid"
logfile="/var/log/${name}.log"

procname="/usr/local/bin/fabrixd"
command="/usr/sbin/daemon"
command_args="-p ${pidfile} -o ${logfile} -S -T ${name} -- ${procname} -c ${fabrixd_config}"

start_precmd="${name}_prestart"

fabrixd_prestart()
{
	install -d -m 755 /var/run/${name}
}

run_rc_command "$1"
