2014-05-10 22:33:46 +02:00
|
|
|
#!/bin/bash
|
2014-05-10 18:57:04 +02:00
|
|
|
GAME=$1
|
2017-05-26 13:52:55 +02:00
|
|
|
|
|
|
|
[ "$ENABLED" != "yes" ] && exit
|
|
|
|
[ -z ${ERESSEA} ] && ERESSEA=$HOME/eressea
|
|
|
|
|
|
|
|
export ERESSEA
|
|
|
|
BIN=$ERESSEA/server/bin
|
2014-05-10 22:33:46 +02:00
|
|
|
TURN=$(cat $ERESSEA/game-$GAME/turn)
|
2014-05-10 18:57:04 +02:00
|
|
|
if [ ! -e $ERESSEA/game-$GAME/data/$TURN.dat ]; then
|
|
|
|
echo "data file $TURN is missing, cannot run turn for game $GAME"
|
|
|
|
exit 1
|
|
|
|
fi
|
2014-05-10 22:33:46 +02:00
|
|
|
REPORTS=$ERESSEA/game-$GAME/reports
|
2014-05-10 18:57:04 +02:00
|
|
|
if [ -d $REPORTS ]; then
|
|
|
|
rm -rf $REPORTS
|
|
|
|
fi
|
|
|
|
mkdir $REPORTS
|
2014-12-12 18:15:06 +01:00
|
|
|
|
|
|
|
cd $ERESSEA/game-$GAME
|
2017-05-26 13:52:55 +02:00
|
|
|
|
|
|
|
# wait for the queue lock to go away
|
|
|
|
maxt=5
|
|
|
|
to=5
|
|
|
|
while [ -e orders.queue.lock ] ; do
|
|
|
|
echo "waiting for orders to finish processing."
|
|
|
|
sleep $to
|
|
|
|
let to=$to+$to
|
|
|
|
let mast=$maxt-1
|
|
|
|
[ $maxt -lt 0 ] && break
|
|
|
|
done
|
|
|
|
|
2014-12-11 12:19:04 +01:00
|
|
|
if [ -d test ]; then
|
|
|
|
touch test/execute.lock
|
|
|
|
fi
|
2015-01-11 01:23:47 +01:00
|
|
|
$BIN/create-orders $GAME $TURN
|
|
|
|
$BIN/backup-eressea $GAME $TURN
|
2014-12-11 12:19:04 +01:00
|
|
|
rm -f execute.lock
|
2015-01-11 01:23:47 +01:00
|
|
|
$BIN/run-turn $GAME $TURN
|
2014-12-11 12:19:04 +01:00
|
|
|
touch execute.lock
|
2014-12-12 18:15:06 +01:00
|
|
|
|
2014-05-10 18:57:04 +02:00
|
|
|
if [ ! -s $ERESSEA/game-$GAME/orders.$TURN ]; then
|
|
|
|
echo "server did not create orders for turn $TURN in game $GAME"
|
|
|
|
exit 2
|
|
|
|
fi
|
2014-12-28 17:27:49 +01:00
|
|
|
if [ ! -s $REPORTS/reports.txt ]; then
|
|
|
|
echo "server did not create reports.txt in game $GAME"
|
|
|
|
exit 4
|
|
|
|
fi
|
|
|
|
$BIN/backup-eressea $GAME $TURN
|
2014-05-10 22:33:46 +02:00
|
|
|
let TURN=$TURN+1
|
2014-05-10 18:57:04 +02:00
|
|
|
if [ ! -s $ERESSEA/game-$GAME/data/$TURN.dat ]; then
|
|
|
|
echo "server did not create data for turn $TURN in game $GAME"
|
|
|
|
exit 3
|
|
|
|
fi
|
2014-12-28 17:27:49 +01:00
|
|
|
echo "sending reports for game $GAME, turn $TURN"
|
2014-05-10 18:57:04 +02:00
|
|
|
$BIN/compress.sh $GAME $TURN
|
2015-02-08 14:01:22 +01:00
|
|
|
$BIN/sendreports.sh $GAME
|
2014-12-11 13:02:20 +01:00
|
|
|
$BIN/backup-eressea $GAME $TURN
|
2014-12-11 12:19:04 +01:00
|
|
|
rm -f test/execute.lock
|