From patchwork Mon Apr 29 04:34:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sent X-Patchwork-Id: 63665 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id C846F27BBE2; Mon, 29 Apr 2024 05:36:24 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1F3B927BBE9 for ; Mon, 29 Apr 2024 05:36:22 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s1IkO-0002ms-Sm; Mon, 29 Apr 2024 00:36:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s1Ijw-0002hE-8w for guix-patches@gnu.org; Mon, 29 Apr 2024 00:35:47 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s1Iju-0006R0-FK for guix-patches@gnu.org; Mon, 29 Apr 2024 00:35:44 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s1IkD-0001Vz-OD for guix-patches@gnu.org; Mon, 29 Apr 2024 00:36:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70636] [PATCH v2] services: admin: Support rebooting after an unattended upgrade References: <4852ee6c60830311f4f1f06a43af9b471e91ad88.1714339967.git.richard@freakingpenguin.com> In-Reply-To: <4852ee6c60830311f4f1f06a43af9b471e91ad88.1714339967.git.richard@freakingpenguin.com> Resent-From: Richard Sent Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 29 Apr 2024 04:36:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70636 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70636@debbugs.gnu.org Cc: Richard Sent Received: via spool by 70636-submit@debbugs.gnu.org id=B70636.17143653425817 (code B ref 70636); Mon, 29 Apr 2024 04:36:01 +0000 Received: (at 70636) by debbugs.gnu.org; 29 Apr 2024 04:35:42 +0000 Received: from localhost ([127.0.0.1]:54777 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s1Iju-0001Vl-1L for submit@debbugs.gnu.org; Mon, 29 Apr 2024 00:35:42 -0400 Received: from mail-108-mta26.mxroute.com ([136.175.108.26]:35283) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s1Ijr-0001Vc-8k for 70636@debbugs.gnu.org; Mon, 29 Apr 2024 00:35:40 -0400 Received: from filter006.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta26.mxroute.com (ZoneMTA) with ESMTPSA id 18f2822c0710008ca2.001 for <70636@debbugs.gnu.org> (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Mon, 29 Apr 2024 04:35:17 +0000 X-Zone-Loop: 4bf38bc1e917ece841b377cbea9ec4835d22e6fea439 X-Originating-IP: [136.175.111.2] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=freakingpenguin.com; s=x; h=Content-Transfer-Encoding:MIME-Version: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=j5FzwphsdUTcPH+xFgY3VTDHsFIK4MnIelP+Ah36JG0=; b=T6Kv2nA0lKb7vxR5CWb51R0H4s ZN4mX+rIRMS9ZzhBPTbjmYSNrcjNWfIh1gLVJ0hEkdHRjyc2Vtt+esgAaC2wX8GXOvXCs4b4i54hx n4IEAF0gZoUdCJLI+lZfBpwhqE3WzBDnaAZa0WLHyyiPUgDVrUFggEtfGuzzbxcSHRTSCuWIWEWcb vYPCAu0a6LVhqdjiT2oZXoxyJVCdfzwBELu6Om4LcWEk4GdflHC9fr6tB6JVTJrKZR757p55SLTnf IiOLYvJric3ur1Xk8BGTFzt062ojeRgfGo0EyrGWxyfOQFzAh0iUHAEI9M62dMDASKH1J//GzSTCs nERf46aA==; From: Richard Sent Date: Mon, 29 Apr 2024 00:34:20 -0400 Message-ID: <8e12822dfa63081eaca99f204a78965fc6db3a01.1714365260.git.richard@freakingpenguin.com> MIME-Version: 1.0 X-Authenticated-Id: richard@freakingpenguin.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * 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(-) base-commit: 3bd8d238aba718bf949691d0e37fa310e2cfc12a 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* (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))