#!/bin/sh
#
# $NetBSD: atheme.sh,v 1.1.1.1 2008/06/16 10:38:27 adrianp Exp $
#
# PROVIDE: atheme
# REQUIRE: DAEMON
# KEYWORD: shutdown
#

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

name="atheme"
rcvar=${name}
command="/usr/pkg/bin/${name}-services"
required_files="/usr/pkg/etc/atheme/atheme.conf"
pidfile="/var/run/atheme/atheme.pid"
atheme_user="atheme"
atheme_group="atheme"
# command_args="-l /var/log/atheme/atheme.log -p ${pidfile}"
start_precmd="atheme_precmd"

atheme_precmd()
{
	if [ ! -d /var/run/atheme ]; then
		/bin/mkdir -p /var/run/atheme
		/bin/chmod 0750 /var/run/atheme
		/usr/sbin/chown atheme:atheme /var/run/atheme
	fi

	if [ ! -d /var/log/atheme ]; then
		/bin/mkdir -p /var/log/atheme
		/bin/chmod 0750 /var/log/atheme
		/usr/sbin/chown atheme:atheme /var/log/atheme
	fi

	if [ ! -d /var/atheme ]; then
		/bin/mkdir -p /var/atheme
		/bin/chmod 0750 /var/atheme
		/usr/sbin/chown atheme:atheme /var/atheme
	fi
}

load_rc_config $name
run_rc_command "$1"
