From e5d53769df025be750b53924957161f0f840a34b Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Thu, 11 Dec 2014 12:19:04 +0100 Subject: [PATCH] lock files to prevent accidents. preview will only run if the turn worked out. cannot accidentally run in the game directory. --- process/cron/run-eressea | 6 ++++++ scripts/run-turn.lua | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/process/cron/run-eressea b/process/cron/run-eressea index cc33f8f1e..21de5ee09 100755 --- a/process/cron/run-eressea +++ b/process/cron/run-eressea @@ -13,7 +13,12 @@ if [ -d $REPORTS ]; then fi mkdir $REPORTS $BIN/backup-eressea $GAME +if [ -d test ]; then + touch test/execute.lock +fi +rm -f execute.lock $BIN/run-turn $GAME +touch execute.lock if [ ! -s $ERESSEA/game-$GAME/orders.$TURN ]; then echo "server did not create orders for turn $TURN in game $GAME" exit 2 @@ -31,3 +36,4 @@ $BIN/compress.sh $GAME $TURN $BIN/sendreports.sh $GAME $BIN/backup-eressea $GAME [ $GAME -lt 4 ] && $BIN/send-summary $GAME +rm -f test/execute.lock diff --git a/scripts/run-turn.lua b/scripts/run-turn.lua index f938c8514..46095f216 100644 --- a/scripts/run-turn.lua +++ b/scripts/run-turn.lua @@ -182,6 +182,16 @@ function run_turn(rules) return result end +function file_exists(name) + local f=io.open(name,"r") + if f~=nil then io.close(f) return true else return false end +end + +if file_exists('execute.lock') then + eressea.log.error("Lockfile exists, aborting.") + assert(false) +end + local path = 'scripts' if config.install then path = config.install .. '/' .. path