aboutsummaryrefslogtreecommitdiffstats
path: root/check-routeros-update.rsc
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-03-08 12:45:37 +0100
committerGravatar Christian Hesse <mail@eworm.de>2024-03-12 20:37:57 +0100
commita996bdac2aa42728676fe2acc1f0b589aae6673c (patch)
treea463949cd39ea9d37d6dd57b5281207c47a4474e /check-routeros-update.rsc
parent7f154a178bf41a6d053cd86e339d8533c0028a51 (diff)
check-routeros-update: switch to $LogPrint
Diffstat (limited to 'check-routeros-update.rsc')
-rw-r--r--check-routeros-update.rsc35
1 files changed, 18 insertions, 17 deletions
diff --git a/check-routeros-update.rsc b/check-routeros-update.rsc
index a68762b..e209610 100644
--- a/check-routeros-update.rsc
+++ b/check-routeros-update.rsc
@@ -24,7 +24,7 @@
:global DeviceInfo;
:global EscapeForRegEx;
- :global LogPrintExit2;
+ :global LogPrint;
:global ScriptFromTerminal;
:global ScriptLock;
:global SendNotification2;
@@ -50,12 +50,12 @@
:error "A reboot for update is already scheduled.";
}
- $LogPrintExit2 debug $ScriptName ("Checking for updates...") false;
+ $LogPrint debug $ScriptName ("Checking for updates...");
/system/package/update/check-for-updates without-paging as-value;
:local Update [ /system/package/update/get ];
:if ([ $ScriptFromTerminal $ScriptName ] = true && ($Update->"installed-version") = ($Update->"latest-version")) do={
- $LogPrintExit2 info $ScriptName ("System is already up to date.") false;
+ $LogPrint info $ScriptName ("System is already up to date.");
:error true;
}
@@ -64,13 +64,14 @@
:local Link ("https://mikrotik.com/download/changelogs/" . $Update->"channel" . "-release-tree");
:if ($NumLatest < 117505792) do={
- $LogPrintExit2 info $ScriptName ("The version '" . ($Update->"latest-version") . "' is not a valid version.") true;
+ $LogPrint info $ScriptName ("The version '" . ($Update->"latest-version") . "' is not a valid version.");
+ :error false;
}
:if ($NumInstalled < $NumLatest) do={
:if ($SafeUpdateAll ~ "^YES,? ?PLEASE!?\$") do={
- $LogPrintExit2 info $ScriptName ("Installing ALL versions automatically, including " . \
- $Update->"latest-version" . "...") false;
+ $LogPrint info $ScriptName ("Installing ALL versions automatically, including " . \
+ $Update->"latest-version" . "...");
$SendNotification2 ({ origin=$ScriptName; \
subject=([ $SymbolForNotification "sparkles" ] . "RouterOS update: " . $Update->"latest-version"); \
message=("Installing ALL versions automatically, including " . $Update->"latest-version" . \
@@ -79,7 +80,7 @@
}
:if ($SafeUpdatePatch = true && ($NumInstalled & 0xffff0000) = ($NumLatest & 0xffff0000)) do={
- $LogPrintExit2 info $ScriptName ("Version " . $Update->"latest-version" . " is a patch release, updating...") false;
+ $LogPrint info $ScriptName ("Version " . $Update->"latest-version" . " is a patch release, updating...");
$SendNotification2 ({ origin=$ScriptName; \
subject=([ $SymbolForNotification "sparkles" ] . "RouterOS update: " . $Update->"latest-version"); \
message=("Version " . $Update->"latest-version" . " is a patch update for " . $Update->"channel" . \
@@ -92,8 +93,8 @@
version~("^" . [ $EscapeForRegEx ($Update->"latest-version") ] . "\\b") ];
:if ([ :len $Neighbors ] > 0) do={
:local Neighbor [ /ip/neighbor/get ($Neighbors->0) identity ];
- $LogPrintExit2 info $ScriptName ("Seen a neighbor (" . $Neighbor . ") running version " . \
- $Update->"latest-version" . " from " . $Update->"channel" . ", updating...") false;
+ $LogPrint info $ScriptName ("Seen a neighbor (" . $Neighbor . ") running version " . \
+ $Update->"latest-version" . " from " . $Update->"channel" . ", updating...");
$SendNotification2 ({ origin=$ScriptName; \
subject=([ $SymbolForNotification "sparkles" ] . "RouterOS update: " . $Update->"latest-version"); \
message=("Seen a neighbor (" . $Neighbor . ") running version " . $Update->"latest-version" . \
@@ -109,10 +110,10 @@
($SafeUpdateUrl . $Update->"channel" . "?installed=" . $Update->"installed-version" . \
"&latest=" . $Update->"latest-version") output=user as-value ];
} on-error={
- $LogPrintExit2 warning $ScriptName ("Failed receiving safe version for " . $Update->"channel" . ".") false;
+ $LogPrint warning $ScriptName ("Failed receiving safe version for " . $Update->"channel" . ".");
}
:if ($Result->"status" = "finished" && $Result->"data" = $Update->"latest-version") do={
- $LogPrintExit2 info $ScriptName ("Version " . $Update->"latest-version" . " is considered safe, updating...") false;
+ $LogPrint info $ScriptName ("Version " . $Update->"latest-version" . " is considered safe, updating...");
$SendNotification2 ({ origin=$ScriptName; \
subject=([ $SymbolForNotification "sparkles" ] . "RouterOS update: " . $Update->"latest-version"); \
message=("Version " . $Update->"latest-version" . " is considered safe for " . $Update->"channel" . \
@@ -131,8 +132,8 @@
}
:if ($SentRouterosUpdateNotification = $Update->"latest-version") do={
- $LogPrintExit2 info $ScriptName ("Already sent the RouterOS update notification for version " . \
- $Update->"latest-version" . ".") false;
+ $LogPrint info $ScriptName ("Already sent the RouterOS update notification for version " . \
+ $Update->"latest-version" . ".");
:error true;
}
@@ -146,8 +147,8 @@
:if ($NumInstalled > $NumLatest) do={
:if ($SentRouterosUpdateNotification = $Update->"latest-version") do={
- $LogPrintExit2 info $ScriptName ("Already sent the RouterOS downgrade notification for version " . \
- $Update->"latest-version" . ".") false;
+ $LogPrint info $ScriptName ("Already sent the RouterOS downgrade notification for version " . \
+ $Update->"latest-version" . ".");
:error true;
}
@@ -156,8 +157,8 @@
message=("A different RouterOS version " . ($Update->"latest-version") . \
" is available for " . $Identity . ", but it is a downgrade.\n\n" . \
[ $DeviceInfo ]); link=$Link; silent=true });
- $LogPrintExit2 info $ScriptName ("A different RouterOS version " . ($Update->"latest-version") . \
- " is available for downgrade.") false;
+ $LogPrint info $ScriptName ("A different RouterOS version " . ($Update->"latest-version") . \
+ " is available for downgrade.");
:set SentRouterosUpdateNotification ($Update->"latest-version");
}
} on-error={ }