check-routeros-update: install update only, notification on downgrade

This commit is contained in:
Christian Hesse 2020-07-07 08:55:49 +02:00
parent 2907dbe18f
commit 22a9a11c73

View file

@ -44,12 +44,11 @@
$LogPrintExit warning "An empty string is not a valid version." true; $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 NumInstalled [ $VersionToNum ($Update->"installed-version") ]; :local NumLatest [ $VersionToNum ($Update->"latest-version") ];
:local NumLatest [ $VersionToNum ($Update->"latest-version") ];
:if ($SafeUpdatePatch = true && $NumInstalled < $NumLatest && \ :if ($NumInstalled < $NumLatest) do={
($NumInstalled & 0xffff0000) = ($NumLatest & 0xffff0000)) do={ :if ($SafeUpdatePatch = true && ($NumInstalled & 0xffff0000) = ($NumLatest & 0xffff0000)) do={
$LogPrintExit info ("Version " . $Update->"latest-version" . " is a patch release, updating...") false; $LogPrintExit info ("Version " . $Update->"latest-version" . " is a patch release, updating...") false;
$SendNotification ("RouterOS update") \ $SendNotification ("RouterOS update") \
("Version " . $Update->"latest-version" . " is a patch update for " . $Update->"channel" . \ ("Version " . $Update->"latest-version" . " is a patch update for " . $Update->"channel" . \
@ -97,3 +96,13 @@
"" "true"; "" "true";
:set SentRouterosUpdateNotification ($Update->"latest-version"); :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");
}