/
clans/
councils/
deity/
doc/mudprogs/
exchange/
guilds/
player/a/
src/dmalloc/
src/dmalloc/bin/
src/dmalloc/include/
src/dmalloc/lib/
src/utils/
watch/
web/public_html/
#! /bin/csh -f

# Set the port number.
set port = 4050
set basedir = /home/ucmm/ucmm/
set email = "you@yourmud.com"

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 15
end