36 lines
1.1 KiB
Bash
Executable File
36 lines
1.1 KiB
Bash
Executable File
#!/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
|
|
elif [[ $LAST_VERSION =~ rc[0-9]+$ ]]; then
|
|
echo "OK : Installed version is $INSTALLED_VERSION, last version is Release Candidate : $LAST_VERSION"
|
|
else
|
|
echo "WARNING : new version available, installed is $INSTALLED_VERSION, last is $LAST_VERSION."
|
|
exit 2
|
|
fi
|
|
|