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

This commit is contained in:
Enno Rehling 2017-09-15 19:58:22 +02:00
parent 1413c2807d
commit f83c3a9e9f
1 changed files with 11 additions and 0 deletions

View File

@ -1,3 +1,5 @@
#!/bin/bash
GAME=$1 GAME=$1
TURN=$2 TURN=$2
@ -7,6 +9,7 @@ if [ ! -d $ERESSEA/game-$GAME ] ; then
fi fi
cd $ERESSEA/game-$GAME cd $ERESSEA/game-$GAME
if [ -d orders.dir.$TURN ]; then if [ -d orders.dir.$TURN ]; then
echo "orders.dir.$TURN already exists" echo "orders.dir.$TURN already exists"
else else
@ -14,3 +17,11 @@ else
mkdir -p orders.dir mkdir -p orders.dir
fi fi
ls -1rt orders.dir.$TURN/turn-* | xargs cat > orders.$TURN 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