From c3d08d153679fe9330c7aeae886822a958f1b15d Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 11 Jun 2018 21:00:01 +0200 Subject: [PATCH 1/3] redirect cron output to a logfile --- process/cron/preview.cron | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/process/cron/preview.cron b/process/cron/preview.cron index 71ebd0571..eb39fd8f8 100755 --- a/process/cron/preview.cron +++ b/process/cron/preview.cron @@ -1,5 +1,5 @@ #!/bin/bash - +( [ "$PREVIEW" != "yes" ] && exit [ -z ${ERESSEA} ] && ERESSEA=$HOME/eressea @@ -13,3 +13,5 @@ for game in 2 3 4 ; do ${SRC}/s/preview -g ${game} run && \ ${SRC}/s/preview -g ${game} send done +) | tee -a $HOME/log/preview.cron.log + From 8af4b1fe292a0fca7cca3512e904b63ac83473ec Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 7 Jul 2018 10:45:11 +0200 Subject: [PATCH 2/3] pipe cron output to logfile, fix sendreport script --- process/Makefile | 3 +-- process/cron/run-eressea.cron | 4 +++- process/functions.sh | 10 -------- process/sendreport.sh | 45 ++++++++++++++++++++--------------- 4 files changed, 30 insertions(+), 32 deletions(-) delete mode 100644 process/functions.sh diff --git a/process/Makefile b/process/Makefile index 8edfed0b8..0d84bdae2 100644 --- a/process/Makefile +++ b/process/Makefile @@ -1,6 +1,5 @@ SCRIPTS=compress.sh send-bz2-report send-zip-report create-orders \ -run-turn sendreports.sh -IGNORE=sendreport.sh +run-turn sendreports.sh sendreport.sh shellcheck: $(SCRIPTS) shellcheck $(SCRIPTS) diff --git a/process/cron/run-eressea.cron b/process/cron/run-eressea.cron index 4ea38184c..ecd4c6b11 100755 --- a/process/cron/run-eressea.cron +++ b/process/cron/run-eressea.cron @@ -1,6 +1,6 @@ #!/bin/bash GAME=$1 - +( [ "$ENABLED" != "yes" ] && exit [ -z ${ERESSEA} ] && ERESSEA=$HOME/eressea @@ -58,3 +58,5 @@ $BIN/compress.sh $GAME $TURN $BIN/sendreports.sh $GAME $BIN/backup-eressea $GAME $TURN rm -f test/execute.lock +) | tee -a $HOME/log/eressea.cron.log + diff --git a/process/functions.sh b/process/functions.sh deleted file mode 100644 index 859fd302a..000000000 --- a/process/functions.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -PATH=$ERESSEA/bin:$PATH - -function abort() { - if [ $# -gt 0 ]; then - echo $@ - fi - exit -1 -} diff --git a/process/sendreport.sh b/process/sendreport.sh index be643ef56..d98ed505e 100755 --- a/process/sendreport.sh +++ b/process/sendreport.sh @@ -1,11 +1,17 @@ #!/bin/bash -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 + +function abort() { + if [ $# -gt 0 ]; then + echo "$@" + fi + exit -1 +} GAME=$1 EMAIL=$2 @@ -14,32 +20,33 @@ PASSWD=$4 #echo "$GAME $EMAIL $FACTION $PASSWD" >> /tmp/report.log function reply() { - echo $@ | mutt -s "Reportnachforderung Partei ${FACTION}" $EMAIL - abort $@ + echo "$@" | mutt -s "Reportnachforderung Partei ${FACTION}" "$EMAIL" + abort "$@" } -LOCKFILE=$ERESSEA/.report.lock -[ -e $LOCKFILE ] && reply "lockfile exists. wait for mail delivery to finish." +LOCKFILE="$ERESSEA/.report.lock" +[ -e "$LOCKFILE" ] && reply "lockfile exists. wait for mail delivery to finish." -REPLYTO='accounts@eressea.de' +echo "$(date):report:$GAME:$EMAIL:$FACTION:$PASSWD" >> "$ERESSEA/request.log" -echo `date`:report:$GAME:$EMAIL:$FACTION:$PASSWD >> $ERESSEA/request.log +cd "$ERESSEA" || exit +checkpasswd.py "game-$GAME/passwd" "$FACTION" "$PASSWD" || reply "Das Passwort fuer die Partei $FACTION ist ungueltig" -cd $ERESSEA -checkpasswd.py game-$GAME/passwd $FACTION $PASSWD || reply "Das Passwort fuer die Partei $FACTION ist ungueltig" - -cd $ERESSEA/game-$GAME/reports -if [ ! -e ${FACTION}.sh ]; then +cd "$ERESSEA/game-$GAME/reports" || exit +if [ ! -e "${FACTION}.sh" ]; then echo "Der Report für Partei $FACTION kann wegen technischer Probleme leider nicht nachgefordert werden: No such file ${FACTION}.sh" \ - | mutt -s "Reportnachforderung Partei ${FACTION}" $EMAIL + | mutt -s "Reportnachforderung Partei ${FACTION}" "$EMAIL" exit fi -source ${FACTION}.sh $EMAIL || reply "Unbekannte Partei $FACTION" +bash "${FACTION}.sh" "$EMAIL" || reply "Unbekannte Partei $FACTION" -if [ -e $ERESSEA/game-$GAME/eressea.db ]; then +if [ -e "$ERESSEA/game-$GAME/eressea.db" ]; then SQL="select email from faction f left join faction_data fd on fd.faction_id=f.id where f.game_id=$GAME AND fd.code='$FACTION' and fd.turn=(select max(turn) from faction_data fx where fx.faction_id=f.id)" - OWNER=$(sqlite3 $ERESSEA/game-$GAME/eressea.db "$SQL") - echo "Der Report Deiner Partei wurde an ${EMAIL} gesandt." \ - | mutt -s "Reportnachforderung Partei ${FACTION}" $OWNER + OWNER=$(sqlite3 "$ERESSEA/game-$GAME/eressea.db" "$SQL") + if [ ! -z "$OWNER" ]; then + echo "Der Report Deiner Partei wurde an ${EMAIL} gesandt." \ + | mutt -s "Reportnachforderung Partei ${FACTION}" "$OWNER" + fi fi + From 64eb545b4a864f2be65f03c5590f57ecb7784b0f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 12 Jul 2018 20:24:23 +0200 Subject: [PATCH 3/3] Bug 2460: Startgeschenke --- scripts/eressea/equipment.lua | 15 +++++++++++---- scripts/tests/config.lua | 16 ++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/scripts/eressea/equipment.lua b/scripts/eressea/equipment.lua index 6e4ccfc9b..8852dfb27 100644 --- a/scripts/eressea/equipment.lua +++ b/scripts/eressea/equipment.lua @@ -1,13 +1,20 @@ --- forward declaration required: - +-- forward declarations required: local self = {} + +local function equip_first(u) + equip_newunits(u) + name = 'seed_' .. u.race + equip_unit(u, name, 255) +end + local mysets = { ['first_unit'] = { ['items'] = { ['money'] = 2500, ['log'] = 10, ['stone'] = 4 - } + }, + ['callback'] = equip_first }, ['seed_unit'] = { ['items'] = { @@ -75,7 +82,7 @@ local mysets = { }, ['seed_insect'] = { ['items'] = { - ['nestwarmth'] =9 + ['nestwarmth'] = 9 } }, ['seed_halfling'] = { diff --git a/scripts/tests/config.lua b/scripts/tests/config.lua index a3104a6b6..316a8ccca 100644 --- a/scripts/tests/config.lua +++ b/scripts/tests/config.lua @@ -14,6 +14,22 @@ function test_read_race() assert_not_nil(f) end +function test_first_insect() + local f = faction.create('insect') + local r = region.create(0, 0, "plain") + local u = unit.create(f, r, 1) + u:equip('first_unit') + assert_equal(9, u:get_item('nestwarmth')) +end + +function test_first_troll() + local f = faction.create('troll') + local r = region.create(0, 0, "plain") + local u = unit.create(f, r, 1) + u:equip('first_unit') + assert_equal(2, u:eff_skill('perception')) +end + function test_seed_unit() local r = region.create(0, 0, "plain") local f = faction.create('human')