add a shellcheck test, fix some scripts

This commit is contained in:
Enno Rehling 2017-12-03 15:43:22 +01:00
parent c124702ffe
commit 4619f77af9
8 changed files with 46 additions and 41 deletions

View File

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

6
process/Makefile Normal file
View File

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

View File

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

View File

@ -1,17 +1,17 @@
#!/bin/sh #!/bin/sh
GAME=$1 GAME="$1"
TURN=$2 TURN="$2"
if [ ! -d $ERESSEA/game-$GAME ] ; then if [ ! -d "$ERESSEA/game-$GAME" ] ; then
echo "No such game: $GAME" echo "No such game: $GAME"
exit 1 exit 1
fi fi
cd $ERESSEA/game-$GAME cd "$ERESSEA/game-$GAME" || exit
echo "running turn $TURN, game $GAME" 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 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 #!/bin/bash
if [ -z $ERESSEA ]; then if [ -z "$ERESSEA" ]; then
ERESSEA=`echo $PWD |sed -e 's/\/game.*//'` ERESSEA=$(echo "$PWD" |sed -e 's/\/game.*//')
echo "Assuming that ERESSEA=$ERESSEA" echo "Assuming that ERESSEA=$ERESSEA"
fi fi
if [ ! -f reports.txt ]; then if [ ! -f reports.txt ]; then
echo "need to run $0 from the report direcory" echo "need to run $0 from the report direcory"
exit -2 exit -2
fi fi
source $HOME/bin/functions.sh
TEMPLATE=report-mail.txt TEMPLATE=report-mail.txt
if [ "$1" == "-Lde" ] if [ "$1" == "-Lde" ]
@ -26,4 +25,6 @@ addr=$1
subj=$2 subj=$2
shift 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 #!/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" echo "Assuming that ERESSEA=$ERESSEA"
fi fi
if [ ! -f reports.txt ]; then if [ ! -f reports.txt ]; then
@ -9,7 +10,7 @@ if [ ! -f reports.txt ]; then
fi fi
PWD=$(pwd) PWD=$(pwd)
GAME=$(dirname $PWD) GAME=$(dirname "$PWD")
TEMPLATE=report-mail.txt TEMPLATE=report-mail.txt
if [ "$1" == "-Lde" ] if [ "$1" == "-Lde" ]
@ -24,13 +25,13 @@ then
shift shift
fi fi
if [ -e $GAME/$TEMPLATE ]; then if [ -e "$GAME/$TEMPLATE" ]; then
TEMPLATE=$GAME/$TEMPLATE TEMPLATE="$GAME/$TEMPLATE"
else else
TEMPLATE=$ERESSEA/server/etc/$TEMPLATE TEMPLATE="$ERESSEA/server/etc/$TEMPLATE"
fi fi
if [ ! -e $TEMPLATE ]; then if [ ! -e "$TEMPLATE" ]; then
echo "no such email template: $TEMPLATE" echo "no such email template: $TEMPLATE"
exit -3 exit -3
fi fi
@ -42,7 +43,7 @@ done
addr=$1 addr=$1
subject=$2 subject=$2
shift 2 shift 2
mutt -F $ERESSEA/etc/muttrc -s "$subject" -a $* -- $addr < $TEMPLATE mutt -F "$ERESSEA/etc/muttrc" -s "$subject" -a "$@" -- "$addr" < "$TEMPLATE"
if [ $? -ne 0 ] ; then if [ $? -ne 0 ] ; then
echo "Sending failed for email/report: $2/$3" echo "Sending failed for email/report: $2/$3"

View File

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

View File

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