#!/bin/sh
#
# $NetBSD: anope.sh,v 1.3 2019/12/08 03:55:05 nia Exp $
#
# PROVIDE: anope
# REQUIRE: DAEMON

. /etc/rc.subr

name="anope"
rcvar=${name}
command="/usr/pkg/bin/anope"
command_args="--confdir=/usr/pkg/etc/anope"
command_args="${command_args} --dbdir=/usr/pkg/anope/data"
command_args="${command_args} --localedir=/usr/pkg/share/locale"
command_args="${command_args} --logdir=/usr/pkg/anope/logs"
command_args="${command_args} --modulesdir=/usr/pkg/lib/anope"
required_files="/usr/pkg/etc/anope/anope/services.conf"
pidfile="/usr/pkg/anope/${name}.pid"

anope_user="anope"
anope_group="anope"

extra_commands="support"
support_cmd="anope_support"

anope_support()
{
	if [ ! -f ${required_files} ]; then
		warn "${required_files} does not exist."
		return 1;
	fi
	su -m ${anope_user}:${anope_group} -c "${command} ${command_args} --support"
}

load_rc_config $name
run_rc_command "$1"
