#!/bin/sh

# PROVIDE: bitlbee
# REQUIRE: DAEMON

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

name="bitlbee"
rcvar=$name
command="/usr/pkg/sbin/bitlbee"
pidfile="/var/run/${name}/pid"
command_args="-D"	# run as a daemon
start_precmd="bitlbee_precmd"

bitlbee_precmd()
{
	if [ ! -d "/var/run/${name}" ]; then
		/bin/mkdir -p "/var/run/${name}"
		/bin/chmod 0700 "/var/run/${name}"
		/usr/sbin/chown bitlbee:nobody "/var/run/${name}"
	fi
}

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