From ce03f447699677c456018c84a71accd615d01ea5 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 18 Jul 2022 23:46:49 +0200 Subject: check-routeros-update: use a better check for valid version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently the latest version in long-term branch is 0.0... And the script is sending downgrade notifications. 😝 Obviously that is not a valid version... With this changen a version has to be 7.0 and above to be considered valid. --- check-routeros-update | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/check-routeros-update b/check-routeros-update index acca9b9..9e1de8e 100644 --- a/check-routeros-update +++ b/check-routeros-update @@ -53,10 +53,6 @@ $LogPrintExit2 debug $0 ("Checking for updates...") false; /system/package/update/check-for-updates without-paging as-value; :local Update [ /system/package/update/get ]; -:if ([ :len ($Update->"latest-version") ] = 0) do={ - $LogPrintExit2 info $0 ("An empty string is not a valid version.") true; -} - :if ([ $ScriptFromTerminal $0 ] = true && ($Update->"installed-version") = ($Update->"latest-version")) do={ $LogPrintExit2 info $0 ("System is already up to date.") true; } @@ -65,6 +61,10 @@ $LogPrintExit2 debug $0 ("Checking for updates...") false; :local NumLatest [ $VersionToNum ($Update->"latest-version") ]; :local Link ("https://mikrotik.com/download/changelogs/" . $Update->"channel" . "-release-tree"); +:if ($NumLatest < 117505792) do={ + $LogPrintExit2 info $0 ("The version '" . ($Update->"latest-version") . "' is not a valid version.") true; +} + :if ($NumInstalled < $NumLatest) do={ :if ($SafeUpdatePatch = true && ($NumInstalled & 0xffff0000) = ($NumLatest & 0xffff0000)) do={ $LogPrintExit2 info $0 ("Version " . $Update->"latest-version" . " is a patch release, updating...") false; -- cgit v1.2.3-70-g09d2