From 4dfce302e6161fbea69235cdc0905f9c20dbd407 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch> Date: Mon, 22 Nov 2021 09:10:15 +0100 Subject: [PATCH] add filecheck if they are writable --- icinga-cli.sh | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/icinga-cli.sh b/icinga-cli.sh index 5748e41..ce521ba 100755 --- a/icinga-cli.sh +++ b/icinga-cli.sh @@ -14,7 +14,7 @@ _product="ICINGA PASSIVE CLIENT" -_version="0.5" +_version="0.6" _license="GNU GPL 3.0" _copyright='(c) 2020 Institute for Medical Education * University of Bern' @@ -113,7 +113,18 @@ function loopChecks(){ _log "---------- starting in a permanent loop" echo "Serviceloop started `date` - process id $$" > "${lockfile}" - _getFileSnapshot>$snapShotStart + if [ $? -ne 0 ]; then + _log "ABORT: Lock file is not writable ${lockfile}." + ls -l "${lockfile}" + exit 1 + fi + + _getFileSnapshot>${snapShotStart} + if [ $? -ne 0 ]; then + _log "ABORT: Snapshot file is not writable ${snapShotStart}." + ls -l "${snapShotStart}" + exit 1 + fi while true; do # typeset -i local iSleep=$(($RANDOM%$sleeptime)) # sleep minimum is half of $sleeptime @@ -123,6 +134,11 @@ function loopChecks(){ _log "______________________________________________________________________" _log "" _getFileSnapshot>$snapShotCurrent + if [ $? -ne 0 ]; then + _log "ABORT: Snapshot file is not writable ${snapShotCurrent}." + ls -l "${snapShotCurrent}" + exit 1 + fi diff $snapShotStart $snapShotCurrent >/dev/null if [ $? -ne 0 ]; then _log "ABORT: Files were updated / overwritten. The loop must be restarted.\n`diff $snapShotStart $snapShotCurrent`" -- GitLab