2017-09-15 19:58:22 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
2015-01-11 01:23:47 +01:00
|
|
|
GAME=$1
|
|
|
|
TURN=$2
|
|
|
|
|
2017-12-03 17:30:41 +01:00
|
|
|
if [ ! -d "$ERESSEA/game-$GAME" ] ; then
|
2015-01-11 01:23:47 +01:00
|
|
|
echo "No such game: $GAME"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-12-03 17:30:41 +01:00
|
|
|
cd "$ERESSEA/game-$GAME" || exit
|
2017-09-15 19:58:22 +02:00
|
|
|
|
2017-12-03 17:30:41 +01:00
|
|
|
if [ -d "orders.dir.$TURN" ]; then
|
2015-01-11 01:23:47 +01:00
|
|
|
echo "orders.dir.$TURN already exists"
|
|
|
|
else
|
2017-12-03 17:30:41 +01:00
|
|
|
mv orders.dir "orders.dir.$TURN"
|
2015-01-11 01:23:47 +01:00
|
|
|
mkdir -p orders.dir
|
|
|
|
fi
|
2018-10-09 19:27:33 +02:00
|
|
|
rm -f "orders.$TURN"
|
2019-05-09 21:55:45 +02:00
|
|
|
find "orders.dir.$TURN" -maxdepth 1 -name "turn-*" -type f -printf "%T+\t%p\n" | sort | cut -f2 | while read -r
|
2017-12-16 19:39:56 +01:00
|
|
|
do
|
2018-12-03 21:05:48 +01:00
|
|
|
tr -d '\r' < "$REPLY" >> "orders.$TURN"
|
2017-12-16 19:39:56 +01:00
|
|
|
done
|
2017-09-15 19:58:22 +02:00
|
|
|
|
2017-09-15 19:59:42 +02:00
|
|
|
lockfile -r3 -l120 orders.queue.lock
|
2017-09-15 19:58:22 +02:00
|
|
|
if [ -e orders.queue ] ; then
|
2018-10-09 19:27:33 +02:00
|
|
|
mv orders.queue "orders.queue.bak.$TURN"
|
2017-09-15 19:59:42 +02:00
|
|
|
fi
|
|
|
|
rm -f orders.queue.lock
|
2017-09-15 19:58:22 +02:00
|
|
|
|
|
|
|
|