#!/bin/sh
#
# $NetBSD: ircd-hybrid.sh,v 1.6 2021/08/29 18:38:53 khorben Exp $
#
# PROVIDE: ircdhybrid
# REQUIRE: DAEMON

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

name="ircdhybrid"
rcvar=$name
piddir="/var/run/ircd-hybrid"
pidfile="$piddir/ircd.pid"
command="/usr/pkg/bin/ircd"
conffile="/usr/pkg/etc/ircd-hybrid/ircd.conf"
command_args="-configfile $conffile"
required_files="$conffile"
ircdhybrid_user="irc"
ircdhybrid_group="irc"
start_precmd="set_pid_file"

set_pid_file () {
	/bin/mkdir -p $piddir
	/usr/sbin/chown irc $piddir 
	/usr/bin/chgrp irc $piddir
	/bin/chmod 0770 $piddir
	/usr/bin/touch $pidfile 
	/usr/sbin/chown irc $pidfile 
	/usr/bin/chgrp irc $pidfile
	/bin/chmod 0640 $pidfile
}

load_rc_config $name
run_rc_command "$1"
