#!/bin/sh
#
# Starts/stops the irc daemon
#

# $PATH to go
PATH=/sbin:/bin:/usr/sbin:/usr/bin
          
# where the irc-daemon is
IRCD=/usr/sbin/ircd
PIDFILE=/var/run/ircd/ircd.pid                  

if [ -x "/usr/sbin/ircd" ]; then
  case "$1" in
          start)
                  echo -n "Starting irc server daemon:"
                  echo -n " ircd"
                  start-stop-daemon --start --quiet --pidfile ${PIDFILE} --chuid irc --exec ${IRCD}
                  echo "."
                  ;;
        
          stop)
                  echo -n "Stopping irc server daemon:"
                  echo -n " ircd"
                  start-stop-daemon --stop --quiet --oknodo --pidfile ${PIDFILE} --exec ${IRCD}
                  echo "."  
                  ;;
        
          restart|force-reload)
                  echo -n "Restarting irc server daemon:"
                  echo -n " ircd"
                  start-stop-daemon --stop --quiet --oknodo --pidfile ${PIDFILE} --exec ${IRCD}
                  sleep 2
                  start-stop-daemon --start --quiet --pidfile ${PIDFILE} --chuid irc --exec ${IRCD}
                  echo "."
                  ;;
          *)
                  echo "Usage: $0 {start|stop|restart|force-reload}"
                  exit 1
                  ;;
  esac
fi

exit 0

