summaryrefslogtreecommitdiffstats
path: root/lib/adei/adei_version.sh
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2019-09-04 22:06:01 +0200
committerSuren A. Chilingaryan <csa@suren.me>2019-09-04 22:06:01 +0200
commit6db35a5230578e296d9f493b28e6330e22569c8f (patch)
tree86ccb8725d2ae1a779459e2d8c01087c07a37e58 /lib/adei/adei_version.sh
parent78f3f37d3d8b213887fa6d47e32c5f9f05c0e299 (diff)
downloadconky-6db35a5230578e296d9f493b28e6330e22569c8f.tar.gz
conky-6db35a5230578e296d9f493b28e6330e22569c8f.tar.bz2
conky-6db35a5230578e296d9f493b28e6330e22569c8f.tar.xz
conky-6db35a5230578e296d9f493b28e6330e22569c8f.zip
Integrate also nagios-based monitoring here
Diffstat (limited to 'lib/adei/adei_version.sh')
-rw-r--r--lib/adei/adei_version.sh51
1 files changed, 51 insertions, 0 deletions
diff --git a/lib/adei/adei_version.sh b/lib/adei/adei_version.sh
new file mode 100644
index 0000000..b71b1e1
--- /dev/null
+++ b/lib/adei/adei_version.sh
@@ -0,0 +1,51 @@
+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
+}
+
+adei_version_check() {
+ vercomp $adei_revision $1
+ res=$?
+ if [ $res -eq 1 ]; then
+ return 0
+ elif [ $res -eq 2 ]; then
+ return 1;
+ fi
+
+ if [ -z "$2" -o -z "$adei_date" ]; then
+ return 0
+ fi
+
+ if [ $adei_date -ge $2 ]; then
+ return 0
+ fi
+
+ return 1
+}
+