123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- #!/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
- }
|