From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id E5E16138335 for ; Wed, 7 Aug 2019 15:46:14 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DF35CE08AD; Wed, 7 Aug 2019 15:46:13 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id B83FFE088C for ; Wed, 7 Aug 2019 15:46:13 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id A1820349491 for ; Wed, 7 Aug 2019 15:46:12 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id DEB0F759 for ; Wed, 7 Aug 2019 15:46:09 +0000 (UTC) From: "Thomas Deutschmann" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Thomas Deutschmann" Message-ID: <1565124031.5124ba044c454c112e756c5e8024650a64008609.whissi@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: defaults/ X-VCS-Repository: proj/genkernel X-VCS-Files: defaults/initrd.defaults defaults/initrd.scripts defaults/linuxrc defaults/unlock-luks.sh X-VCS-Directories: defaults/ X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: 5124ba044c454c112e756c5e8024650a64008609 X-VCS-Branch: master Date: Wed, 7 Aug 2019 15:46:09 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 5fecc691-df82-4969-84bc-76f14dc8d564 X-Archives-Hash: 1464642ac4563629ae742675fc293787 commit: 5124ba044c454c112e756c5e8024650a64008609 Author: Thomas Deutschmann gentoo org> AuthorDate: Tue Aug 6 15:11:39 2019 +0000 Commit: Thomas Deutschmann gentoo org> CommitDate: Tue Aug 6 20:40:31 2019 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=5124ba04 linuxrc: Rework debug mode This commit will introduce $GK_DEBUGMODE_STATEFILE and a new function is_debug() to check if debug mode is enabled or not. Using a state file instead of a variable will allow us to enable/disable debug mode from outside: I.e. when you have booted in debug mode and are working remotely, you can now remove the state file, which will disable debug mode. This will allow you to resume booting without dropping in another local debug shell. It works the other way, too: When you did NOT boot in debug mode but experiencing a problem and want to drop in another debug shell after next step, you can now enable debug mode by creating the state file. Signed-off-by: Thomas Deutschmann gentoo.org> defaults/initrd.defaults | 1 + defaults/initrd.scripts | 34 ++++++++++++++++++++++++---------- defaults/linuxrc | 2 +- defaults/unlock-luks.sh | 2 +- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults index 704a5a2..89d13ac 100644 --- a/defaults/initrd.defaults +++ b/defaults/initrd.defaults @@ -70,6 +70,7 @@ CDROOT_MARKER='/livecd' VERIFY=0 IP='dhcp' +GK_DEBUGMODE_STATEFILE="/tmp/debug.enabled" GK_NET_DHCP_PIDFILE='/var/run/udhcpc.pid' GK_NET_DHCP_RETRIES=3 GK_NET_GW= diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index 1f7dc94..994f0f0 100644 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -49,7 +49,7 @@ modules_scan() { break fi - if [ -n "${DEBUG}" ] + if is_debug then printf "%b" "${BOLD} ::${NORMAL} " printf "%b" "Scanning for ${x} ..." @@ -58,12 +58,12 @@ modules_scan() { modprobe ${x} >/dev/null 2>&1 loaded=${?} - [ -n "${DEBUG}" -a "${loaded}" = "0" ] && \ + is_debug && [ "${loaded}" = "0" ] && \ echo "loaded" - [ -n "${DEBUG}" -a "${loaded}" != "0" ] && \ + is_debug && [ "${loaded}" != "0" ] && \ echo "not loaded" - [ -z "${DEBUG}" -a "${loaded}" = "0" ] && \ + ! is_debug && [ "${loaded}" = "0" ] && \ [ -z "${QUIET}" ] && \ printf "%b" "${x} " else @@ -462,6 +462,17 @@ conf_rc_no_umounts() { fi } +is_debug() { + is_debug=1 + + if [ -f "${GK_DEBUGMODE_STATEFILE}" ] + then + is_debug=0 + fi + + return ${is_debug} +} + # is_int "${A}" ["${B}"..] # NOTE we consider a leading 0 false as it would be interpreted as octal is_int() { @@ -880,7 +891,7 @@ test_success() { # $2 hide flag good_msg() { - [ -n "${QUIET}" ] && [ -z "${DEBUG}" ] && return 0 + [ -n "${QUIET}" ] && ! is_debug && return 0 msg_string=${1} msg_string="${msg_string:-...}" @@ -888,7 +899,7 @@ good_msg() { } good_msg_n() { - [ -n "${QUIET}" ] && [ -z "${DEBUG}" ] && return 0 + [ -n "${QUIET}" ] && ! is_debug && return 0 msg_string=${1} msg_string="${msg_string:-...}" @@ -1943,7 +1954,7 @@ start_sshd() { # setup environment variables for the ssh login shell local varname= varvalue= touch "${CRYPT_ENV_FILE}" - for varname in CRYPT_ROOT CRYPT_ROOT_TRIM CRYPT_SILENT CRYPT_SWAP DEBUG + for varname in CRYPT_ROOT CRYPT_ROOT_TRIM CRYPT_SILENT CRYPT_SWAP do eval varvalue=\$${varname} echo "${varname}=${varvalue}" >> "${CRYPT_ENV_FILE}" @@ -2106,12 +2117,15 @@ setup_md_device() { } rundebugshell() { - if [ -n "${DEBUG}" ] + if is_debug then good_msg 'Starting debug shell as requested by "debug" option.' - good_msg "Stopping by: ${1}" - run_shell + else + return 0 fi + + good_msg "Stopping by: ${1}" + run_shell } do_resume() { diff --git a/defaults/linuxrc b/defaults/linuxrc index d729806..dcae3cc 100644 --- a/defaults/linuxrc +++ b/defaults/linuxrc @@ -153,7 +153,7 @@ do ;; # Debug Options debug) - DEBUG='yes' + touch "${GK_DEBUGMODE_STATEFILE}" ;; # Scan delay options scandelay=*) diff --git a/defaults/unlock-luks.sh b/defaults/unlock-luks.sh index cae5269..e8f28f6 100644 --- a/defaults/unlock-luks.sh +++ b/defaults/unlock-luks.sh @@ -106,7 +106,7 @@ main() { if [ -s "${LUKS_KEY}" ] then - if [ "${DEBUG}" != 'yes' ] + if ! is_debug then rm -f "${LUKS_KEY}" else