daleken/
daleken/data/notes/
daleken/data/player/
daleken/data/system/poses/
daleken/doc/Homepage/images/
daleken/log/
:
#! /bin/sh -f
# Written by Furey.
# With additions from Tony.
# With changes from Kahn.
# Ported to 'sh' by Loki for those who don't have 'csh'.
# Thanks to Alan and Grodyn for thier help on the redirecting stuff - Loki

# Set the port number.
if [ "$1" != "" ]; then
         port=$1 
else
         port=12345
fi

# Change to area directory.
cd `dirname $0`/../area

# Set limits. (cannot be used in a 'sh' script - Loki)
# nohup
# nice
# limit stack 1024k
if [ -r shutdown.txt ]; then
         rm -f shutdown.txt
fi

while [ 1 ]; do

    # If you want to have logs in a different directory,
    #   change the 'logfile=' line to reflect the directory name.
    # (It isn't used but I let it in anyway)
    index=1000
    while [ 1 ]; do
        logfile=../log/$index.log
        if [ -r $logfile ]; then
                 index=`expr $index + 1`
        else
                 break
        fi
    done

    # Update to new code if possible.
    if [ -r ../bin/daleken.new ]; then
	if [ -r ../bin/daleken.exe ]; then
	    \mv ../bin/daleken.exe ../bin/daleken.old
	fi
	\mv ../bin/daleken.new ../bin/daleken.exe
    fi

    # Run daleken.
    # Thanks to Alan and Grodyn for their help on the redirecting stuff - Loki
    echo Running DalekenMUD on port $port. > $logfile
    ../bin/daleken.exe $port >>$logfile 2>&1

    if [ -r core ]; then
	\mv core ../src/
    fi

    # Restart, giving old connections a chance to die.
    if [ -r shutdown.txt ]; then
        rm -f shutdown.txt
        exit 0
    fi
    sleep 7
done