mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-08-04 02:04:56 +02:00
global-functions: merge $LogAnd{Error,Put} to $LogPrintExit ...
... and fix logging. Logging with severity from variable (:log $severity ...) is not possible, this is considered a syntax error. Also the 'workaround' with parsing code failed with missing message in log. The reliable code is a lot longer, so merge the two functions to save a lot of duplicate code.
This commit is contained in:
parent
6036edb506
commit
ceaa83b83e
13 changed files with 56 additions and 56 deletions
|
@ -7,24 +7,24 @@
|
|||
:global DownloadPackage;
|
||||
:global ScriptFromTerminal;
|
||||
:global ScriptLock;
|
||||
:global LogAndError;
|
||||
:global LogPrintExit;
|
||||
|
||||
$ScriptLock "packages-update";
|
||||
|
||||
:local Update [ / system package update get ];
|
||||
|
||||
:if ([ :typeof ($Update->"latest-version") ] = "nothing") do={
|
||||
$LogAndError warning "Latest version is not known.";
|
||||
$LogPrintExit warning "Latest version is not known." true;
|
||||
}
|
||||
|
||||
:if ($Update->"installed-version" = $Update->"latest-version") do={
|
||||
$LogAndError info ("Version " . $Update->"latest-version" . " is already installed.");
|
||||
$LogPrintExit info ("Version " . $Update->"latest-version" . " is already installed.") true;
|
||||
}
|
||||
|
||||
:foreach Package in=[ / system package find where !bundle ] do={
|
||||
:local PkgName [ / system package get $Package name ];
|
||||
if ([ $DownloadPackage $PkgName ($Update->"latest-version") ] = false) do={
|
||||
$LogAndError error ("Download for package " . $PkgName . " failed.");
|
||||
$LogPrintExit error ("Download for package " . $PkgName . " failed.") true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ $ScriptLock "packages-update";
|
|||
/ system scheduler add name="reboot-for-update" start-time=03:00:00 interval=1d \
|
||||
on-event=(":global RandomDelay; \$RandomDelay 3600; " . \
|
||||
"/ system scheduler remove reboot-for-update; / system reboot;");
|
||||
$LogAndError info ("Scheduled reboot for update between 03:00 and 04:00.");
|
||||
$LogPrintExit info ("Scheduled reboot for update between 03:00 and 04:00.") true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue