#!/sbin/openrc-run

supervisor=supervise-daemon
name="ergo"
command="/usr/bin/ergo"
command_args="run --conf ${ERGO_CONFIGFILE:-'/etc/ergo/ircd.yaml'}"
error_log=/var/log/ergo.log
command_user="ergo:ergo"
directory="/var/$RC_SVCNAME"
command_background=true
pidfile="/run/ergo.pid"

extra_started_commands="reload"
description_reload="Rehash configuration, certificates and the MOTD"

depend() {
	need net localmount
	after firewall
}

start_pre() {
	checkpath -d -o $command_user "$directory"
	checkpath -f -o $command_user "$error_log"
}

reload() {
	ebegin "Rehashing configuration, certificates and the MOTD"
	$supervisor $RC_SVCNAME --signal HUP
	eend $?
}
