2014-05-10 22:33:46 +02:00
|
|
|
#!/bin/bash
|
2020-05-01 17:50:58 +02:00
|
|
|
|
2014-05-10 18:57:04 +02:00
|
|
|
GAME=$1
|
2018-07-07 10:45:11 +02:00
|
|
|
(
|
2020-06-27 17:30:24 +02:00
|
|
|
[ "$ENABLED" == "no" ] && exit
|
|
|
|
[ -z "$ERESSEA" ] && ERESSEA="$HOME/eressea"
|
2017-05-26 13:52:55 +02:00
|
|
|
|
|
|
|
export ERESSEA
|
2021-03-06 21:29:36 +01:00
|
|
|
eval "$(luarocks path)"
|
|
|
|
export LUA_PATH="${ERESSEA}/server/scripts/?.lua;$LUA_PATH"
|
2020-06-27 17:30:24 +02:00
|
|
|
BIN="$ERESSEA/server/bin"
|
|
|
|
TURN=$(cat "$ERESSEA/game-$GAME/turn")
|
|
|
|
if [ ! -e "$ERESSEA/game-$GAME/data/$TURN.dat" ]; then
|
2014-05-10 18:57:04 +02:00
|
|
|
echo "data file $TURN is missing, cannot run turn for game $GAME"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-06-27 17:30:24 +02:00
|
|
|
REPORTS="$ERESSEA/game-$GAME/reports"
|
|
|
|
if [ -d "$REPORTS" ]; then
|
|
|
|
rm -rf "$REPORTS"
|
2014-05-10 18:57:04 +02:00
|
|
|
fi
|
2020-06-27 17:30:24 +02:00
|
|
|
mkdir "$REPORTS"
|
2014-12-12 18:15:06 +01:00
|
|
|
|
2020-06-27 17:30:24 +02:00
|
|
|
cd "$ERESSEA/game-$GAME" || exit
|
2017-05-26 13:52:55 +02:00
|
|
|
|
2014-12-11 12:19:04 +01:00
|
|
|
if [ -d test ]; then
|
|
|
|
touch test/execute.lock
|
|
|
|
fi
|
2019-02-10 09:51:06 +01:00
|
|
|
|
2020-06-27 17:30:24 +02:00
|
|
|
"$BIN/create-orders" "$GAME" "$TURN"
|
|
|
|
if [ ! -s "$ERESSEA/game-$GAME/orders.$TURN" ]; then
|
2019-02-10 09:51:06 +01:00
|
|
|
echo "server did not create orders for turn $TURN in game $GAME"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2020-06-27 17:30:24 +02:00
|
|
|
"$BIN/backup-eressea" "$GAME" "$TURN"
|
2014-12-11 12:19:04 +01:00
|
|
|
rm -f execute.lock
|
2020-06-27 17:30:24 +02: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
|
|
|
|
2020-06-27 17:30:24 +02:00
|
|
|
if [ ! -s "$REPORTS/reports.txt" ]; then
|
2014-12-28 17:27:49 +01:00
|
|
|
echo "server did not create reports.txt in game $GAME"
|
|
|
|
exit 4
|
|
|
|
fi
|
2020-06-27 17:30:24 +02:00
|
|
|
"$BIN/backup-eressea" "$GAME" "$TURN"
|
2014-05-10 22:33:46 +02:00
|
|
|
let TURN=$TURN+1
|
2020-06-27 17:30:24 +02:00
|
|
|
if [ ! -s "$ERESSEA/game-$GAME/data/$TURN.dat" ]; then
|
2014-05-10 18:57:04 +02:00
|
|
|
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"
|
2020-06-27 17:30:24 +02:00
|
|
|
"$BIN/compress.sh" "$GAME" "$TURN"
|
|
|
|
"$BIN/sendreports.sh" "$GAME"
|
|
|
|
"$BIN/backup-eressea" "$GAME" "$TURN"
|
2014-12-11 12:19:04 +01:00
|
|
|
rm -f test/execute.lock
|
2020-06-27 17:30:24 +02:00
|
|
|
) | tee -a "$HOME/log/eressea.cron.log"
|
2018-07-07 10:45:11 +02:00
|
|
|
|