CVS/
sog/CVS/
sog/area/
sog/area/CVS/
sog/backup/
sog/backup/CVS/
sog/bin/
sog/bin/CVS/
sog/clans/CVS/
sog/clans/plists/
sog/clans/plists/CVS/
sog/classes/CVS/
sog/corefiles/
sog/corefiles/CVS/
sog/doc/CVS/
sog/doc/SoG/
sog/doc/SoG/CVS/
sog/doc/cvsup/
sog/doc/cvsup/CVS/
sog/doc/olc/CVS/
sog/etc/CVS/
sog/gods/
sog/gods/CVS/
sog/lang/CVS/
sog/log/
sog/log/CVS/
sog/notes/
sog/notes/CVS/
sog/player/
sog/player/CVS/
sog/races/CVS/
sog/src/CVS/
sog/src/comm/CVS/
sog/src/compat/
sog/src/compat/CVS/
sog/src/compat/mkdep/
sog/src/compat/mkdep/CVS/
sog/src/compat/regex-win32/CVS/
sog/src/db/CVS/
sog/src/mudprogs/CVS/
sog/src/olc/CVS/
sog/tmp/
sog/tmp/CVS/
#!/bin/sh
umask 002
port="-p 6666 -i 6667"
sog=`pwd`/sog
index=1000
cd ..

# Set limits.
if [ -e shutdown.txt ]; then
	rm -f shutdown.txt
fi

while [ 1 ]; do
	while [ 1 ]; do
		logfile=log/$index.log
		if [ -e $logfile ]; then
			index=`echo $index + 1 | bc`
		else
			break
		fi
	done

	$sog $port 2>&1 | tee $logfile
	exitcode=$?

	if [ -e sog.core ]; then
		mv sog.core corefiles/core.$index
	fi

	if [ -e shutdown.txt ]; then
		rm -f shutdown.txt
		exit 0
	fi

	if [ $exitcode -ne 0 ]; then
		exit 1
	fi
	sleep 15
done