]> git.pld-linux.org Git - packages/monitoring-plugin-check_file_exists.git/commitdiff
also check if file is folder
authorSimon Smit <Simon.johannes.smit@gmail.com>
Thu, 13 Jul 2017 09:44:08 +0000 (11:44 +0200)
committerElan Ruusamäe <glen@pld-linux.org>
Fri, 14 Jul 2017 17:15:14 +0000 (20:15 +0300)
check_file_exists.sh

index 35ac36367130175be71378dba77ceb69a965e238..77a0222f4537f87096f7bf08b835bf863d20f061 100755 (executable)
@@ -35,6 +35,11 @@ exists() {
        echo "$(state_name): $1 EXISTS :: `head -3 $1`" # shows the first three lines of the file
 }
 
+exists_dir() {
+    $negate && STATE=$STATE_CRITICAL || STATE=$STATE_OK
+    echo "$(state_name): $1 EXISTS :: Directory" # don't show the first three lines of the file
+}
+
 not_exists() {
        $negate && STATE=$STATE_OK || STATE=$STATE_CRITICAL
        echo "$(state_name): $1 Does NOT exist"
@@ -71,6 +76,8 @@ fi
 
 if [ -f "$1" ]; then
        exists "$1"
+elif [ -d "$1" ]; then
+    exists_dir "$1"
 else
        not_exists "$1"
 fi
This page took 0.091161 seconds and 4 git commands to generate.