#!/bin/sh
# IRCD Script v3.0
# $Id$ 
#
DIR=`pwd`
DATE=`date +"%a, %b %e %Y"`
TIME=`date +"%H:%M:%S %Z"`
IRCDPID="ircd.pid"
BACKUP="ircd.bak"

if [ -r $IRCDPID ]; then
mv -f $IRCDPID $BACKUP
src/ircd
sleep 1
if [ ! -r $IRCDPID ]; then
mv -f $BACKUP $IRCDPID
echo "|--------------------------------------------|"
echo "|              **** ERROR ****               |"
echo "|             Possible problems:             |"
echo "| (1) IRCd already running.                  |"
echo "| (2) The correct IP was not placed in the   |"
echo "|     M:line of the ircd.conf.               |"
echo "| (3) DPATH or SPATH's are incorrect. Run    |"
echo "|     ./Config to correct that.              |"
echo "| (4) Someone else is running an ircd on the |"
echo "|     default port you chose in ircd.conf.   |"
echo "|                                            |"
echo "|      see ircd.log for more information     |"
echo "|********************************************|"
echo "| If you can't get Unreal IRCd to work - go  |"
echo "| to /server irc.flirt.org and join          |"
echo "| #UnrealIRCd or mail us at                  |"
echo "|    unreal-support@lists.sourceforge.net    |"
echo "|                                            |"
echo "|--------------------------------------------|"
exit
else
echo "|----------------------------------------"
echo "| UnrealIRCD successfully loaded."
echo "| Directory: $DIR"
echo "| Date: $DATE"
echo "| Time: $TIME"
PID=`cat ircd.pid`
echo "| Process ID: $PID"
echo "|----------------------------------------"
rm -f $BACKUP
  fi
else
src/ircd
sleep 2
if [ ! -r $IRCDPID ]; then
echo "|--------------------------------------------|"
echo "|              **** ERROR ****               |"
echo "|             Possible problems:             |"
echo "| (1) IRCd already running.                  |"
echo "| (2) The correct IP was not placed in the   |"
echo "|     M:line of the ircd.conf.               |"
echo "| (3) DPATH or SPATH's are incorrect. Run    |"
echo "|     ./Config to correct that.              |"
echo "| (4) Someone else is running an ircd on the |"
echo "|     default port you chose in ircd.conf.   |"
echo "|********************************************|"
echo "| If you can't get Unreal IRCd to work - go  |"
echo "| to /server irc.flirt.org and join          |"
echo "| #UnrealIRCd or mail us at                  |"
echo "|    unreal-support@lists.sourceforge.net    |"
echo "|                                            |"
echo "|--------------------------------------------|"

exit
else
echo "|----------------------------------------"
echo "| UnrealIRCD successfully loaded."
echo "| Directory: $DIR"
echo "| Date: $DATE"
echo "| Time: $TIME"
PID=`cat ircd.pid`
echo "| Process ID: $PID"
echo "|----------------------------------------"
  fi
fi
