#!/bin/sh
#

# PROVIDE: soju
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add these lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# soju_enable (bool):	Set to NO by default.
#			Set it to YES to enable soju.
# soju_config (path):	Set to %%PREFIX%%/etc/soju/config
#			by default.

. /etc/rc.subr

name="soju"
rcvar=soju_enable
desc="Soju IRC bouncer"

: ${soju_enable:=NO}
: ${soju_config:=%%PREFIX%%/etc/soju/config}

command=/usr/sbin/daemon
procname="%%PREFIX%%/bin/soju"
pidfile=/var/run/${name}.pid
command_args="-P /var/run/daemon_${name}.pid -p $pidfile -u %%USER%% -H -c -f $procname -config ${soju_config}"
start_precmd="mkdir -p /var/run/soju && chown %%USER%%: /var/run/soju"

load_rc_config $name
run_rc_command "$1"
