From 3ce1bbc3ddd5840804161ab9a6c17f28c75e7a6a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20Vysko=C4=8Dil?= <vyskocilpavel@muni.cz>
Date: Wed, 6 Feb 2019 11:31:20 +0100
Subject: [PATCH] Added git_pull_check.sh

---
 README.md         |  7 +++++++
 git_pull_check.sh | 23 +++++++++++++++++++++++
 2 files changed, 30 insertions(+)
 create mode 100755 git_pull_check.sh

diff --git a/README.md b/README.md
index b35d988..cc9a4e9 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,13 @@
 ## List of Local scripts
 Local scripts are located in /usr/lib/check_mk/local/ 
 
+###  git_pull_check.sh
+* Attributes to be filled: 
+<pre>
+# List of paths to check separated by space
+paths=""
+</pre>
+
 
 ## List of plugins
 Local scripts are located in /usr/lib/check_mk/plugins/ 
\ No newline at end of file
diff --git a/git_pull_check.sh b/git_pull_check.sh
new file mode 100755
index 0000000..7b14a9d
--- /dev/null
+++ b/git_pull_check.sh
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+# List of paths to check separated by space
+paths=""
+
+for path in $paths
+do
+    if [[ -d $path ]]; then
+        cd $path
+        result=$(git fetch --dry-run 2>&1)
+        if [[ -n $result ]] ; then
+            status=1
+            statustxt="WARNING - There are available new commits"
+        else
+            status=0
+            statustxt="OK"
+        fi
+    else
+        status=2
+        statustxt="CRITICAL - Directory does not exist"
+    fi
+    echo "$status git_pull_check_dir=$path - $statustxt"
+done
-- 
GitLab