summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Sent <richard@freakingpenguin.com>2024-04-29 00:34:20 -0400
committerLudovic Courtès <ludo@gnu.org>2024-09-16 00:16:21 +0200
commit85556e1dab5040e9f570fd2606fef563bf0bbb83 (patch)
tree889c9e4f7dc7c931a4ef9e3ed3e27090e5b09fd6
parent2fcca2dafbfcf8d300177a755e6d42b55d78e50d (diff)
services: admin: Support rebooting after an unattended upgrade
* 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 Signed-off-by: Ludovic Courtès <ludo@gnu.org>
-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 bdaefe3802d..bc4d306c2dc 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -23088,6 +23088,10 @@ system to use for the upgrade. If no value is provided the
23088 #~(@@ (guix system install) installation-os))) 23088 #~(@@ (guix system install) installation-os)))
23089@end lisp 23089@end lisp
23090 23090
23091@item @code{reboot?} (default: @code{#f})
23092This field specifies whether the system should reboot after completing
23093an unattended upgrade.
23094
23091@item @code{services-to-restart} (default: @code{'(mcron)}) 23095@item @code{services-to-restart} (default: @code{'(mcron)})
23092This field specifies the Shepherd services to restart when the upgrade 23096This field specifies the Shepherd services to restart when the upgrade
23093completes. 23097completes.
diff --git a/gnu/services/admin.scm b/gnu/services/admin.scm
index 0b325fddb1e..4882883878a 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.")
420 (default "30 01 * * 0")) 420 (default "30 01 * * 0"))
421 (channels unattended-upgrade-configuration-channels 421 (channels unattended-upgrade-configuration-channels
422 (default #~%default-channels)) 422 (default #~%default-channels))
423 (reboot? unattended-upgrade-configuration-reboot?
424 (default #f))
423 (services-to-restart unattended-upgrade-configuration-services-to-restart 425 (services-to-restart unattended-upgrade-configuration-services-to-restart
424 (default '(mcron))) 426 (default '(mcron)))
425 (system-expiration unattended-upgrade-system-expiration 427 (system-expiration unattended-upgrade-system-expiration
@@ -443,6 +445,9 @@ which lets you search for packages that provide a given file.")
443 (define services 445 (define services
444 (unattended-upgrade-configuration-services-to-restart config)) 446 (unattended-upgrade-configuration-services-to-restart config))
445 447
448 (define reboot?
449 (unattended-upgrade-configuration-reboot? config))
450
446 (define expiration 451 (define expiration
447 (unattended-upgrade-system-expiration config)) 452 (unattended-upgrade-system-expiration config))
448 453
@@ -512,7 +517,13 @@ which lets you search for packages that provide a given file.")
512 517
513 ;; XXX: If 'mcron' has been restarted, perhaps this isn't 518 ;; XXX: If 'mcron' has been restarted, perhaps this isn't
514 ;; reached. 519 ;; reached.
515 (format #t "~a upgrade complete~%" (timestamp)))))) 520 (format #t "~a upgrade complete~%" (timestamp))
521
522 ;; Stopping the root shepherd service triggers a reboot.
523 (when #$reboot?
524 (format #t "~a rebooting system~%" (timestamp))
525 (force-output) ;ensure the entire log is written.
526 (stop-service 'root))))))
516 527
517 (define upgrade 528 (define upgrade
518 (program-file "unattended-upgrade" code)) 529 (program-file "unattended-upgrade" code))