From patchwork Mon Feb 27 09:20:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Peres X-Patchwork-Id: 34 Return-Path: Delivered-To: patchwork@archlinux.org Received: from nymeria.archlinux.org by nymeria.archlinux.org (Dovecot) with LMTP id rDZlDnHvs1jTQAAAtiB/HQ for ; Mon, 27 Feb 2017 10:20:49 +0100 Received: from nymeria.archlinux.org (localhost.localdomain [127.0.0.1]) by nymeria.archlinux.org (Postfix) with ESMTP id 795664027F; Mon, 27 Feb 2017 10:20:47 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on nymeria.archlinux.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.5 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_MED shortcircuit=no autolearn=unavailable autolearn_force=no version=3.4.1 Received: from luna.archlinux.org (luna.archlinux.org [IPv6:2a01:4f8:160:3033::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by nymeria.archlinux.org (Postfix) with ESMTPS; Mon, 27 Feb 2017 10:20:47 +0100 (CET) Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 33FD727F5F; Mon, 27 Feb 2017 09:20:47 +0000 (UTC) Authentication-Results: luna.archlinux.org; dkim=none Received: from luna.archlinux.org (luna.archlinux.org [127.0.0.1]) by luna.archlinux.org (Postfix) with ESMTP id 933C923672 for ; Mon, 27 Feb 2017 09:20:44 +0000 (UTC) Received: from nymeria.archlinux.org (nymeria.archlinux.org [89.238.67.251]) by luna.archlinux.org (Postfix) with ESMTPS for ; Mon, 27 Feb 2017 09:20:44 +0000 (UTC) Received: from nymeria.archlinux.org (localhost.localdomain [127.0.0.1]) by nymeria.archlinux.org (Postfix) with ESMTP id 1C53340159 for ; Mon, 27 Feb 2017 10:20:43 +0100 (CET) Received: from smtp3-g21.free.fr (smtp3-g21.free.fr [212.27.42.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by nymeria.archlinux.org (Postfix) with ESMTPS for ; Mon, 27 Feb 2017 10:20:43 +0100 (CET) Received: from localhost.localdomain (unknown [62.78.152.186]) (Authenticated sender: martin.peres) by smtp3-g21.free.fr (Postfix) with ESMTPSA id 03A4613F88D; Mon, 27 Feb 2017 10:20:38 +0100 (CET) From: Martin Peres To: arch-projects@archlinux.org Date: Mon, 27 Feb 2017 11:20:26 +0200 Message-Id: <20170227092026.29134-1-martin.peres@free.fr> X-Mailer: git-send-email 2.11.1 Subject: [arch-projects] [mkinitcpio][PATCH] init: introduce a non-interactive mode (rd.noninteractive) X-BeenThere: arch-projects@archlinux.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Arch Linux projects development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Arch Linux projects development discussion Errors-To: arch-projects-bounces@archlinux.org Sender: "arch-projects" X-UID: 95 Status: X-Keywords: Content-Length: 2712 CI systems compile and boot on kernels that are sometimes broken and fail to find the root device. This patch adds a new parameter (rd.noninteractive) that prevents starting an interactive shell and reboots the machine 2 seconds after warning the user about the issue. This allows me to test the kernel faster than would be possible using external watchdogs which would require at least 2 minutes before kicking in. --- init_functions | 16 ++++++++++++++++ man/mkinitcpio.8.txt | 3 +++ test/test_parse_cmdline | 2 ++ 3 files changed, 21 insertions(+) diff --git a/init_functions b/init_functions index d5a584e..7287086 100644 --- a/init_functions +++ b/init_functions @@ -47,6 +47,19 @@ poll_device() { } launch_interactive_shell() { + if [ -n "$rd_noninteractive" ]; then + printf '%s\n' \ + "************** REBOOT REQUIRED **************" \ + "* *" \ + "* running in non-interactive mode *" \ + "* - *" \ + "* automatically restarting in 2 seconds *" \ + "* *" \ + "*********************************************" + sleep 2 + reboot -f + fi + export PS1='[rootfs \W]\$ ' # explicitly redirect to /dev/console in case we're logging. note that @@ -174,6 +187,9 @@ parse_cmdline_item() { rd_logmask=$(( _rdlog_kmsg | _rdlog_cons )) fi ;; + rd.noninteractive) + rd_noninteractive=y + ;; [![:alpha:]_]*|[[:alpha:]_]*[![:alnum:]_]*) # invalid shell variable, ignore it ;; diff --git a/man/mkinitcpio.8.txt b/man/mkinitcpio.8.txt index 5c3118e..d9410dc 100644 --- a/man/mkinitcpio.8.txt +++ b/man/mkinitcpio.8.txt @@ -292,6 +292,9 @@ the kernel command line: *all*;; Writes output to all known log targets. +*rd.noninteractive*:: + If specified, reboot the machine instead of starting an interactive shell. + These are only the variables that the core of mkinitcpio honor. Additional hooks may look for other environment variables and should be documented by the help output for the hook. diff --git a/test/test_parse_cmdline b/test/test_parse_cmdline index ff855e4..9249962 100755 --- a/test/test_parse_cmdline +++ b/test/test_parse_cmdline @@ -217,6 +217,8 @@ test_parse 'rd.log=kmsg' \ 'rd_logmask' '2' test_parse 'rd.log=file' \ 'rd_logmask' '1' +test_parse 'rd.noninteractive' \ + 'rd_noninteractive' 'y' # a mix of stuff test_parse 'foo=bar bareword bar="ba az"' \