mirror of
https://github.com/eworm-de/routeros-scripts.git
synced 2025-06-20 17:15:48 +02:00
packages-update: support deferred reboot with longer interval
This commit is contained in:
parent
6130c94cc1
commit
c3d3d61f92
2 changed files with 10 additions and 5 deletions
|
@ -46,8 +46,8 @@ Configuration
|
|||
|
||||
The configuration goes to `global-config-overlay`, this is the only parameter:
|
||||
|
||||
* `PackagesUpdateDeferReboot`: defer the reboot for night (between 3 AM
|
||||
and 5 AM)
|
||||
* `PackagesUpdateDeferReboot`: defer the reboot for night (between 3 AM and
|
||||
5 AM), use a numerical value in days suffixed with a `d` to defer further
|
||||
|
||||
By modifying the scheduler's `start-time` you can force the reboot at
|
||||
different time.
|
||||
|
|
|
@ -31,19 +31,24 @@
|
|||
:local Schedule do={
|
||||
:local ScriptName [ :tostr $1 ];
|
||||
|
||||
:global PackagesUpdateDeferReboot;
|
||||
|
||||
:global GetRandomNumber;
|
||||
:global IfThenElse;
|
||||
:global LogPrint;
|
||||
|
||||
:global RebootForUpdate do={
|
||||
/system/reboot;
|
||||
}
|
||||
|
||||
:local Interval [ $IfThenElse ($PackagesUpdateDeferReboot >= 1d) $PackagesUpdateDeferReboot 1d ];
|
||||
:local StartTime [ :tostr [ :totime (10800 + [ $GetRandomNumber 7200 ]) ] ];
|
||||
/system/scheduler/add name="_RebootForUpdate" start-time=$StartTime interval=1d \
|
||||
/system/scheduler/add name="_RebootForUpdate" start-time=$StartTime interval=$Interval \
|
||||
on-event=("/system/scheduler/remove \"_RebootForUpdate\"; " . \
|
||||
":global RebootForUpdate; \$RebootForUpdate;");
|
||||
$LogPrint info $ScriptName ("Scheduled reboot for update at " . $StartTime . \
|
||||
" local time (" . [ /system/clock/get time-zone-name ] . ").");
|
||||
" local time (" . [ /system/clock/get time-zone-name ] . ")" . \
|
||||
[ $IfThenElse ($Interval > 1d) (" deferred by " . $Interval) ] . ".");
|
||||
:return true;
|
||||
}
|
||||
|
||||
|
@ -153,7 +158,7 @@
|
|||
:error true;
|
||||
}
|
||||
} else={
|
||||
:if ($PackagesUpdateDeferReboot = true) do={
|
||||
:if ($PackagesUpdateDeferReboot = true || $PackagesUpdateDeferReboot >= 1d) do={
|
||||
$Schedule $ScriptName;
|
||||
:set ExitOK true;
|
||||
:error true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue