packages-update: support deferred reboot on auto-update

Closes #56
This commit is contained in:
Christian Hesse 2024-01-26 09:11:17 +01:00
parent 98f26989f5
commit 62f33d7b19
5 changed files with 24 additions and 1 deletions

View file

@ -34,6 +34,18 @@ Just install the script:
It is automatically run by [check-routeros-update](check-routeros-update.md)
if available.
Configuration
-------------
The configuration goes to `global-config-overlay`, this is the only parameter:
* `PackagesUpdateDeferReboot`: defer the reboot for night (between 3 AM
and 4 AM)
> **Info**: Copy relevant configuration from
> [`global-config`](../global-config.rsc) (the one without `-overlay`) to
> your local `global-config-overlay` and modify it to your specific needs.
Usage and invocation
--------------------

View file

@ -135,6 +135,9 @@
# Set to all upper-case "Yes, please!" to enable.
:global SafeUpdateAll "no";
# Defer the reboot for night on automatic (non-interactive) update
:global PackagesUpdateDeferReboot false;
# These thresholds control when to send health notification
# on temperature and voltage.
:global CheckHealthTemperature {

View file

@ -12,7 +12,7 @@
:local 0 "global-functions";
# expected configuration version
:global ExpectedConfigVersion 116;
:global ExpectedConfigVersion 117;
# global variables not to be changed by user
:global GlobalFunctionsReady false;

View file

@ -36,6 +36,7 @@
116=("... and also please keep in mind that it takes a huge amount of time maintaining these scripts. " . [ $IfThenElse ($IDonate != true) \
("Following the donation hint " . [ $SymbolForNotification "arrow-down" "below" ] . "to keep me motivated is much appreciated. Thanks!") \
("Looks like you did donate already. " . [ $SymbolForNotification "heart" "<3" ] . "Much appreciated, thanks!") ]);
117="Enhanced 'packages-update' to support deferred reboot on automatically installed updates.";
};
# Migration steps to be applied on script updates

View file

@ -18,6 +18,8 @@
:global ScriptLock;
:global VersionToNum;
:global PackagesUpdateDeferReboot;
:local Schedule do={
:global RebootForUpdate do={
:global RandomDelay;
@ -109,6 +111,11 @@ $ScriptLock $0;
$Schedule;
$LogPrintExit2 info $0 ("Scheduled reboot for update between 03:00 and 04:00.") true;
}
} else={
:if ($PackagesUpdateDeferReboot = true) do={
$Schedule;
$LogPrintExit2 info $0 ("Scheduled reboot for update between 03:00 and 04:00.") true;
}
}
$LogPrintExit2 info $0 ("Rebooting for update.") false;