pouet.chapril.org-tools/monitoring/check_tootsuite_mastodon_re...

36 lines
1.2 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
2023-03-03 15:48:33 +01:00
LAST_VERSION=$(curl -L --silent https://api.github.com/repos/tootsuite/mastodon/releases | jq -r '.[0].name' | sed -e 's/^v//g')
2020-10-15 18:16:57 +02:00
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
2023-08-17 14:21:41 +02:00
elif [[ $LAST_VERSION =~ rc[0-9]+$ ]] || [[ $LAST_VERSION =~ beta[0-9]+$ ]]; then
echo "OK : Installed version is $INSTALLED_VERSION, last version is Release Candidate or Beta : $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