|
@@ -1,7 +1,9 @@
|
|
|
#!/bin/bash
|
|
|
|
|
|
-# Version 1.4
|
|
|
+# Version 1.5
|
|
|
#
|
|
|
+# v1.5 CHANGES:
|
|
|
+# - added enhancement sugestion made by briand on checkmk forum to make the version-compare more granular
|
|
|
# v1.4 CHANGES:
|
|
|
# - added extra logic to deal with unresponsive or empty response from release-url
|
|
|
# v1.3 CHANGES:
|
|
@@ -15,8 +17,11 @@
|
|
|
|
|
|
# Installation:
|
|
|
# This file should be place on a/the nextcloud host in /usr/lib/check_mk_agent/local
|
|
|
-# Also do not forget to make this file executable with chmod +x /usr/lib/check_mk_agent/local/nextcloud-updates.sh
|
|
|
#
|
|
|
+# (optional) if you want the check to run on a different schedule (like once per hour) put it in a subdirectory of above path
|
|
|
+# named to the number of seconds of the interval wanted, so 3600/ for once an hour, 86400 for once per day.
|
|
|
+#
|
|
|
+# Also do not forget to make this file executable with chmod +x /usr/lib/check_mk_agent/local/nextcloud-updates.sh
|
|
|
|
|
|
# (c) Michael Honkoop <mhonkoop@comsolve.nl>
|
|
|
|
|
@@ -32,6 +37,14 @@ BASEPATH="/var/www/html"
|
|
|
|
|
|
APACHEUSER="apache"
|
|
|
|
|
|
+# Set how exact the version-comparison should be - enhancement suggested by briand at checkmk forum
|
|
|
+#
|
|
|
+# how many “.”-separated fields to compare:
|
|
|
+# 3 → XX.YY.ZZ (full)
|
|
|
+# 2 → XX.YY (major+minor)
|
|
|
+# 1 → XX (major only)
|
|
|
+VERSION_FIELDS=2
|
|
|
+
|
|
|
######################
|
|
|
# The code below should not be changed, unless you know EXACTLY what you are doing.
|
|
|
# All confogureable parameters are above this section.
|
|
@@ -62,12 +75,12 @@ fi
|
|
|
# Get current installed Nextcloud version-information
|
|
|
# in v29.x.x version gives more detail, which is not given by the check on installed version, so switched to versionstring instead.
|
|
|
|
|
|
-NCINSTALLED=$(sudo -u $APACHEUSER php $BASEPATH/occ status --output=json | jq -r '.versionstring')
|
|
|
+NCINSTALLED=$(sudo -u $APACHEUSER php $BASEPATH/occ status --output=json | jq -r '.versionstring' | cut -d. -f1-"$VERSION_FIELDS")
|
|
|
|
|
|
# Get latest avaiable version information
|
|
|
# In v29.x.x this has changed outputs <name-of-instance> <version>,
|
|
|
|
|
|
-NCAVAILABLE=$(curl -s --connect-timeout 5 --fail-with-body $RELEASEURL | sed -e 's/<[^>]*>//g' | grep -o "^nextcloud.*.zip" | tail -n1 | cut -d'-' -f 2 | sed 's/.\{4\}$//')
|
|
|
+NCAVAILABLE=$(curl -s --connect-timeout 5 --fail-with-body $RELEASEURL | sed -e 's/<[^>]*>//g' | grep -o "^nextcloud.*.zip" | tail -n1 | cut -d'-' -f 2 | sed 's/.\{4\}$//' | cut -d. -f1-"$VERSION_FIELDS")
|
|
|
|
|
|
# if the check on the release-url is not returning a version - report status
|
|
|
if [ -z $NCAVAILABLE ]; then
|