server/process/create-orders

30 lines
493 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
lockfile -r3 -l120 orders.queue.lock
if [ -d "orders.dir.$TURN" ]; then
echo "orders.dir.$TURN already exists"
exit
fi
rm -f "orders.$TURN"
cd orders.dir || exit
php ../../orders-php/cli.php -d "orders.db" export | tr -d '\r' > "../orders.$TURN"
cd .. || exit
mv orders.dir "orders.dir.$TURN"
mkdir -p orders.dir
rm -f orders.queue.lock