Forráskód Böngészése

Correcting messed up copy/paste formatting

Michael Honkoop 2 hete
szülő
commit
28350d58fc
1 módosított fájl, 14 hozzáadás és 12 törlés
  1. 14 12
      localchecks/gogs-version.sh

+ 14 - 12
localchecks/gogs-version.sh

@@ -1,12 +1,14 @@
+#!/bin/bash
+
 # Version 0.1 - initial start of this localcheck
 
 # Installation
-# This file should be place on a/the Gogs (https://gogs.io) host in /usr/lib/che                                                          ck_mk_agent/local
+# This file should be place on a/the Gogs (https://gogs.io) 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 ho                                                          ur, 86400/ for once per day.
+# (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_m                                                          k_agent/local/gogs-version.sh
+# Also do not forget to make this file executable with chmod +x /usr/lib/check_mk_agent/local/gogs-version.sh
 
 # (c) Michael Honkoop <mhonkoop@comsolve.nl>
 
@@ -29,25 +31,25 @@ GOGS_BIN="${BASEPATH}/gogs"
 SERVICE="Gogs"
 
 ######################
-# The code below should not be changed, unless you know EXACTLY what you are doi                                                          ng.
+# The code below should not be changed, unless you know EXACTLY what you are doing.
 # All configureable parameters are above this section.
 ######################
 
 # check if jq package is present on the system (required for this check)
 command -v jq >/dev/null 2>&1
 if [ $? -ne 0 ]; then
-    echo "2 \"$SERVICE\" - $SERVICE localcheck requires jq package to be install                                                          ed"
+    echo "2 \"$SERVICE\" - $SERVICE localcheck requires jq package to be installed"
     exit 0
 fi
 
 # Check Gogs binary presence and report if not found
 if [[ ! -x "$GOGS_BIN" ]]; then
-    echo "2 \"$SERVICE\" - Gogs executable not found: $GOGS_BIN check localcheck                                                           configuration."
+    echo "2 \"$SERVICE\" - Gogs executable not found: $GOGS_BIN check localcheck configuration."
     exit 0
 fi
 
 # Get current installed Gogs version-information
-GOGS_INSTALLED=$("$GOGS_BIN" --version | sed -nE 's/.*version ([0-9]+\.[0-9]+\.[                                                          0-9]+).*/\1/p')
+GOGS_INSTALLED=$("$GOGS_BIN" --version | sed -nE 's/.*version ([0-9]+\.[0-9]+\.[0-9]+).*/\1/p')
 
 if [[ -z "$GOGS_INSTALLED" ]]; then
     echo "3 \"$SERVICE\" - Gogs executable found, but returned no valid version"
@@ -55,18 +57,18 @@ if [[ -z "$GOGS_INSTALLED" ]]; then
 fi
 
 # Get latest avaiable version information.
-GOGS_AVAILABLE=$(curl -fsSL -H 'Accept: application/vnd.github+json' "$RELEASEUR                                                          L" | jq -er 'map(select(.draft == false and .prerelease == false)) | .[0].tag_na                                                          me' | sed 's/^v//')
+GOGS_AVAILABLE=$(curl -fsSL -H 'Accept: application/vnd.github+json' "$RELEASEURL" | jq -er 'map(select(.draft == false and .prerelease == false)) | .[0].tag_name' | sed 's/^v//')
 
 # Return status when latest version information could not be retrieved.
 if [[ -z "$GOGS_AVAILABLE" || "$GOGS_AVAILABLE" == "null" ]]; then
-    echo "1 \"$SERVICE\" - No data received from release-URL, can not determine                                                           latest release-version."
+    echo "1 \"$SERVICE\" - No data received from release-URL, can not determine latest release-version."
     exit 0
 fi
 
 # Compare installed version to available version
 if [[ "$GOGS_INSTALLED" == "$GOGS_AVAILABLE" ]]; then
     echo "0 \"$SERVICE\" - Gogs version $GOGS_INSTALLED is up to date."
-elif [[ "$(printf '%s\n' "$GOGS_INSTALLED" "$GOGS_AVAILABLE" | sort -V | tail -n                                                          1)" == "$GOGS_AVAILABLE" ]]; then
+elif [[ "$(printf '%s\n' "$GOGS_INSTALLED" "$GOGS_AVAILABLE" | sort -V | tail -n1)" == "$GOGS_AVAILABLE" ]]; then
     echo "1 \"$SERVICE\" - Update available: $GOGS_INSTALLED -> $GOGS_AVAILABLE"
     exit 0
-fi
+fi