#!/bin/sh
#
# ircd		This shell script takes care of starting and stopping ircd.
#
# chkconfig:	234 75 30
# description:	Internet Relay Chat Server.
#

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

# Source networking configuration.
. /etc/sysconfig/network

# Get service config
[ -f /etc/sysconfig/ircd ] && . /etc/sysconfig/ircd

# Check that networking is up.
if is_yes "${NETWORKING}"; then
	if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
		msg_network_down "IRCd Server"
		exit 1
	fi
else
	exit 0
fi


# See how we were called.
case "$1" in
  start)
	# Check if the service is already running?
	if [ ! -f /var/lock/subsys/ircd ]; then
		# Start daemons.
		msg_starting "IRCd Server"
		daemon ircd
		touch /var/lock/subsys/ircd
	else
		msg_already_running "IRCd Server"
	fi
	;;
  stop)
	# Check if the service is already running?
	if [ -f /var/lock/subsys/ircd ]; then
		# Stop daemons.
		msg_stopping "IRCd Server"
		killproc ircd
		rm -f /var/run/ircd.pid /var/lock/subsys/ircd >/dev/null 2>&1
	else
		msg_already_running "IRCd Server"
	fi
	;;
  restart|force-reload)
  	$0 stop
	$0 start
	exit $?
	;;
  status)
  	status ircd
	exit $?
	;;
  *)
	msg_usage "$0 {start|stop|restart|force-reload|status}"
	exit 3
esac

exit 0
