forked from github/server
31 lines
611 B
Bash
Executable file
31 lines
611 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
|
|
rm -f "orders.$TURN"
|
|
find "orders.dir.$TURN" -maxdepth 1 -name "turn-*" -type f -printf "%T+\t%p\n" | sort | cut -f2 | while read -r
|
|
do
|
|
tr -d '\r' < "$REPLY" >> "orders.$TURN"
|
|
done
|
|
|
|
lockfile -r3 -l120 orders.queue.lock
|
|
if [ -e orders.queue ] ; then
|
|
mv orders.queue "orders.queue.bak.$TURN"
|
|
fi
|
|
rm -f orders.queue.lock
|
|
|
|
|