From 2b8451aefd8f1ddba2faaec08d50f17a17f137c6 Mon Sep 17 00:00:00 2001 From: Per Cederqvist <ceder@lysator.liu.se> Date: Tue, 7 Nov 2006 06:58:40 +0000 Subject: [PATCH] Fail if not allowed to manipulate the temporary files. Clean up all temporary files. --- check_lysrdiff | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/check_lysrdiff b/check_lysrdiff index d2eeaaf..9a2c497 100755 --- a/check_lysrdiff +++ b/check_lysrdiff @@ -62,7 +62,16 @@ state=$statecache-$partno find $BASE/lysrdiff/state -type f \ -printf "%TY-%Tm-%Td %TH:%TM:%TS %P\n" \ | sort > $statecache.$partno.$$ - mv -f $statecache.$partno.$$ $state +mv -f $statecache.$partno.$$ $state || { + echo UNKNOWN - mv failed + rm $statecache.$partno.$$ + exit 3 +} +rm -f $state-stale $state-active || { + echo UNKNOWN - rm failed + rm $state + exit 3 +} echo $staletime MARKER \ | sort $state - \ @@ -90,6 +99,8 @@ then END { if (sz >= 200) printf ", others" } ' \ |sed s'/, \([^,]*\)$/ and \1/' echo '. | activity='$ACTIVITY stale=$STALE failed=`grep -c -- '-fail$' $state` + rm $state $state-stale $state-active + exit 2 fi @@ -103,14 +114,17 @@ then END { if (sz >= 200) printf ", others" } ' \ |sed s'/, \([^,]*\)$/ and \1/' echo '. | activity='$ACTIVITY stale=$STALE failed=0 + rm $state $state-stale $state-active exit 2 fi if [ $ACTIVITY = 0 ] then echo -n 'WARNING - No activity. | activity='0 stale=$STALE failed=0 + rm $state $state-stale $state-active exit 1 fi echo 'OK - all ok. | activity='$ACTIVITY stale=0 failed=0 +rm $state $state-stale $state-active exit 0 -- GitLab