From 22a9a11c738300d2ff29e065e9f2edca1f2f7709 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 7 Jul 2020 08:55:49 +0200 Subject: check-routeros-update: install update only, notification on downgrade --- check-routeros-update | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/check-routeros-update b/check-routeros-update index 931c32f..ea1fd31 100644 --- a/check-routeros-update +++ b/check-routeros-update @@ -44,12 +44,11 @@ $LogPrintExit warning "An empty string is not a valid version." true; } -:if ($Update->"installed-version" != $Update->"latest-version") do={ - :local NumInstalled [ $VersionToNum ($Update->"installed-version") ]; - :local NumLatest [ $VersionToNum ($Update->"latest-version") ]; +:local NumInstalled [ $VersionToNum ($Update->"installed-version") ]; +:local NumLatest [ $VersionToNum ($Update->"latest-version") ]; - :if ($SafeUpdatePatch = true && $NumInstalled < $NumLatest && \ - ($NumInstalled & 0xffff0000) = ($NumLatest & 0xffff0000)) do={ +:if ($NumInstalled < $NumLatest) do={ + :if ($SafeUpdatePatch = true && ($NumInstalled & 0xffff0000) = ($NumLatest & 0xffff0000)) do={ $LogPrintExit info ("Version " . $Update->"latest-version" . " is a patch release, updating...") false; $SendNotification ("RouterOS update") \ ("Version " . $Update->"latest-version" . " is a patch update for " . $Update->"channel" . \ @@ -97,3 +96,13 @@ "" "true"; :set SentRouterosUpdateNotification ($Update->"latest-version"); } + +:if ($NumInstalled > $NumLatest) do={ + $SendNotification ("RouterOS version") \ + ("A different RouterOS version " . ($Update->"latest-version") . \ + " is available for " . $Identity . ", but it is a downgrade.\n\n" . \ + [ $DeviceInfo ] . "\n\n" . \ + "https://mikrotik.com/download/changelogs/" . $Update->"channel" . "-release-tree") \ + "" "true"; + :set SentRouterosUpdateNotification ($Update->"latest-version"); +} -- cgit v1.2.3-54-g00ecf