diff options
Diffstat (limited to 'net-irc/ngircd/files/ngircd.init-r2.d')
-rw-r--r-- | net-irc/ngircd/files/ngircd.init-r2.d | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/net-irc/ngircd/files/ngircd.init-r2.d b/net-irc/ngircd/files/ngircd.init-r2.d new file mode 100644 index 000000000000..1a54154ff417 --- /dev/null +++ b/net-irc/ngircd/files/ngircd.init-r2.d @@ -0,0 +1,52 @@ +#!/sbin/openrc-run +# Copyright 1999-2022 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +extra_commands="configtest" +extra_started_commands="reload" + +description="IRC server" +description_configtest="Run ngircd's internal config check." +description_reload="Reload the ngircd's configuration." + +: ${NGIRCD_CONFIGFILE:=/etc/ngircd/${RC_SVCNAME}.conf} + +command="/usr/sbin/ngircd" +command_args="${NGIRCD_OPTS} -f \"${NGIRCD_CONFIGFILE}\"" +command_args_foreground="-n" +command_user="ngircd:ngircd" +pidfile="${NGIRCD_PIDFILE:-/var/run/ngircd/${RC_SVCNAME}.pid}" + +depend() { + need net + use logger + provide ircd +} + +start_pre() { + checkpath -f "${pidfile}" -o ${command_user} || return 1 + if [ "${RC_CMD}" != "restart" ]; then + configtest || return 1 + fi +} + +stop_pre() { + if [ "${RC_CMD}" = "restart" ]; then + configtest || return 1 + fi +} + +reload() { + configtest || return 1 + ebegin "Refreshing ${RC_SVCNAME}'s configuration" + start-stop-daemon --signal SIGHUP --pidfile "${pidfile}" + eend $? "Failed to reload ${RC_SVCNAME}" +} + +configtest() { + ebegin "Checking ${RC_SVCNAME}'s configuration" + # "press enter to continue" + echo | ${command} -f "${NGIRCD_CONFIGFILE}" -t >/dev/null + + eend $? "failed, please correct errors in the config file" +} |