#! /bin/csh -f
# Set the port number.
set port = 4200
set basedir = /home/ucmm2/CM-Dev/cm3
set email = "ucmm@localhost"
if ( "$1" != "" ) set port="$1"
if ( "$2" == "newlog" ) rm $basedir/log/*
# Change to area directory.
cd $basedir/area
# Set limits.
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
#cd $basedir/src/utils
#./grux >&! $logfile
cd $basedir/area
# Run SMAUG.
$basedir/src/rmexe $port >>&! $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
mail -s "Port $port Rebooted" $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
echo Crashed... Rebooting. > $basedir/area/bootlog
date >> $basedir/area/bootlog
mail -s "Port $port Crashed... Rebooting" $email < $basedir/area/bootlog
rm -f $basedir/area/bootlog
end