From 459159f5623ff92a38d6094db75b155221931878 Mon Sep 17 00:00:00 2001 From: tykayn Date: Thu, 26 Nov 2020 17:16:51 +0100 Subject: [PATCH] check version ok --- monitoring/check_version.sh | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 monitoring/check_version.sh diff --git a/monitoring/check_version.sh b/monitoring/check_version.sh new file mode 100644 index 0000000..c68746f --- /dev/null +++ b/monitoring/check_version.sh @@ -0,0 +1,40 @@ +#!/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 + lastVersion=$(curl -s https://framagit.org/api/v4/projects/$FRAMAGIT_PROJECT_ID/releases | jshon -a -e name|cut -d '"' -f2|grep -v '[\^\(alpha\)]'|head -n 1) + currentVersion=$(cd $LOCAL_REPO && git branch | grep '*'|cut -c 3-100 ) + +# echo "current version: $currentVersion" +# echo "last version: $lastVersion" + if [ $currentVersion = $lastVersion ]; then + echo "OK" + result=0 + else + echo "WARNING : new version available, current is $currentVersion, last is $lastVersion." + result=1 + fi +fi +exit $result +