server/process/orders-accept

26 lines
563 B
Bash
Executable File

#!/bin/sh
# example: orders-accept 2 de < mail.txt
game="$1"
[ -z "$ERESSEA" ] && ERESSEA="$HOME/eressea"
SCRIPT=$(readlink -f "$0")
BIN=$(dirname "$SCRIPT")
LOCKFILE="$ERESSEA/game-$game/orders.queue.lock"
set -e
trap 'rm -f "$LOCKFILE"' EXIT
cd "$ERESSEA/game-$game"
mkdir -p orders.dir
cd orders.dir
lockfile -r3 -l120 "$LOCKFILE"
eval "$(python "$BIN/accept-orders.py" "$@")"
filename=$(basename "$ACCEPT_FILE")
email="$ACCEPT_MAIL"
if [ -d "$ERESSEA/orders-php" ]
then
php "$ERESSEA/orders-php/cli.php" insert "$filename" "$email"
fi
rm -f "$LOCKFILE"