Added gitignore file.
This commit is contained in:
parent
7b8d44b781
commit
7a1fffbcf3
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*~
|
@ -1,70 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Nagios plugin to check Gitea version
|
||||
|
||||
function usage()
|
||||
{
|
||||
echo "Usage : $0"
|
||||
}
|
||||
|
||||
|
||||
function getCurrentVersion
|
||||
{
|
||||
local result
|
||||
|
||||
local json=$(curl -s -X GET "https://forge.april.org/api/v1/version" -H "accept: application/json")
|
||||
#echo "[$json]"
|
||||
|
||||
# {"version":"1.11.1"}
|
||||
local regexp='\{"version":"(.*)"}'
|
||||
if [[ $json =~ $regexp ]]; then
|
||||
result=${BASH_REMATCH[1]}
|
||||
else
|
||||
result=
|
||||
fi
|
||||
|
||||
echo "$result"
|
||||
}
|
||||
|
||||
function getLastVersionFromGithub
|
||||
{
|
||||
local result
|
||||
|
||||
local owner="$1"
|
||||
local repo="$2"
|
||||
|
||||
local json=$(curl -s -X GET https://api.github.com/repos/$owner/$repo/releases/latest |grep tag_name)
|
||||
#echo "[$json]"
|
||||
|
||||
# [ "tag_name": "v1.11.1",]
|
||||
local regexp='.*"tag_name": "v(.+)".*'
|
||||
|
||||
if [[ $json =~ $regexp ]]; then
|
||||
result=${BASH_REMATCH[1]}
|
||||
else
|
||||
result=
|
||||
fi
|
||||
|
||||
echo "$result"
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
if [ "$#" -ne 0 ]; then
|
||||
usage
|
||||
else
|
||||
currentVersion=$(getCurrentVersion)
|
||||
#echo "Current version = $currentVersion"
|
||||
|
||||
lastVersion=$(getLastVersionFromGithub "go-gitea" "gitea")
|
||||
#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
|
Loading…
Reference in New Issue
Block a user