#! /bin/sh
#
# ircd		IRC server
#
# description:  loads the IRC server
# chkconfig:    - 97 13

# Source function library.
. /etc/init.d/functions

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
if [ ${NETWORKING} = "no" ]
then
	exit 0
fi

[ -r /etc/ircd/ircd.conf ] || exit 0

RETVAL=0
prog="/usr/sbin/ircd"
user="irc"

start() {
        echo -n "Starting IRC service: "
	daemon --user ${user} ${prog}
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && touch /var/lock/subsys/ircd
	return $RETVAL
}

stop() {
	echo -n "Stopping IRC service: "
        killproc ircd
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && rm -f /var/lock/subsys/ircd
        return $RETVAL
}	

rhstatus() {
	status ${prog}
}

restart() {
	stop
	start
}

reload() {
	echo -n "Reloading IRC service: "
	killproc ${prog} -HUP
	RETVAL=$?
	echo
	return $RETVAL
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
	rhstatus
	;;
  restart)
	restart
	;;
  reload)
	reload
	;;
  *)
	echo "Usage: $0 {start|stop|status|restart|reload}"
	exit 1
esac

exit 0
