#!/bin/bash
#
# This is a startup script example you can adapt for your needs.
# It can take a server directory to start as argument else,
# it will use the current dir.
# If you want to use it, rename it to 'start.sh' and give it executable rights.
#
# If you want to start/stop the server as a system service you should not use this
# script. Please read the documentation for more informations.
#

serverdir="$1"
[ -z "$serverdir" ] && serverdir="$(pwd)"
if [ ! -e "$serverdir/nalc.conf" ]; then
	echo "ERROR: nalc.conf not found!"
	exit 1
else
	. "$serverdir/nalc.conf"
fi

#DEBUG=$serverdir/logs/debug.log
#MOREDEBUG=$serverdir/logs/moredebug.log

#while true; do
#        sleep 5
#        echo "----------------------" >>$MOREDEBUG
#        echo "Server restarted at "`date` >>$MOREDEBUG
#        echo "----------------------" >>$MOREDEBUG

echo "0" >/tmp/players_c.txt

"$MINETEST_BIN" \
	--world "$MINETEST_DIR/worlds/$WORLD_NAME/" \
	--config "$MINETEST_DIR/minetest.conf" \
	--gameid nalc_game \
	--port $PORT \
#	--logfile $DEBUG

#done &>> $MOREDEBUG