move orders.queue file (clever use of lockfile program)

This commit is contained in:
Enno Rehling 2017-09-15 19:58:22 +02:00 committed by Enno Rehling
parent 197fd48508
commit dc2663571c
1 changed files with 11 additions and 0 deletions

View File

@ -1,3 +1,5 @@
#!/bin/bash
GAME=$1
TURN=$2
@ -7,6 +9,7 @@ if [ ! -d $ERESSEA/game-$GAME ] ; then
fi
cd $ERESSEA/game-$GAME
if [ -d orders.dir.$TURN ]; then
echo "orders.dir.$TURN already exists"
else
@ -14,3 +17,11 @@ else
mkdir -p orders.dir
fi
ls -1rt orders.dir.$TURN/turn-* | xargs cat > orders.$TURN
if [ -e orders.queue ] ; then
lockfile -r3 -l120 orders.queue.lock
mv orders.queue orders.dir.$TURN/orders.queue
rm -f orders.queue.lock
fi