server/process/create-orders
2017-12-06 20:10:16 +01:00

28 lines
523 B
Bash
Executable file

#!/bin/bash
GAME=$1
TURN=$2
if [ ! -d "$ERESSEA/game-$GAME" ] ; then
echo "No such game: $GAME"
exit 1
fi
cd "$ERESSEA/game-$GAME" || exit
if [ -d "orders.dir.$TURN" ]; then
echo "orders.dir.$TURN already exists"
else
mv orders.dir "orders.dir.$TURN"
mkdir -p orders.dir
fi
#shellcheck disable=2011
ls -1rt "orders.dir.$TURN/turn-*" | xargs cat > "orders.$TURN"
lockfile -r3 -l120 orders.queue.lock
if [ -e orders.queue ] ; then
mv orders.queue "orders.dir.$TURN/orders.queue"
fi
rm -f orders.queue.lock