From patchwork Sun Apr 28 21:32:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sent X-Patchwork-Id: 63664 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 7ECB527BBE9; Sun, 28 Apr 2024 22:34:59 +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 B2CBC27BBE2 for ; Sun, 28 Apr 2024 22:34:56 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s1CAX-0001LY-57; Sun, 28 Apr 2024 17:34:45 -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 1s1CAV-0001L5-FR for guix-patches@gnu.org; Sun, 28 Apr 2024 17:34:43 -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 1s1CAV-0007Y7-4L for guix-patches@gnu.org; Sun, 28 Apr 2024 17:34:43 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s1CAo-0002Lm-Ky for guix-patches@gnu.org; Sun, 28 Apr 2024 17:35:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70636] [PATCH] services: admin: Support restarting system after unattended upgrade Resent-From: Richard Sent Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 28 Apr 2024 21:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 70636 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70636@debbugs.gnu.org Cc: Richard Sent X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.17143400829019 (code B ref -1); Sun, 28 Apr 2024 21:35:02 +0000 Received: (at submit) by debbugs.gnu.org; 28 Apr 2024 21:34:42 +0000 Received: from localhost ([127.0.0.1]:53003 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s1CAU-0002LP-C7 for submit@debbugs.gnu.org; Sun, 28 Apr 2024 17:34:42 -0400 Received: from lists.gnu.org ([2001:470:142::17]:43640) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s1CAS-0002LJ-MZ for submit@debbugs.gnu.org; Sun, 28 Apr 2024 17:34:41 -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 1s1CA3-0001IF-DW for guix-patches@gnu.org; Sun, 28 Apr 2024 17:34:15 -0400 Received: from mail-108-mta127.mxroute.com ([136.175.108.127]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s1CA1-0007V9-In for guix-patches@gnu.org; Sun, 28 Apr 2024 17:34:15 -0400 Received: from filter006.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta127.mxroute.com (ZoneMTA) with ESMTPSA id 18f26a125e10008ca2.001 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Sun, 28 Apr 2024 21:34:06 +0000 X-Zone-Loop: 36f9282b432276b75b11623ae604af0acdb61fff39ab 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=ZQKQGZic9TRKbJWO1LufJNvt6tRTEEAqozTWUTzAAwg=; b=pnZZVZ1Du2PAB1FtXeMwCu8/rr QJQi0Qtq3I2e1f9zaNZti8xBR4qZXAUVcnWUsGSpDD8hlcAfzMCJ+2m9lnTHMBNGgEX0uW4FqqWUc G/2/mX0rwgMDHrwuUouNRsLiFrCxgkoqlmcgi/67hR/zcAgnwZzgAAOvA7ml5vwVnDR8XCxcQPVA2 +PMYwx2rjjMWz1vq0VGh+4k4sRWIrpXNIQc9EX3xdOoYVy0CrDyxCMnZP7h4DfAM1qbdYEejXBYH7 nDDJV5gugMpMArwTtsfIv23ODcHLbgbCj/WSiopmkkeA5jHrPojFt1602YR+0rAnNNqvldIpt/gfK U3H13Pcg==; From: Richard Sent Date: Sun, 28 Apr 2024 17:32:47 -0400 Message-ID: <4852ee6c60830311f4f1f06a43af9b471e91ad88.1714339967.git.richard@freakingpenguin.com> MIME-Version: 1.0 X-Authenticated-Id: richard@freakingpenguin.com Received-SPF: pass client-ip=136.175.108.127; envelope-from=richard@freakingpenguin.com; helo=mail-108-mta127.mxroute.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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 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(-) base-commit: 9f183c3627a006e8fd3bb9708448bc05a6204e6d 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* (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))