#!/bin/sh
#
# This is a small helper script that restarts the server if it crashed
# and runs the server in a screen session. This script is only a sample.
# You probably have to modify it, when you plan to use it.

export CRYSTAL=/home/matzeb/CS
export CEL=/home/matzeb/cel
export CSCONFPATH=/home/matzeb/cel
LOG="$HOME/log.txt"

cd planeshift

#Allow Core files up to 80Meg size
ulimit -c 80000

#When server crashed restart it
echo "***Log Started :" > "$LOG"
date >> "$LOG"

while ! screen ./psserver $@; do
	echo "******Restarting server"
	echo "----ServerRestart" >> "$LOG"
	date >> "$LOG"
done

echo "***Log closed :" >> "$LOG"
date >> "$LOG"
