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 0C0F81382C5 for ; Sun, 21 Mar 2021 22:36:13 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 52DE1E0876; Sun, 21 Mar 2021 22:36:12 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (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 29B29E0876 for ; Sun, 21 Mar 2021 22:36:12 +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 89CC0335D26 for ; Sun, 21 Mar 2021 22:36:10 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id E873C5D2 for ; Sun, 21 Mar 2021 22:36:08 +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: <1616351043.92e8f61d4e151549b6e66a073461f7d1dc3659f6.whissi@gentoo> Subject: [gentoo-commits] proj/genkernel:master commit in: defaults/ X-VCS-Repository: proj/genkernel X-VCS-Files: defaults/initrd.scripts X-VCS-Directories: defaults/ X-VCS-Committer: whissi X-VCS-Committer-Name: Thomas Deutschmann X-VCS-Revision: 92e8f61d4e151549b6e66a073461f7d1dc3659f6 X-VCS-Branch: master Date: Sun, 21 Mar 2021 22:36:08 +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: 4d18880b-4d20-4124-be6a-73ab3762aacd X-Archives-Hash: 325666f90a89a2e20f024347ef09585a commit: 92e8f61d4e151549b6e66a073461f7d1dc3659f6 Author: Thomas Deutschmann gentoo org> AuthorDate: Sat Mar 20 17:23:44 2021 +0000 Commit: Thomas Deutschmann gentoo org> CommitDate: Sun Mar 21 18:24:03 2021 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=92e8f61d initrd.scripts: Add is_quiet() function Signed-off-by: Thomas Deutschmann gentoo.org> defaults/initrd.scripts | 65 +++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index ccbc16d..cbeb6bc 100644 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -85,16 +85,16 @@ modules_scan() { fi log_msg "Loading modules of module group '${1}' (smart loading: ${smart_loading}) ..." - [ -z "${QUIET}" ] && \ - printf "%b" "${BOLD} ::${NORMAL} Loading from ${1}: " + is_quiet \ + || printf "%b" "${BOLD} ::${NORMAL} Loading from ${1}: " for x in ${MODS} do MLOAD=$(echo ${MLIST} | sed -e "s/.*${x}.*/${x}/") if [ "${MLOAD}" = "${x}" ] # Only module to no-load then - [ -z "${QUIET}" ] && \ - printf "%b\n" "${BOLD} ::${NORMAL} Skipping ${x} ..." + is_quiet \ + || printf "%b\n" "${BOLD} ::${NORMAL} Skipping ${x} ..." elif [ "${MLOAD}" = "${MLIST}" ] then if [ "${smart_loading}" = "yes" ] @@ -131,14 +131,15 @@ modules_scan() { echo "not loaded" ! is_debug && [ "${loaded}" = "0" ] && \ - [ -z "${QUIET}" ] && \ + ! is_quiet && \ printf "%b" "${x} " else - [ -z "${QUIET}" ] && \ - printf "%b\n" "${BOLD} ::${NORMAL} Skipping ${x} ..." + is_quiet \ + || printf "%b\n" "${BOLD} ::${NORMAL} Skipping ${x} ..." fi done - [ -z "${QUIET}" ] && echo + + is_quiet || echo } uppercase() { @@ -627,6 +628,12 @@ is_log_enabled() { return 0 } +is_quiet() { + is_true "${QUIET}" && return 0 + + return 1 +} + is_true() { case "${1}" in 1) @@ -1174,7 +1181,7 @@ good_msg() { log_msg "[OK] ${msg_string}" - [ "${2-${QUIET}}" != '1' ] && printf "%b\n" "${GOOD}>>${NORMAL}${BOLD} ${msg_string} ${NORMAL}" + is_true "${2-${QUIET}}" || printf "%b\n" "${GOOD}>>${NORMAL}${BOLD} ${msg_string} ${NORMAL}" } good_msg_n() { @@ -1183,7 +1190,7 @@ good_msg_n() { log_msg "[OK] ${msg_string}" - [ "${2-${QUIET}}" != '1' ] && printf "%b" "${GOOD}>>${NORMAL}${BOLD} ${msg_string}" + is_true "${2-${QUIET}}" || printf "%b" "${GOOD}>>${NORMAL}${BOLD} ${msg_string}" } bad_msg() { @@ -1202,7 +1209,7 @@ warn_msg() { log_msg "[**] ${msg_string}" - [ "${2-${QUIET}}" != '1' ] && printf "%b\n" "${WARN}**${NORMAL}${BOLD} ${msg_string} ${NORMAL}" + is_true "${2-${QUIET}}" || printf "%b\n" "${WARN}**${NORMAL}${BOLD} ${msg_string} ${NORMAL}" } warn_msg_n() { @@ -1211,7 +1218,7 @@ warn_msg_n() { log_msg "[**] ${msg_string}" - [ "${2-${QUIET}}" != '1' ] && printf "%b" "${WARN}**${NORMAL}${BOLD} ${msg_string}" + is_true "${2-${QUIET}}" || printf "%b" "${WARN}**${NORMAL}${BOLD} ${msg_string}" } write_env_file() { @@ -1625,7 +1632,7 @@ start_volumes() { local lvm_cmd="run lvm vgscan 2>&1" is_log_enabled && lvm_cmd="${lvm_cmd} | tee -a '${GK_INIT_LOG}'" - [ -n "${QUIET}" ] && lvm_cmd="${lvm_cmd} 1>/dev/null" + is_quiet && lvm_cmd="${lvm_cmd} 1>/dev/null" eval "${lvm_cmd}" if [ $? -ne 0 ] @@ -1641,7 +1648,7 @@ start_volumes() { # To activate volumegroups on all devices in the cache local lvm_cmd="run lvm vgchange -ay --sysinit 2>&1" is_log_enabled && lvm_cmd="${lvm_cmd} | tee -a '${GK_INIT_LOG}'" - [ -n "${QUIET}" ] && lvm_cmd="${lvm_cmd} 1>/dev/null" + is_quiet && lvm_cmd="${lvm_cmd} 1>/dev/null" eval "${lvm_cmd}" if [ $? -ne 0 ] @@ -1663,7 +1670,7 @@ start_volumes() { local zfs_cmd="run /sbin/zpool import -N -a ${ZPOOL_CACHE} ${ZPOOL_FORCE} 2>&1" is_log_enabled && zfs_cmd="${zfs_cmd} | tee -a '${GK_INIT_LOG}'" - [ -n "${QUIET}" ] && zfs_cmd="${zfs_cmd} 1>/dev/null" + is_quiet && zfs_cmd="${zfs_cmd} 1>/dev/null" eval "${zfs_cmd}" if [ $? -ne 0 ] @@ -1681,7 +1688,7 @@ start_volumes() { local zfs_cmd="run /sbin/zpool export -f '${ZFS_POOL}' 2>&1" is_log_enabled && zfs_cmd="${zfs_cmd} | tee -a '${GK_INIT_LOG}'" - [ -n "${QUIET}" ] && zfs_cmd="${zfs_cmd} 1>/dev/null" + is_quiet && zfs_cmd="${zfs_cmd} 1>/dev/null" eval "${zfs_cmd}" if [ $? -ne 0 ] @@ -1693,7 +1700,7 @@ start_volumes() { zfs_cmd="run /sbin/zpool import -N ${ZPOOL_CACHE} ${ZPOOL_FORCE} '${ZFS_POOL}' 2>&1" is_log_enabled && zfs_cmd="${zfs_cmd} | tee -a '${GK_INIT_LOG}'" - [ -n "${QUIET}" ] && zfs_cmd="${zfs_cmd} 1>/dev/null" + is_quiet && zfs_cmd="${zfs_cmd} 1>/dev/null" eval "${zfs_cmd}" if [ $? -ne 0 ] @@ -1706,7 +1713,7 @@ start_volumes() { local zfs_cmd="run /sbin/zpool import -N ${ZPOOL_CACHE} ${ZPOOL_FORCE} '${ZFS_POOL}' 2>&1" is_log_enabled && zfs_cmd="${zfs_cmd} | tee -a '${GK_INIT_LOG}'" - [ -n "${QUIET}" ] && zfs_cmd="${zfs_cmd} 1>/dev/null" + is_quiet && zfs_cmd="${zfs_cmd} 1>/dev/null" eval "${zfs_cmd}" if [ $? -ne 0 ] @@ -1729,7 +1736,7 @@ start_iscsi() { iscsi_cmd="run iscsistart -b 2>&1" is_log_enabled && iscsi_cmd="${iscsi_cmd} | tee -a '${GK_INIT_LOG}'" - [ -n "${QUIET}" ] && iscsi_cmd="${iscsi_cmd} 1>/dev/null" + is_quiet && iscsi_cmd="${iscsi_cmd} 1>/dev/null" eval "${iscsi_cmd}" if [ $? -ne 0 ] @@ -1783,7 +1790,7 @@ start_iscsi() { iscsi_cmd="run iscsistart -i '${ISCSI_INITIATORNAME}' -t '${ISCSI_TARGET}' -a '${ISCSI_ADDRESS}' ${ADDITIONAL} 2>&1" is_log_enabled && iscsi_cmd="${iscsi_cmd} | tee -a '${GK_INIT_LOG}'" - [ -n "${QUIET}" ] && iscsi_cmd="${iscsi_cmd} 1>/dev/null" + is_quiet && iscsi_cmd="${iscsi_cmd} 1>/dev/null" eval "${iscsi_cmd}" if [ $? -ne 0 ] @@ -2142,12 +2149,12 @@ start_network() { let interface_timeout_100msec_modulo=${interface_time_waited}%10 if [ ${interface_timeout_100msec_modulo} = 0 ] then - [ -z "${QUIET}" ] && printf "." + is_quiet || printf "." fi fi done - [ -z "${QUIET}" ] && echo + is_quiet || echo if [ "${have_interface}" != '1' ] then @@ -2271,10 +2278,10 @@ kill_network() { ipv6_tentative || break sleep 1 : $(( dad_timeout -= 1 )) - [ -z "${QUIET}" ] && printf "." + is_quiet || printf "." done - [ -z "${QUIET}" ] && echo '' + is_quiet || echo if [ ${dad_timeout} -le 0 ] then @@ -2296,10 +2303,10 @@ kill_network() { fi sleep 1 : $(( deconfiguration_timeout -= 1 )) - [ -z "${QUIET}" ] && printf "." + is_quiet || printf "." done - [ -z "${QUIET}" ] && echo '' + is_quiet || echo if [ ${deconfiguration_timeout} -le 0 ] then @@ -2433,10 +2440,10 @@ wait_sshd() { fi sleep 1 : $(( ssh_timeout -= 1 )) - [ -z "${QUIET}" ] && printf "." + is_quiet || printf "." done - [ -z "${QUIET}" ] && echo "" + is_quiet || echo } kill_sshd() { @@ -2494,7 +2501,7 @@ sdelay() { do let SDELAY=${SDELAY}-1 sleep 1 - [ -z "${QUIET}" ] && printf "." + is_quiet || printf "." done echo elif [ "${CDROOT}" = '1' ]