--- /usr/portage/net-irc/unrealircd/files/unrealircd.rc 2004-10-09 22:46:39.000000000 +0200 +++ /etc/init.d/unrealircd 2009-11-20 22:36:12.000000000 +0100 @@ -3,6 +3,11 @@ # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/net-irc/unrealircd/files/unrealircd.rc,v 1.7 2004/10/09 20:36:31 swegener Exp $ +# Set the pidfile from unrealircd that is hardcoded to this location through the ebuild installation process. +UNREALIRCD_PIDFILE=${UNREALIRCD_PIDFILE:-/var/run/unrealircd/ircd.pid} +UNREALIRCD_LOGFILE=${UNREALIRCD_LOGFILE:-/var/log/unrealircd/ircd.log} +UNREALIRCD_GROUP=${UNREALIRCD_GROUP:-${UNREALIRCD_USER:-unrealircd}} + opts="reload start stop" depend() { @@ -11,20 +16,43 @@ } start() { - ebegin "Starting unrealircd" + ebegin "Starting ${SVCNAME}" + # UnrealIRCd do not touch the pidfile if it exists on startup + if [ -f ${UNREALIRCD_PIDFILE} ]; then + ewarn "The file ${UNREALIRCD_PIDFILE} already exists. Maybe ${SVCNAME} crashed, please check ${UNREALIRCD_LOGFILE}" + rm -f ${UNREALIRCD_PIDFILE} + fi start-stop-daemon --start --quiet --exec /usr/bin/unrealircd \ - --chuid ${UNREALIRCD_USER} -- ${UNREALIRCD_OPTS} &>/dev/null + --chuid ${UNREALIRCD_USER} --group ${UNREALIRCD_GROUP} -- ${UNREALIRCD_OPTS} &>/dev/null eend $? } stop() { - ebegin "Shutting down unrealircd" - killall unrealircd + ebegin "Shutting down ${SVCNAME}" + if [ -f ${UNREALIRCD_PIDFILE} ]; then + start-stop-daemon --stop --quiet --pidfile ${UNREALIRCD_PIDFILE} &>/dev/null + else + ewarn "Can't find ${UNREALIRCD_PIDFILE} trying to stop ${SVCNAME} over his process name." + start-stop-daemon --stop --quiet --name ${SVCNAME} &>/dev/null + fi eend $? } reload() { - ebegin "Re-Loading unrealircd" - killall -1 unrealircd + ebegin "Re-Loading ${SVCNAME}" + if [ -f ${UNREALIRCD_PIDFILE} ]; then + start-stop-daemon --signal HUP --quiet --pidfile ${UNREALIRCD_PIDFILE} &>/dev/null + else + ewarn "Can't find ${UNREALIRCD_PIDFILE} trying to reload ${SVCNAME} over his process name." + start-stop-daemon --signal HUP --quiet --name ${SVCNAME} &>/dev/null + # UnrealIRCd do not recreate the file while rehashing + if [ $? -eq 0 ]; then + ebegin "Recreating ${UNREALIRCD_PIDFILE} for ${SVCNAME} daemon." + echo `pidof ${SVCNAME}` > ${UNREALIRCD_PIDFILE} && \ + chown ${UNREALIRCD_USER}:${UNREALIRCD_GROUP} ${UNREALIRCD_PIDFILE} && \ + chmod 0600 ${UNREALIRCD_PIDFILE} + eend $? + fi + fi eend $? }