firehol.takip 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/bash
  2. vercomp () {
  3. if [[ $1 == $2 ]]
  4. then
  5. return 0
  6. fi
  7. local IFS=.
  8. local i ver1=($1) ver2=($2)
  9. # fill empty fields in ver1 with zeros
  10. for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
  11. do
  12. ver1[i]=0
  13. done
  14. for ((i=0; i<${#ver1[@]}; i++))
  15. do
  16. if [[ -z ${ver2[i]} ]]
  17. then
  18. # fill empty fields in ver2 with zeros
  19. ver2[i]=0
  20. fi
  21. if ((10#${ver1[i]} > 10#${ver2[i]}))
  22. then
  23. return 1
  24. fi
  25. if ((10#${ver1[i]} < 10#${ver2[i]}))
  26. then
  27. return 2
  28. fi
  29. done
  30. return 0
  31. }
  32. testvercomp () {
  33. vercomp $1 $2
  34. case $? in
  35. 0) op='=';;
  36. 1) op='>';;
  37. 2) op='<';;
  38. esac
  39. echo $1 $op $2
  40. }
  41. _repo="firehol/firehol"
  42. get_latest_release() {
  43. curl -k --silent "https://api.github.com/repos/$1/releases/latest" \
  44. | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/'
  45. }
  46. function surum_takip
  47. {
  48. local _talimat _ENSON surum isim
  49. _talimat=firehol
  50. isim=firehol
  51. surum=`grep "surum=" $talimatname/genel/${_talimat:0:1}/$_talimat/talimat | cut -d'=' -f2`
  52. ENSON=$(get_latest_release $_repo)
  53. ENSON=${ENSON:1} # eğer v1.2 gibi başında v harfi ile dönüş veriyorsa
  54. testvercomp $surum $ENSON
  55. }