add scrip check release

This commit is contained in:
Quentin Gibeaux 2020-10-15 18:16:57 +02:00 committed by root
parent 1e097e17e6
commit 6a18b1944a

View File

@ -0,0 +1,33 @@
#!/bin/bash
#
# Nagios plugin to check mastodon version
#
# program return value
# 0 : OK
# 1 : CRITICAL
# 2 : WARNING new version available
# 3 : UNKNOWN github or local repo not probable
LAST_VERSION=$(curl --silent https://api.github.com/repos/tootsuite/mastodon/releases | jq -r '.[0].name')
INSTALLED_VERSION=$(git -C /home/mastodon/live/ branch | grep ^* | sed -e 's/.*live-//')
if [ -z "$LAST_VERSION" ]; then
echo "UNKNOWN : cannot get version from github."
exit 3
fi
if [ -z "$INSTALLED_VERSION" ]; then
echo "UNKNOWN : cannot get version from /home/mastodon/live"
exit 3
fi
if [ "$LAST_VERSION" = "$INSTALLED_VERSION" ]; then
echo "OK : Installed version is $INSTALLED_VERSION, last version is $LAST_VERSION"
exit 0
else
echo "WARNING : new version available, installed is $INSTALLED_VERSION, last is $LAST_VERSION."
exit 2
fi