rm6/
rm6/clans/
rm6/councils/
rm6/deity/
rm6/doc/mudprogs/
rm6/exchange/
rm6/gods/
rm6/homes/
rm6/nations/
rm6/player/
rm6/player/a/
rm6/src/RCS/
rm6/src/dmalloc/
rm6/src/dmalloc/bin/
rm6/src/dmalloc/include/
rm6/src/dmalloc/lib/
rm6/src/scripts/
rm6/src/utils/
#! /bin/csh -f

# Set the port number.
set port = 7000
set basedir = /home/badas/rm5
set email = "badas@localhost"

if ( "$1" != "" ) set port="$1"
if ( "$2" == "newlog" ) rm $basedir/log/* 

# Change to area directory.
cd $basedir/area

# Set limits.
nohup
nice
limit stack 2048k
limit coredumpsize unlimited
if ( -e shutdown.txt ) rm -f shutdown.txt

while ( 1 )
    cd $basedir/area

    # If you want to have logs in a different directory,
    #   change the 'set logfile' line to reflect the directory name.
    set index = 1000
    while ( 1 )
	set logfile = $basedir/log/$index.log
	if ( ! -e $logfile ) break
	@ index++
    end

    # Record starting time
    date > $logfile
    date > $basedir/area/boot.txt

    # Record initial charges
    # charges >> $logfile

    # cd $basedir/src/utils
    # ./grux >&! $logfile
    # cd $basedir/area

    # Run SMAUG.
    $basedir/src/rmexe $port >>&! $logfile

    # Record ending charges
    # charges >> $logfile

    # Restart, giving old connections a chance to die.

    if ( -e $basedir/area/shutdown.txt ) then
	echo "Script killed!" > $basedir/area/bootlog
	cat $basedir/area/shutdown.txt > $basedir/area/bootlog
	/usr/lib/sendmail $email < $basedir/area/bootlog
	rm -f $basedir/area/bootlog
	cp $basedir/area/shutdown.txt $basedir/area/shutdown.last
	rm -f $basedir/area/shutdown.txt
	exit 0
    endif
    sleep 5
end