mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2025-06-23 02:08:53 +02:00
packages-update: move output and logging to local function...
... and pass script name for clean logging.
This commit is contained in:
parent
237dcd7261
commit
461f7b6e76
1 changed files with 7 additions and 6 deletions
|
@ -23,14 +23,19 @@
|
||||||
:global PackagesUpdateDeferReboot;
|
:global PackagesUpdateDeferReboot;
|
||||||
|
|
||||||
:local Schedule do={
|
:local Schedule do={
|
||||||
|
:global LogPrintExit2;
|
||||||
|
|
||||||
:global RebootForUpdate do={
|
:global RebootForUpdate do={
|
||||||
:global RandomDelay;
|
:global RandomDelay;
|
||||||
$RandomDelay 3600;
|
$RandomDelay 3600;
|
||||||
/system/reboot;
|
/system/reboot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/system/scheduler/add name="_RebootForUpdate" start-time=03:00:00 interval=1d \
|
/system/scheduler/add name="_RebootForUpdate" start-time=03:00:00 interval=1d \
|
||||||
on-event=("/system/scheduler/remove \"_RebootForUpdate\"; " . \
|
on-event=("/system/scheduler/remove \"_RebootForUpdate\"; " . \
|
||||||
":global RebootForUpdate; \$RebootForUpdate;");
|
":global RebootForUpdate; \$RebootForUpdate;");
|
||||||
|
$LogPrintExit2 info $1 ("Scheduled reboot for update between 3 AM and 4 AM local time (" . \
|
||||||
|
[ /system/clock/get time-zone-name ] . ").") true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ScriptLock $0;
|
$ScriptLock $0;
|
||||||
|
@ -107,18 +112,14 @@ $ScriptLock $0;
|
||||||
/system/package/downgrade;
|
/system/package/downgrade;
|
||||||
}
|
}
|
||||||
|
|
||||||
:local Message ("Scheduled reboot for update between 3 AM and 4 AM local time (" . \
|
|
||||||
[ /system/clock/get time-zone-name ] . ").");
|
|
||||||
:if ([ $ScriptFromTerminal $0 ] = true) do={
|
:if ([ $ScriptFromTerminal $0 ] = true) do={
|
||||||
:put "Do you want to (s)chedule reboot or (r)eboot now? [s/R]";
|
:put "Do you want to (s)chedule reboot or (r)eboot now? [s/R]";
|
||||||
:if (([ /terminal/inkey timeout=60 ] % 32) = 19) do={
|
:if (([ /terminal/inkey timeout=60 ] % 32) = 19) do={
|
||||||
$Schedule;
|
$Schedule $0;
|
||||||
$LogPrintExit2 info $0 $Message true;
|
|
||||||
}
|
}
|
||||||
} else={
|
} else={
|
||||||
:if ($PackagesUpdateDeferReboot = true) do={
|
:if ($PackagesUpdateDeferReboot = true) do={
|
||||||
$Schedule;
|
$Schedule $0;
|
||||||
$LogPrintExit2 info $0 $Message true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue