server/process/create-orders

31 lines
573 B
Plaintext
Raw Normal View History

#!/bin/bash
GAME=$1
TURN=$2
2017-12-03 17:30:41 +01:00
if [ ! -d "$ERESSEA/game-$GAME" ] ; then
echo "No such game: $GAME"
exit 1
fi
2017-12-03 17:30:41 +01:00
cd "$ERESSEA/game-$GAME" || exit
2017-12-03 17:30:41 +01:00
if [ -d "orders.dir.$TURN" ]; then
echo "orders.dir.$TURN already exists"
else
2017-12-03 17:30:41 +01:00
mv orders.dir "orders.dir.$TURN"
mkdir -p orders.dir
fi
2017-12-16 21:16:51 +01:00
find "orders.dir.$TURN" -maxdepth 1 -type f -printf "%T+\t%p\n" | sort | cut -f2 | while read -r
do
2017-12-16 21:16:51 +01:00
cat "$REPLY" >> "orders.$TURN"
done
2017-09-15 19:59:42 +02:00
lockfile -r3 -l120 orders.queue.lock
if [ -e orders.queue ] ; then
2017-12-03 17:30:41 +01:00
mv orders.queue "orders.dir.$TURN/orders.queue"
2017-09-15 19:59:42 +02:00
fi
rm -f orders.queue.lock