From 48141cfbf74dd43edc5fb57b3eab92e5140755ba Mon Sep 17 00:00:00 2001
From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch>
Date: Wed, 12 May 2021 15:27:26 +0200
Subject: [PATCH] icingacli - detect unreadable config or non writable output
 file

---
 icinga-cli.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/icinga-cli.sh b/icinga-cli.sh
index 4d4a782..fa23402 100755
--- a/icinga-cli.sh
+++ b/icinga-cli.sh
@@ -313,8 +313,8 @@ function processCheck(){
       # $myFullscript $myparams | tee $_outfile
       eval $myFullscript $myparams > $_outfile
       rc=$?
-      if [ $rc -ne 0 ]; then
-	echo "ERROR: unable to write file $_outfile. Maybe the setup is inclomplete or someone created a file as root."
+      if [ ! -w $_outfile ]; then
+	echo "ERROR: file $_outfile is not writable. Maybe the setup is inclomplete or someone created a file as root... just guessing."
 	ls -ld ${dir_data} $_outfile
 	exit 1
       fi
-- 
GitLab