|
@@ -0,0 +1,79 @@
|
|
|
|
+#!/bin/bash
|
|
|
|
+
|
|
|
|
+# (c) Michael Honkoop <mhonkoop@comsolve.nl>
|
|
|
|
+
|
|
|
|
+# License: GNU General Public License v2
|
|
|
|
+
|
|
|
|
+# Version 0.1 (initial release)
|
|
|
|
+#
|
|
|
|
+
|
|
|
|
+# Installation:
|
|
|
|
+# This file should be place on a/the nextcloud host in /usr/lib/check_mk_agent/local
|
|
|
|
+#
|
|
|
|
+# (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/direactadmin.sh
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+##########################################################################
|
|
|
|
+# Global definitions for the script - change if needed to fit your needs #
|
|
|
|
+##########################################################################
|
|
|
|
+
|
|
|
|
+# Custombuild switch , set to 1 if you are using it.
|
|
|
|
+CustomBuild=1
|
|
|
|
+
|
|
|
|
+#####################################################################
|
|
|
|
+# DO NOT CHANGE BELOW UNLESS YOU EXACTLY KNOW WHAT YOU ARE DOING #
|
|
|
|
+#####################################################################
|
|
|
|
+
|
|
|
|
+# Define global path of directAdmin
|
|
|
|
+if [ $CustomBuild -eq 1 ]
|
|
|
|
+then
|
|
|
|
+ DirAdmin_Path="/usr/local/directadmin/custombuild"
|
|
|
|
+else
|
|
|
|
+ DirAdmin_Path="/usr/local/directadmin"
|
|
|
|
+fi
|
|
|
|
+
|
|
|
|
+# Check DirectAdmin Core updates
|
|
|
|
+DirectAdmin_Core_Update=$($DirAdmin_Path/build update)
|
|
|
|
+if [[ $DirectAdmin_Core_Update == *"is already latest" ]]
|
|
|
|
+then
|
|
|
|
+ echo "0 \"DirectAdmin_Core\" - DirectAdmin core all up to date"
|
|
|
|
+else
|
|
|
|
+ echo "1 \"DirectAdmin_Core\" - DirectAdmin core has a newer version available - consider updating"
|
|
|
|
+fi
|
|
|
|
+
|
|
|
|
+# Check DirectAdmin Core updates
|
|
|
|
+DirectAdmin_Core_Update=$($DirAdmin_Path/build update)
|
|
|
|
+if [[ $DirectAdmin_Core_Update == *"is already latest" ]]
|
|
|
|
+then
|
|
|
|
+ echo "0 \"DirectAdmin_Core\" - DirectAdmin core all up to date"
|
|
|
|
+else
|
|
|
|
+ echo "1 \"DirectAdmin_Core\" - DirectAdmin core has a newer version available - consider updating"
|
|
|
|
+fi
|
|
|
|
+
|
|
|
|
+# store version information from DirectAdmin packages
|
|
|
|
+DirectAdmin_Versions_Update=$($DirAdmin_Path/build versions)
|
|
|
|
+#Define updates Array
|
|
|
|
+updates=()
|
|
|
|
+# iterate over the collected data to find possible updates
|
|
|
|
+while read -r line; do
|
|
|
|
+ if [[ $line =~ ^Latest\ version\ of\ (.+):\ (.+)$ ]]; then
|
|
|
|
+ component="${BASH_REMATCH[1]}"
|
|
|
|
+ latest="${BASH_REMATCH[2]}"
|
|
|
|
+ elif [[ $line =~ ^Installed\ version\ of\ (.+):\ (.+)$ ]]; then
|
|
|
|
+ installed="${BASH_REMATCH[2]}"
|
|
|
|
+
|
|
|
|
+ # Compare versions using sort -V
|
|
|
|
+ if [[ "$(printf '%s\n%s\n' "$installed" "$latest" | sort -V | head -n1)" != "$latest" ]]; then
|
|
|
|
+ updates+=("$component")
|
|
|
|
+ fi
|
|
|
|
+ fi
|
|
|
|
+done <<< "$DirectAdmin_Versions_Update"
|
|
|
|
+
|
|
|
|
+if [[ ${#updates[@]} -eq 0 ]]; then
|
|
|
|
+ echo "0 \"DirectAdmin\" - All DirectAdmin Versions are up to date"
|
|
|
|
+else
|
|
|
|
+ echo "1 \"DirectAdmin\" - DirectAdmin Versions ${updates[*]} have updates"
|
|
|
|
+fi
|