summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sent <richard@freakingpenguin.com>2024-04-29 00:34:20 -0400
committerGuix Patches Tester <>2024-04-29 11:58:12 +0200
commit00ddeb95fc41045d5ee6f4f4351c1d97ff604299 (patch)
tree960a3e126ce47f6c1d4a3736d75801862f216492
parent4178eaf3b2eeea8f6c2e49b1d65cd60a1663c4a9 (diff)
downloadguix-patches-issue-70636.tar
guix-patches-issue-70636.tar.gz
services: admin: Support rebooting after an unattended upgradeissue-70636
* 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
-rw-r--r--doc/guix.texi4
-rw-r--r--gnu/services/admin.scm13
2 files changed, 16 insertions, 1 deletions
diff --git a/doc/guix.texi b/doc/guix.texi
index 3ee9f54773..d4212f7569 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -22891,6 +22891,10 @@ system to use for the upgrade. If no value is provided the
#~(@@ (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 @@ which lets you search for packages that provide a given file.")
(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 @@ which lets you search for packages that provide a given file.")
(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 @@ which lets you search for packages that provide a given file.")
;; 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))