milis/talimatname/genel/f/firehol/firehol.takip

66 lines
1.3 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
vercomp () {
if [[ $1 == $2 ]]
then
return 0
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++))
do
if [[ -z ${ver2[i]} ]]
then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]}))
then
return 1
fi
if ((10#${ver1[i]} < 10#${ver2[i]}))
then
return 2
fi
done
return 0
}
testvercomp () {
vercomp $1 $2
case $? in
0) op='=';;
1) op='>';;
2) op='<';;
esac
echo $1 $op $2
}
_repo="firehol/firehol"
get_latest_release() {
curl -k --silent "https://api.github.com/repos/$1/releases/latest" \
| grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'
}
function surum_takip
{
local _talimat _ENSON surum isim
_talimat=firehol
isim=firehol
surum=`grep "surum=" $talimatname/genel/${_talimat:0:1}/$_talimat/talimat | cut -d'=' -f2`
ENSON=$(get_latest_release $_repo)
ENSON=${ENSON:1} # eğer v1.2 gibi başında v harfi ile dönüş veriyorsa
testvercomp $surum $ENSON
}