all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Richard Sent <richard@freakingpenguin.com>
To: 74678@debbugs.gnu.org
Cc: "Richard Sent" <richard@freakingpenguin.com>,
	"Ludovic Courtès" <ludo@gnu.org>,
	"Maxim Cournoyer" <maxim.cournoyer@gmail.com>
Subject: [bug#74678] [PATCH] services: admin: Improve use of unattended-upgrade reboot? field.
Date: Tue,  3 Dec 2024 18:28:13 -0500	[thread overview]
Message-ID: <a9362bf033834e45aa6db8c1476a642ad1b0d37a.1733268493.git.richard@freakingpenguin.com> (raw)

This ensures the unattended upgrade job successfully reboots regardless of the
value for services-to-restart. Previously the mcron service may be restarted
which would halt script execution before the system rebooted.

* gnu/services/admin.scm (unattended-upgrade-mcron-jobs): Do not restart
services when reboot? is #t.
* doc/guix.texi (Unattended Upgrades): Document it.

Change-Id: I8e486a764ec1dc5c3090130cc447a0cc3f5a2e00
---
Hi all,

I noticed my server would not reboot automatically until I set
services-to-restart to '() (default value: '(mcron)). This patch
should make unattended-upgrade easier to use for those who don't want
to dive into the code.

 doc/guix.texi          |  4 ++++
 gnu/services/admin.scm | 10 ++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 26488b41c8..5f4fded753 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -23268,6 +23268,10 @@ Unattended Upgrades
 This field specifies whether the system should reboot after completing
 an unattended upgrade.
 
+When @code{reboot?} is @code{#t}, services are not restarted before
+rebooting.  This means that the value for @code{services-to-restart} is
+ignored.  The updated services will be started after the system reboots.
+
 @item @code{services-to-restart} (default: @code{'(mcron)})
 This field specifies the Shepherd services to restart when the upgrade
 completes.
diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index 4882883878..24ff659a01 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -512,11 +512,13 @@ (define (unattended-upgrade-mcron-jobs config)
                       #$(string-append (number->string expiration)
                                        "s")))
 
-            (format #t "~a restarting services...~%" (timestamp))
-            (for-each restart-service '#$services)
+            (unless #$reboot?
+              ;; Rebooting effectively restarts services anyway and execution
+              ;; would be halted here if mcron is restarted.
+              (format #t "~a restarting services...~%" (timestamp))
+              (for-each restart-service '#$services))
 
-            ;; XXX: If 'mcron' has been restarted, perhaps this isn't
-            ;; reached.
+            ;; XXX: If 'mcron' has been restarted, this is not reached.
             (format #t "~a upgrade complete~%" (timestamp))
 
             ;; Stopping the root shepherd service triggers a reboot.

base-commit: 8a28ba76126cbbd2a6d61e864f576e7a7bd7a763
-- 
2.46.0





             reply	other threads:[~2024-12-03 23:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-03 23:28 Richard Sent [this message]
2024-12-09 21:55 ` bug#74678: [PATCH] services: admin: Improve use of unattended-upgrade reboot? field Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a9362bf033834e45aa6db8c1476a642ad1b0d37a.1733268493.git.richard@freakingpenguin.com \
    --to=richard@freakingpenguin.com \
    --cc=74678@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    --cc=maxim.cournoyer@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.