#!/bin/bash

# Init file for Next Generation IRC Server
#
# chkconfig: 2345 55 25
# description: Next Generation IRC Server daemon
#
# processname: ngircd
# pidfile: /var/run/ngircd.pid

# source function library
. /etc/rc.d/init.d/functions

PID_FILE=/var/run/ngircd.pid
RETVAL=0

# Some functions to make the below more readable


case "$1" in
	start)
		
		echo -n "Starting Next Generation IRC Server: "
		if [ ! -f $PID_FILE ] ; then
			/usr/sbin/ngircd && success && touch /var/lock/subsys/ngircd || failure
			touch /var/lock/subsys/ngircd
		fi
		echo
		;;
	stop)
		echo -n "Shutting down Next Generation IRC Server: "
#		if [ -f $PID_FILE ] ; then
			killall -9 ngircd
			rm -rf $PID_FILE && success
			[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/ngircd
#		fi
		echo
		;;
	restart)
		$0 stop
		$0 start
		;;
	*)
		echo "Usage: ngirc {start|stop|restart}"
		exit 1
		;;
esac

exit $RETVAL
