#!/bin/bash

# exit codes of GameServer:
#  0 normal shutdown
#  2 reboot attempt

while :; do
	[ -f log/java0.log.0 ] && mv log/java0.log.0 "log/`date +%Y-%m-%d_%H-%M-%S`_java.log"
	[ -f log/stdout.log ] && mv log/stdout.log "log/`date +%Y-%m-%d_%H-%M-%S`_stdout.log"
	java -Xms1024m -Xmx1024m -cp ./lib/bsf.jar:./lib/bsh-2.0b4.jar:./lib/commons-logging-1.1.jar:./lib/javolution.jar:./lib/mmocore.jar:./lib/jython.jar:./lib/c3p0-0.9.1.2.jar:./lib/mysql-connector-java-5.0.7-bin.jar:./lib/l2jmack.jar net.sf.l2j.gameserver.GameServer > log/stdout.log 2>&1
	[ $? -ne 2 ] && break
#	/etc/init.d/mysql restart
	sleep 10
done
