unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Richard Sent <richard@freakingpenguin.com>
To: 70636@debbugs.gnu.org
Cc: Richard Sent <richard@freakingpenguin.com>
Subject: [bug#70636] [PATCH v2] services: admin: Support rebooting after an unattended upgrade
Date: Mon, 29 Apr 2024 00:34:20 -0400	[thread overview]
Message-ID: <8e12822dfa63081eaca99f204a78965fc6db3a01.1714365260.git.richard@freakingpenguin.com> (raw)
In-Reply-To: <4852ee6c60830311f4f1f06a43af9b471e91ad88.1714339967.git.richard@freakingpenguin.com>

* gnu/services/admin.scm (unattended-upgrade-configuration): Add reboot?
field. When truthy, unattended upgrade will stop the shepherd root service,
triggering a reboot.
* doc/guix.texi (Unattended Upgrades): Document it.

Change-Id: I0af659b3c318421b1a7baa94dde3dadacc1fa10d
---
Decided to change restart? to reboot?. The manual seems to generally
prefer reboot and it makes restarting services vs. rebooting the
system a bit more distinct.

 doc/guix.texi          |  4 ++++
 gnu/services/admin.scm | 13 ++++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index 5d3c9225b4..709db674c9 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -22891,6 +22891,10 @@ Unattended Upgrades
     #~(@@ (guix system install) installation-os)))
 @end lisp
 
+@item @code{reboot?} (default: @code{#f})
+This field specifies whether the system should reboot after completing
+an unattended upgrade.
+
 @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 0b325fddb1..4882883878 100644
--- a/gnu/services/admin.scm
+++ b/gnu/services/admin.scm
@@ -420,6 +420,8 @@ (define-record-type* <unattended-upgrade-configuration>
                         (default "30 01 * * 0"))
   (channels             unattended-upgrade-configuration-channels
                         (default #~%default-channels))
+  (reboot?              unattended-upgrade-configuration-reboot?
+                        (default #f))
   (services-to-restart  unattended-upgrade-configuration-services-to-restart
                         (default '(mcron)))
   (system-expiration    unattended-upgrade-system-expiration
@@ -443,6 +445,9 @@ (define (unattended-upgrade-mcron-jobs config)
   (define services
     (unattended-upgrade-configuration-services-to-restart config))
 
+  (define reboot?
+    (unattended-upgrade-configuration-reboot? config))
+
   (define expiration
     (unattended-upgrade-system-expiration config))
 
@@ -512,7 +517,13 @@ (define (unattended-upgrade-mcron-jobs config)
 
             ;; XXX: If 'mcron' has been restarted, perhaps this isn't
             ;; reached.
-            (format #t "~a upgrade complete~%" (timestamp))))))
+            (format #t "~a upgrade complete~%" (timestamp))
+
+            ;; Stopping the root shepherd service triggers a reboot.
+            (when #$reboot?
+              (format #t "~a rebooting system~%" (timestamp))
+              (force-output) ;ensure the entire log is written.
+              (stop-service 'root))))))
 
   (define upgrade
     (program-file "unattended-upgrade" code))

base-commit: 3bd8d238aba718bf949691d0e37fa310e2cfc12a
-- 
2.41.0





  reply	other threads:[~2024-04-29  4:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-28 21:32 [bug#70636] [PATCH] services: admin: Support restarting system after unattended upgrade Richard Sent
2024-04-29  4:34 ` Richard Sent [this message]
2024-09-15 21:53   ` bug#70636: [PATCH v2] services: admin: Support rebooting after an " 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

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=8e12822dfa63081eaca99f204a78965fc6db3a01.1714365260.git.richard@freakingpenguin.com \
    --to=richard@freakingpenguin.com \
    --cc=70636@debbugs.gnu.org \
    /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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).