From 62f33d7b19792fded8366d57ff8756c5952da990 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Fri, 26 Jan 2024 09:11:17 +0100 Subject: packages-update: support deferred reboot on auto-update Closes #56 --- doc/packages-update.md | 12 ++++++++++++ global-config.rsc | 3 +++ global-functions.rsc | 2 +- news-and-changes.rsc | 1 + packages-update.rsc | 7 +++++++ 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/doc/packages-update.md b/doc/packages-update.md index 653d233..280c420 100644 --- a/doc/packages-update.md +++ b/doc/packages-update.md @@ -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 -------------------- diff --git a/global-config.rsc b/global-config.rsc index 6066fef..983eedb 100644 --- a/global-config.rsc +++ b/global-config.rsc @@ -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 { diff --git a/global-functions.rsc b/global-functions.rsc index 9be7893..306a2cc 100644 --- a/global-functions.rsc +++ b/global-functions.rsc @@ -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; diff --git a/news-and-changes.rsc b/news-and-changes.rsc index 0c81628..5186420 100644 --- a/news-and-changes.rsc +++ b/news-and-changes.rsc @@ -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 diff --git a/packages-update.rsc b/packages-update.rsc index b67346d..552a682 100644 --- a/packages-update.rsc +++ b/packages-update.rsc @@ -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; -- cgit v1.2.3-70-g09d2