check-routeros-update: show neighbor's identity in message and notification

This commit is contained in:
Christian Hesse 2023-08-24 11:16:23 +02:00
parent 7b47ed7ea5
commit 57027ceb26

View file

@ -81,15 +81,19 @@ $LogPrintExit2 debug $0 ("Checking for updates...") false;
$DoUpdate; $DoUpdate;
} }
:if ($SafeUpdateNeighbor = true && [ :len [ /ip/neighbor/find where platform="MikroTik" \ :if ($SafeUpdateNeighbor = true) do={
version~("^" . [ $EscapeForRegEx ($Update->"latest-version" . " (" . $Update->"channel" . ")") ]) \ :local Neighbors [ /ip/neighbor/find where platform="MikroTik" identity~$SafeUpdateNeighborIdentity \
identity~$SafeUpdateNeighborIdentity ] ] > 0) do={ version~("^" . [ $EscapeForRegEx ($Update->"latest-version" . " (" . $Update->"channel" . ")") ]) ];
$LogPrintExit2 info $0 ("Seen a neighbor running version " . $Update->"latest-version" . ", updating...") false; :if ([ :len $Neighbors ] > 0) do={
$SendNotification2 ({ origin=$0; \ :local Neighbor [ /ip/neighbor/get ($Neighbors->0) identity ];
subject=([ $SymbolForNotification "sparkles" ] . "RouterOS update: " . $Update->"latest-version"); \ $LogPrintExit2 info $0 ("Seen a neighbor (" . $Neighbor . ") running version " . \
message=("Seen a neighbor running version " . $Update->"latest-version" . " from " . $Update->"channel" . \ $Update->"latest-version" . " from " . $Update->"channel" . ", updating...") false;
", updating on " . $Identity . "..."); link=$Link; silent=true }); $SendNotification2 ({ origin=$0; \
$DoUpdate; subject=([ $SymbolForNotification "sparkles" ] . "RouterOS update: " . $Update->"latest-version"); \
message=("Seen a neighbor (" . $Neighbor . ") running version " . $Update->"latest-version" . \
" from " . $Update->"channel" . ", updating on " . $Identity . "..."); link=$Link; silent=true });
$DoUpdate;
}
} }
:if ([ :len $SafeUpdateUrl ] > 0) do={ :if ([ :len $SafeUpdateUrl ] > 0) do={