pouet.chapril.org-tools/monitoring/check_tootsuite_mastodon_release.sh

36 lines
1.1 KiB
Bash
Raw Normal View History

2020-10-15 18:16:57 +02:00
#!/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
2020-12-01 11:14:06 +01:00
elif [[ $LAST_VERSION =~ rc[0-9]+$ ]]; then
echo "OK : Installed version is $INSTALLED_VERSION, last version is Release Candidate : $LAST_VERSION"
2020-10-15 18:16:57 +02:00
else
echo "WARNING : new version available, installed is $INSTALLED_VERSION, last is $LAST_VERSION."
exit 2
fi