#! /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 their 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
# Prevent it from nuking quotas: core and file size
ulimit -c 1024
ulimit -f 2048
# Prevent a bloated stack: stack size.
ulimit -s 2048
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
# If you don't have GNU expr you have a problem... :(
index=`expr $index + 1`
# Alternatively if you have bc
# index=`echo $index + 1|bc`
else
break
fi
done
# Update to new code if possible.
if [ -r ../bin/daleken.new ]; then
if [ -r ../bin/daleken ]; then
\mv ../bin/daleken ../bin/daleken.old
fi
\mv ../bin/daleken.new ../bin/daleken
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 $port >>$logfile 2>&1
if [ -r core ]; then
\mv core ../log/.$index.`date +%d%b%y`
fi
# Restart, giving old connections a chance to die.
if [ -r SHUTDOWN.TXT ]; then
rm -f SHUTDOWN.TXT
exit 0
fi
sleep 7
done