This commit is contained in:
Enno Rehling 2017-12-04 20:01:35 +01:00
commit 7867eb6962
9 changed files with 54 additions and 51 deletions

View File

@ -14,6 +14,7 @@ addons:
- libxml2-dev
- valgrind
- cppcheck
- shellcheck
os:
- linux
notifications:

6
process/Makefile Normal file
View File

@ -0,0 +1,6 @@
SCRIPTS=compress.sh send-bz2-report send-zip-report create-orders \
run-turn sendreports.sh
IGNORE=sendreport.sh
shellcheck: $(SCRIPTS)
shellcheck $(SCRIPTS)

View File

@ -1,24 +1,25 @@
#!/bin/bash
if [ -z $ERESSEA ]; then
if [ -z "$ERESSEA" ]; then
echo "You need to define the \$ERESSEA environment variable to run $0"
exit -2
fi
GAME=$ERESSEA/game-$1
GAME_NAME=$(grep -w name $GAME/eressea.ini | sed 's/.*=\s*//')
GAME="$ERESSEA/game-$1"
GAME_NAME=$(grep -w name "$GAME/eressea.ini" | sed 's/.*=\s*//')
TURN=$2
if [ -z $TURN ]
if [ -z "$TURN" ]
then
TURN=`cat $GAME/turn`
TURN=$(cat "$GAME/turn")
fi
if [ ! -d $GAME/reports ]; then
if [ ! -d "$GAME/reports" ]; then
echo "cannot find reports directory in $GAME"
exit -1
fi
cd $GAME/reports
$ERESSEA/server/bin/compress.py $TURN "$GAME_NAME"
cd -
cd "$GAME/reports" || exit
"$ERESSEA/server/bin/compress.py" "$TURN" "$GAME_NAME"
cd - || exit

View File

@ -3,26 +3,25 @@
GAME=$1
TURN=$2
if [ ! -d $ERESSEA/game-$GAME ] ; then
if [ ! -d "$ERESSEA/game-$GAME" ] ; then
echo "No such game: $GAME"
exit 1
fi
cd $ERESSEA/game-$GAME
cd "$ERESSEA/game-$GAME" || exit
if [ -d orders.dir.$TURN ]; then
if [ -d "orders.dir.$TURN" ]; then
echo "orders.dir.$TURN already exists"
else
mv orders.dir orders.dir.$TURN
mv orders.dir "orders.dir.$TURN"
mkdir -p orders.dir
fi
ls -1rt orders.dir.$TURN/turn-* | xargs cat > orders.$TURN
ls -1rt "orders.dir.$TURN/turn-*" | xargs cat > "orders.$TURN"
lockfile -r3 -l120 orders.queue.lock
if [ -e orders.queue ] ; then
mv orders.queue orders.dir.$TURN/orders.queue
mv orders.queue "orders.dir.$TURN/orders.queue"
fi
rm -f orders.queue.lock
fi

View File

@ -1,17 +1,17 @@
#!/bin/sh
GAME=$1
TURN=$2
GAME="$1"
TURN="$2"
if [ ! -d $ERESSEA/game-$GAME ] ; then
if [ ! -d "$ERESSEA/game-$GAME" ] ; then
echo "No such game: $GAME"
exit 1
fi
cd $ERESSEA/game-$GAME
cd "$ERESSEA/game-$GAME" || exit
echo "running turn $TURN, game $GAME"
$ERESSEA/server/bin/eressea -v3 -t $TURN run-turn.lua
"$ERESSEA/server/bin/eressea" -v3 -t "$TURN" run-turn.lua
mkdir -p log
ln -f eressea.log log/eressea.log.$TURN
ln -f eressea.log "log/eressea.log.$TURN"

View File

@ -1,13 +1,12 @@
#!/bin/bash
if [ -z $ERESSEA ]; then
ERESSEA=`echo $PWD |sed -e 's/\/game.*//'`
if [ -z "$ERESSEA" ]; then
ERESSEA=$(echo "$PWD" |sed -e 's/\/game.*//')
echo "Assuming that ERESSEA=$ERESSEA"
fi
if [ ! -f reports.txt ]; then
echo "need to run $0 from the report direcory"
exit -2
fi
source $HOME/bin/functions.sh
TEMPLATE=report-mail.txt
if [ "$1" == "-Lde" ]
@ -26,4 +25,6 @@ addr=$1
subj=$2
shift 2
cat $ERESSEA/server/etc/$TEMPLATE | mutt -F $ERESSEA/etc/muttrc -s "$subj" -a $* -- $addr
mutt -F "$ERESSEA/etc/muttrc" -s "$subj" -a "$@" -- "$addr" \
< "$ERESSEA/server/etc/$TEMPLATE"

View File

@ -1,6 +1,7 @@
#!/bin/bash
if [ -z $ERESSEA ]; then
ERESSEA=`echo $PWD |sed -e 's/\/game.*//'`
if [ -z "$ERESSEA" ]; then
ERESSEA=$(echo "$PWD" |sed -e 's/\/game.*//')
echo "Assuming that ERESSEA=$ERESSEA"
fi
if [ ! -f reports.txt ]; then
@ -9,7 +10,7 @@ if [ ! -f reports.txt ]; then
fi
PWD=$(pwd)
GAME=$(dirname $PWD)
GAME=$(dirname "$PWD")
TEMPLATE=report-mail.txt
if [ "$1" == "-Lde" ]
@ -24,13 +25,13 @@ then
shift
fi
if [ -e $GAME/$TEMPLATE ]; then
TEMPLATE=$GAME/$TEMPLATE
if [ -e "$GAME/$TEMPLATE" ]; then
TEMPLATE="$GAME/$TEMPLATE"
else
TEMPLATE=$ERESSEA/server/etc/$TEMPLATE
TEMPLATE="$ERESSEA/server/etc/$TEMPLATE"
fi
if [ ! -e $TEMPLATE ]; then
if [ ! -e "$TEMPLATE" ]; then
echo "no such email template: $TEMPLATE"
exit -3
fi
@ -42,8 +43,7 @@ done
addr=$1
subject=$2
shift 2
mutt -F $ERESSEA/etc/muttrc -s "$subject" -a $* -- $addr < $TEMPLATE
if [ $? -ne 0 ] ; then
echo "Sending failed for email/report: $2/$3"
fi
mutt -F "$ERESSEA/etc/muttrc" -s "$subject" -a "$@" -- "$addr" \
< "$TEMPLATE" || echo "Sending failed for email/report: $2/$3"

View File

@ -3,30 +3,23 @@
##
## Prepare the report
if [ -z $ERESSEA ]; then
if [ -z "$ERESSEA" ]; then
echo "You have to define the \$ERESSEA environment variable to run $0"
exit -2
fi
source $HOME/bin/functions.sh
if [ ! -z $1 ]; then
GAME=$ERESSEA/game-$1
if [ ! -z "$1" ]; then
GAME="$ERESSEA/game-$1"
else
GAME=$ERESSEA
fi
cd $GAME/reports || abort "could not chdir to reports directory"
cd "$GAME/reports" || exit
for REPORT in *.sh
do
echo -n "Sending "
basename $REPORT .sh
bash $REPORT
basename "$REPORT" .sh
bash "$REPORT"
done
cd -
if [ -e $GAME/ages.sh ]; then
cd $GAME
./ages.sh
cd -
fi
cd - || exit

View File

@ -26,4 +26,6 @@ cppcheck --version
cppcheck --quiet --error-exitcode=1 src
s/runtests -V
integration_tests
cd ../process
make