24
0
Fork 0
mobilizon.chapril.org-tools/monitoring/check_mobilizonchaprilorg_u...

41 lines
1.3 KiB
Plaintext
Raw Normal View History

2020-11-26 17:16:51 +01:00
#!/bin/bash
#
# Nagios plugin to check mobilizon's version
#
# program return value
# 0 : OK
# 1 : CRITICAL
# 2 : WARNING new version available
# 3 : UNKNOWN github or local repo not probable
# project api for gitlab https://docs.gitlab.com/ee/api/tags.html
# upgrade documentation https://docs.joinmobilizon.org/administration/upgrading/
LOCAL_REPO=/srv/mobilizon.chapril.org/live
FRAMAGIT_PROJECT_ID=20125
function usage() {
echo "Usage : $0"
}
#
if [ "$#" -ne 0 ]; then
usage
else
2021-08-19 14:38:35 +02:00
lastVersion=$(curl -s https://framagit.org/api/v4/projects/$FRAMAGIT_PROJECT_ID/releases | jshon -a -e name > /tmp/listOfVersions.txt && sed -i -e "/rc/d" /tmp/listOfVersions.txt && cat /tmp/listOfVersions.txt |cut -d '"' -f2|grep -v '[\^\(alpha\)]'|head -n 1)
2020-12-09 18:34:07 +01:00
currentVersion=$(cd $LOCAL_REPO && git describe --exact-match --tags $(git log -n1 --pretty='%h') |cut -c 9-100 )
# le tag se nomme ainsi "chapril-1.0.2" donc pour comparer uniquement les numéros de version on enlève le début du nom
2020-11-26 17:16:51 +01:00
2020-12-10 15:18:39 +01:00
# echo "current version: $currentVersion"
# echo "last version: $lastVersion"
2020-12-09 18:34:07 +01:00
if [ "$currentVersion" = "$lastVersion" ]; then
2020-11-26 17:16:51 +01:00
echo "OK"
result=0
else
echo "WARNING : new version available, current is $currentVersion, last is $lastVersion."
result=1
2020-11-26 17:16:51 +01:00
fi
fi
exit $result