mirror of
https://git.eworm.de/cgit/routeros-scripts
synced 2025-06-20 17:05:44 +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:
|
The configuration goes to `global-config-overlay`, this is the only parameter:
|
||||||
|
|
||||||
* `PackagesUpdateDeferReboot`: defer the reboot for night (between 3 AM
|
* `PackagesUpdateDeferReboot`: defer the reboot for night (between 3 AM and
|
||||||
and 5 AM)
|
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
|
By modifying the scheduler's `start-time` you can force the reboot at
|
||||||
different time.
|
different time.
|
||||||
|
|
|
@ -31,19 +31,24 @@
|
||||||
:local Schedule do={
|
:local Schedule do={
|
||||||
:local ScriptName [ :tostr $1 ];
|
:local ScriptName [ :tostr $1 ];
|
||||||
|
|
||||||
|
:global PackagesUpdateDeferReboot;
|
||||||
|
|
||||||
:global GetRandomNumber;
|
:global GetRandomNumber;
|
||||||
|
:global IfThenElse;
|
||||||
:global LogPrint;
|
:global LogPrint;
|
||||||
|
|
||||||
:global RebootForUpdate do={
|
:global RebootForUpdate do={
|
||||||
/system/reboot;
|
/system/reboot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:local Interval [ $IfThenElse ($PackagesUpdateDeferReboot >= 1d) $PackagesUpdateDeferReboot 1d ];
|
||||||
:local StartTime [ :tostr [ :totime (10800 + [ $GetRandomNumber 7200 ]) ] ];
|
: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\"; " . \
|
on-event=("/system/scheduler/remove \"_RebootForUpdate\"; " . \
|
||||||
":global RebootForUpdate; \$RebootForUpdate;");
|
":global RebootForUpdate; \$RebootForUpdate;");
|
||||||
$LogPrint info $ScriptName ("Scheduled reboot for update at " . $StartTime . \
|
$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;
|
:return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +158,7 @@
|
||||||
:error true;
|
:error true;
|
||||||
}
|
}
|
||||||
} else={
|
} else={
|
||||||
:if ($PackagesUpdateDeferReboot = true) do={
|
:if ($PackagesUpdateDeferReboot = true || $PackagesUpdateDeferReboot >= 1d) do={
|
||||||
$Schedule $ScriptName;
|
$Schedule $ScriptName;
|
||||||
:set ExitOK true;
|
:set ExitOK true;
|
||||||
:error true;
|
:error true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue