check-routeros-update: use $SendNotification2

This commit is contained in:
Christian Hesse 2021-04-27 20:51:04 +02:00
parent 4fe11fadee
commit 19ca17190d

View file

@ -19,7 +19,7 @@
:global DeviceInfo; :global DeviceInfo;
:global LogPrintExit2; :global LogPrintExit2;
:global ScriptFromTerminal; :global ScriptFromTerminal;
:global SendNotification; :global SendNotification2;
:global SymbolForNotification; :global SymbolForNotification;
:global VersionToNum; :global VersionToNum;
:global WaitFullyConnected; :global WaitFullyConnected;
@ -65,18 +65,18 @@ $LogPrintExit2 debug $0 ("Checking for updates...") false;
:if ($NumInstalled < $NumLatest) do={ :if ($NumInstalled < $NumLatest) do={
:if ($SafeUpdatePatch = true && ($NumInstalled & 0xffff0000) = ($NumLatest & 0xffff0000)) do={ :if ($SafeUpdatePatch = true && ($NumInstalled & 0xffff0000) = ($NumLatest & 0xffff0000)) do={
$LogPrintExit2 info $0 ("Version " . $Update->"latest-version" . " is a patch release, updating...") false; $LogPrintExit2 info $0 ("Version " . $Update->"latest-version" . " is a patch release, updating...") false;
$SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \ $SendNotification2 ({ subject=([ $SymbolForNotification "sparkles" ] . "RouterOS update"); \
("Version " . $Update->"latest-version" . " is a patch update for " . $Update->"channel" . \ message=("Version " . $Update->"latest-version" . " is a patch update for " . $Update->"channel" . \
", updating on " . $Identity . "...") $Link "true"; ", updating on " . $Identity . "..."); link=$Link; silent=true });
$DoUpdate; $DoUpdate;
} }
:if ($SafeUpdateNeighbor = true && [ :len [ / ip neighbor find where \ :if ($SafeUpdateNeighbor = true && [ :len [ / ip neighbor find where \
version=($Update->"latest-version" . " (" . $Update->"channel" . ")") ] ] > 0) do={ version=($Update->"latest-version" . " (" . $Update->"channel" . ")") ] ] > 0) do={
$LogPrintExit2 info $0 ("Seen a neighbor running version " . $Update->"latest-version" . ", updating...") false; $LogPrintExit2 info $0 ("Seen a neighbor running version " . $Update->"latest-version" . ", updating...") false;
$SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \ $SendNotification2 ({ subject=([ $SymbolForNotification "sparkles" ] . "RouterOS update"); \
("Seen a neighbor running version " . $Update->"latest-version" . " from " . $Update->"channel" . \ message=("Seen a neighbor running version " . $Update->"latest-version" . " from " . $Update->"channel" . \
", updating on " . $Identity . "...") $Link "true"; ", updating on " . $Identity . "..."); link=$Link; silent=true });
$DoUpdate; $DoUpdate;
} }
@ -91,9 +91,9 @@ $LogPrintExit2 debug $0 ("Checking for updates...") false;
} }
:if ($Result->"status" = "finished" && $Result->"data" = $Update->"latest-version") do={ :if ($Result->"status" = "finished" && $Result->"data" = $Update->"latest-version") do={
$LogPrintExit2 info $0 ("Version " . $Update->"latest-version" . " is considered safe, updating...") false; $LogPrintExit2 info $0 ("Version " . $Update->"latest-version" . " is considered safe, updating...") false;
$SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \ $SendNotification2 ({ subject=([ $SymbolForNotification "sparkles" ] . "RouterOS update"); \
("Version " . $Update->"latest-version" . " is considered safe for " . $Update->"channel" . \ message=("Version " . $Update->"latest-version" . " is considered safe for " . $Update->"channel" . \
", updating on " . $Identity . "...") $Link "true"; ", updating on " . $Identity . "..."); link=$Link; silent=true });
$DoUpdate; $DoUpdate;
} }
} }
@ -112,10 +112,10 @@ $LogPrintExit2 debug $0 ("Checking for updates...") false;
$Update->"latest-version" . ".") true; $Update->"latest-version" . ".") true;
} }
$SendNotification ([ $SymbolForNotification "sparkles" ] . "RouterOS update") \ $SendNotification2 ({ subject=([ $SymbolForNotification "sparkles" ] . "RouterOS update"); \
("A new RouterOS version " . ($Update->"latest-version") . \ message=("A new RouterOS version " . ($Update->"latest-version") . \
" is available for " . $Identity . ".\n\n" . \ " is available for " . $Identity . ".\n\n" . \
[ $DeviceInfo ]) $Link "true"; [ $DeviceInfo ]); link=$Link; silent=true });
:set SentRouterosUpdateNotification ($Update->"latest-version"); :set SentRouterosUpdateNotification ($Update->"latest-version");
} }
@ -125,10 +125,10 @@ $LogPrintExit2 debug $0 ("Checking for updates...") false;
$Update->"latest-version" . ".") true; $Update->"latest-version" . ".") true;
} }
$SendNotification ([ $SymbolForNotification "warning-sign" ] . "RouterOS version") \ $SendNotification2 ({ subject=([ $SymbolForNotification "warning-sign" ] . "RouterOS version"); \
("A different RouterOS version " . ($Update->"latest-version") . \ message=("A different RouterOS version " . ($Update->"latest-version") . \
" is available for " . $Identity . ", but it is a downgrade.\n\n" . \ " is available for " . $Identity . ", but it is a downgrade.\n\n" . \
[ $DeviceInfo ]) $Link "true"; [ $DeviceInfo ]); link=$Link; silent=true });
$LogPrintExit2 info $0 ("A different RouterOS version " . ($Update->"latest-version") . \ $LogPrintExit2 info $0 ("A different RouterOS version " . ($Update->"latest-version") . \
" is available for downgrade.") false; " is available for downgrade.") false;
:set SentRouterosUpdateNotification ($Update->"latest-version"); :set SentRouterosUpdateNotification ($Update->"latest-version");