1
0
Fork 0
scripts-admin-quickndirty-p.../nagios/check_gitea_version.sh
Chl 9da2d8701e check_gitea: small enhancement
We really should use a HTML parser but I like the monitoring probes
to be as light on dependencies as possible.
2020-01-09 22:03:35 +01:00

20 lines
706 B
Bash
Executable file

#!/bin/sh
# Quick and dirty NRPE script to check if
# the local version of Gitea is up to date.
# Stop at first uncatched error
set -e
# note: some local problems with IPv4, the quickest way was to force IPv6.
LOCAL_VERSION="$( wget -6 -O - -q "https://$( hostname -f )/api/v1/version" | sed -n 's/{"version":"\([^"]\+\)"}/\1/p' )"
UPSTREAM_VERSION="$( wget -q -O - "https://dl.gitea.io/gitea/" | egrep -o -- '<a href="/gitea/[0-9]+\.[0-9]+\.[0-9]+/"' | egrep -o "[0-9]+\.[0-9]+\.[0-9]+" | sort --version-sort | tail -n 1 )"
if [ "$UPSTREAM_VERSION" = "$LOCAL_VERSION" ]; then
echo "OK ($LOCAL_VERSION / $UPSTREAM_VERSION)"
exit 0
else
echo "WARNING ($LOCAL_VERSION / $UPSTREAM_VERSION)"
exit 1
fi