unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#70636] [PATCH] services: admin: Support restarting system after unattended upgrade
@ 2024-04-28 21:32 Richard Sent
  2024-04-29  4:34 ` [bug#70636] [PATCH v2] services: admin: Support rebooting after an " Richard Sent
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Sent @ 2024-04-28 21:32 UTC (permalink / raw)
  To: 70636; +Cc: Richard Sent

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

Change-Id: I0af659b3c318421b1a7baa94dde3dadacc1fa10d
---
Hi Guix!

This patch adds support for running a complete system restart after an
unattended upgrade. Previously, unattended upgrades were not capable
of, say, upgrading the kernel.

/Technically/ without this patch I'm pretty sure you could restart the
system by restarting the 'file-systems service. I haven't found
documentation on that and it feels like a hack more than a feature. I
don't know if it would perform a safe shutdown. Thankfully, Shepherd
explicitly treats "stop root service" as "restart" so the method in
this patch should be safe.

 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 3ee9f54773..08fdac4cd3 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -22891,6 +22891,10 @@ Unattended Upgrades
     #~(@@ (guix system install) installation-os)))
 @end lisp
 
+@item @code{restart?} (default: @code{#f})
+This field specifies whether the system should restart 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..579cf83132 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))
+  (restart?             unattended-upgrade-configuration-restart?
+                        (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 restart?
+    (unattended-upgrade-configuration-restart? 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 restart.
+            (when #$restart?
+              (format #t "~a restarting system~%" (timestamp))
+              (force-output) ;ensure the entire log is written.
+              (stop-service 'root))))))
 
   (define upgrade
     (program-file "unattended-upgrade" code))

base-commit: 9f183c3627a006e8fd3bb9708448bc05a6204e6d
-- 
2.41.0





^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-15 21:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-28 21:32 [bug#70636] [PATCH] services: admin: Support restarting system after unattended upgrade Richard Sent
2024-04-29  4:34 ` [bug#70636] [PATCH v2] services: admin: Support rebooting after an " Richard Sent
2024-09-15 21:53   ` bug#70636: " Ludovic Courtès

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).