#!/bin/bash

if [ -e world.lock ]; then
	echo Waiting for world backup...
	while [ -e world.lock ]; do sleep 1; done
fi

echo Starting snapshot...
../runas /usr/bin/java snapshot -server -jar versions/minecraft_server.1.8.1-pre1.jar nogui 2>&1

if [ ! -e world.lock ]; then
	echo Restarting in 5 seconds, press ctrl+C to abort, or any key to restart now.
	read -n 1 -t 5
fi

cp start.sh~ start.sh
exec $0
