check-routeros-update: match version with date suffix

Neighbor version can have a date suffix. This changes to match only
on the beginning.

Closes: GH-45

Co-authored-by: Christian Hesse <mail@eworm.de>
This commit is contained in:
Ben Harris 2023-07-13 09:38:20 +08:00 committed by Christian Hesse
parent 313e026229
commit fbf55292a4

View file

@ -18,6 +18,7 @@
:global SentRouterosUpdateNotification;
:global DeviceInfo;
:global EscapeForRegEx;
:global LogPrintExit2;
:global ScriptFromTerminal;
:global ScriptLock;
@ -80,7 +81,7 @@ $LogPrintExit2 debug $0 ("Checking for updates...") false;
}
:if ($SafeUpdateNeighbor = true && [ :len [ /ip/neighbor/find where \
version=($Update->"latest-version" . " (" . $Update->"channel" . ")") ] ] > 0) do={
version~("^" . [ $EscapeForRegEx ($Update->"latest-version" . " (" . $Update->"channel" . ")") ]) ] ] > 0) do={
$LogPrintExit2 info $0 ("Seen a neighbor running version " . $Update->"latest-version" . ", updating...") false;
$SendNotification2 ({ origin=$0; \
subject=([ $SymbolForNotification "sparkles" ] . "RouterOS update: " . $Update->"latest-version"); \