From nobody Wed Feb 22 12:29:16 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PMFp53PKkz3sxC1; Wed, 22 Feb 2023 12:29:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PMFp5100pz3KK0; Wed, 22 Feb 2023 12:29:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677068957; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GBDzAdBH4/m22ztjLDSxhPqGi66nUchQQfiHY8zEbYE=; b=bqtiE6A2/T+U7l49j8bZYiBjEuaD2l/mcBXergtVljc/OMwmO5Tzg4l2S8VjFjJ0JqgVp/ wVlT22Uj6EwSlLuye3m2z2KBr8fNbRPtN+4li7Xcgcxz34PWCN9YZSefYNEUyWAQRX4HLA N5k6pn+cc+nZI6Lx7YNgjFNZzbuvWlIXzXC+1c0pIO1cLd1D0bVuplYuqb0wmG/6HUVPAD db5t22k2G/w1X4Gb1sJOwEwL0tvkZ/7+sCHTUDFLbdAfHZfG6I5BuWgb/3X3WT54x8omUN C2RtqHEXjQiObqak+eElHI1mvUSCSqwguw2nwebqqoEH58b9YrfISgQIg8+Dcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677068957; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GBDzAdBH4/m22ztjLDSxhPqGi66nUchQQfiHY8zEbYE=; b=RjZ/mpjoIaHvpx8WqGvJiZfIkGld4V9h9ilQf0OpBsUoAa/5dC0R8X2Gh/cpJS2olFEYvy 0Ve6Qf0+bst6In2ET0XBS4F/P4mwtchZmUQWnU9nKlfQb7Gx4SDqm6rnB0dk/ZWQa2mn8d Myo6Qye+I+hQMxcYyTOdiQFWzyXdWi5BQcLMjVhMpkpnNEJkCLeT4A1lMCJj6dTwPaVlm3 FItdwFi7TauMAsUx+VCTYuniuxCWBESGWCAXbxNeGig4GG3qOGjfGLH57XYmaodw6I0TC9 2i59jQlNaFZyh6oCIi1AIz1U8XzTb26wUKw/weypid7XeqMlcVzpU6ku1FtcIQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1677068957; a=rsa-sha256; cv=none; b=IrEjRHHE6JpYrCYk8fGUbJaxpGMPFYc++UJDX+VC2sI7csfiyC1lquxxvtxUrSyLdeWa0A n5ub3Rh2H5SiLaY4s7+FAKPvbKpVMxjrRnNlrwb1ys4PW8mg3kOIrR+Am5lhuohVEw5kIL kMXrRkRILGRpkyVQYE4w0G51Omiq2xBh7n1Tl627ONuGTId8bcbChui6iY0sWgly+Iwq/c b9opXAD+S3TfXQYSTD3bcnkSGcPzhGNHrNdH1g6+uU+n5SOqXUGVvSbYDweGA3VxaXqQzV MeqrZ4Uy9Fg92sqL30BgnNtV9fD8xQ6p5rEV7xxPDq/GhS/7aaEkYCu2Kxd3Mg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PMFp504Ngz115F; Wed, 22 Feb 2023 12:29:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 31MCTGN9042523; Wed, 22 Feb 2023 12:29:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31MCTGtj042522; Wed, 22 Feb 2023 12:29:16 GMT (envelope-from git) Date: Wed, 22 Feb 2023 12:29:16 GMT Message-Id: <202302221229.31MCTGtj042522@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Piotrowski <0mp@FreeBSD.org> Subject: git: 8f2bb173bfc6 - stable/13 - Introduce startmsg and use it in rc scripts List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: 0mp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8f2bb173bfc6e1a03a56b5098f8d2af740ce743f Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by 0mp: URL: https://cgit.FreeBSD.org/src/commit/?id=8f2bb173bfc6e1a03a56b5098f8d2af740ce743f commit 8f2bb173bfc6e1a03a56b5098f8d2af740ce743f Author: Jose Luis Duran AuthorDate: 2022-03-13 17:48:06 +0000 Commit: Mateusz Piotrowski <0mp@FreeBSD.org> CommitDate: 2023-02-22 12:27:16 +0000 Introduce startmsg and use it in rc scripts startmsg is a new rc.subr(8) function function to be used instead of echo(1) when for boot messages. It replaces the often forgotten check_startmsgs && echo ... with startmsg ... No functional change intended. I adjusted the commit message and did some final clean-ups of the patch before committing. PR: 255207 Reported by: Jose Luis Duran Reviewed by: imp, 0mp Approved by: imp (src) Differential Revision: https://reviews.freebsd.org/D34514 (cherry picked from commit 325ebf37d8efc6488754051fcc2b1aaa40cefd8b) --- libexec/rc/rc.d/bgfsck | 2 +- libexec/rc/rc.d/cleartmp | 4 ++-- libexec/rc/rc.d/fsck | 4 ++-- libexec/rc/rc.d/hostid | 4 ++-- libexec/rc/rc.d/hostname | 4 ++-- libexec/rc/rc.d/ldconfig | 5 ++--- libexec/rc/rc.d/motd | 4 ++-- libexec/rc/rc.d/mountcritlocal | 4 ++-- libexec/rc/rc.d/moused | 4 ++-- libexec/rc/rc.d/newsyslog | 4 ++-- libexec/rc/rc.d/nfsclient | 3 +-- libexec/rc/rc.d/os-release | 4 ++-- libexec/rc/rc.d/pf | 4 ++-- libexec/rc/rc.d/savecore | 2 +- libexec/rc/rc.subr | 11 ++++++++++- share/man/man8/rc.subr.8 | 13 +++++++++++++ 16 files changed, 48 insertions(+), 28 deletions(-) diff --git a/libexec/rc/rc.d/bgfsck b/libexec/rc/rc.d/bgfsck index e83f6fb3634f..aae8ba086f4d 100755 --- a/libexec/rc/rc.d/bgfsck +++ b/libexec/rc/rc.d/bgfsck @@ -39,7 +39,7 @@ bgfsck_start() bgfsck_msg="${bgfsck_msg} in ${background_fsck_delay} seconds" fi if [ -z "${rc_force}" ]; then - check_startmsgs && echo "${bgfsck_msg}." + startmsg "${bgfsck_msg}." fi (sleep ${background_fsck_delay}; nice -4 fsck -B -p) 2>&1 | \ diff --git a/libexec/rc/rc.d/cleartmp b/libexec/rc/rc.d/cleartmp index 72e6c3ee881a..cc5777484305 100755 --- a/libexec/rc/rc.d/cleartmp +++ b/libexec/rc/rc.d/cleartmp @@ -26,7 +26,7 @@ cleartmp_start() ${tmp}/.ICE-unix ${tmp}/.font-unix" if checkyesno ${rcvar1}; then - check_startmsgs && echo "Clearing ${tmp}." + startmsg "Clearing ${tmp}." # This is not needed for mfs, but doesn't hurt anything. # Things to note: @@ -48,7 +48,7 @@ cleartmp_start() elif checkyesno clear_tmp_X; then # Remove X lock files, since they will prevent you from # restarting X. Remove other X related directories. - check_startmsgs && echo "Clearing ${tmp} (X related)." + startmsg "Clearing ${tmp} (X related)." rm -rf ${tmp}/.X[0-9]-lock ${x11_socket_dirs} fi if checkyesno clear_tmp_X; then diff --git a/libexec/rc/rc.d/fsck b/libexec/rc/rc.d/fsck index a7fe9a15d5c3..c46c11af240e 100755 --- a/libexec/rc/rc.d/fsck +++ b/libexec/rc/rc.d/fsck @@ -24,7 +24,7 @@ fsck_start() # During fsck ignore SIGQUIT trap : 3 - check_startmsgs && echo "Starting file system checks:" + startmsg "Starting file system checks:" # Background fsck can only be run with -p if checkyesno background_fsck; then fsck -F -p @@ -37,7 +37,7 @@ fsck_start() echo "Warning! Some of the devices might not be" \ "available; retrying" root_hold_wait - check_startmsgs && echo "Restarting file system checks:" + startmsg "Restarting file system checks:" # Background fsck can only be run with -p if checkyesno background_fsck; then fsck -F -p diff --git a/libexec/rc/rc.d/hostid b/libexec/rc/rc.d/hostid index 3cf7dd42eb6c..01697a1d1e11 100755 --- a/libexec/rc/rc.d/hostid +++ b/libexec/rc/rc.d/hostid @@ -50,9 +50,9 @@ hostid_set() # Set both kern.hostuuid and kern.hostid. # - check_startmsgs && echo "Setting hostuuid: ${uuid}." + startmsg "Setting hostuuid: ${uuid}." ${SYSCTL} kern.hostuuid="${uuid}" >/dev/null - check_startmsgs && echo "Setting hostid: ${id}." + startmsg "Setting hostid: ${id}." ${SYSCTL} kern.hostid=${id} >/dev/null } diff --git a/libexec/rc/rc.d/hostname b/libexec/rc/rc.d/hostname index 148b61fd68f2..9d4c0221ccf6 100755 --- a/libexec/rc/rc.d/hostname +++ b/libexec/rc/rc.d/hostname @@ -72,9 +72,9 @@ hostname_start() # All right, it is safe to invoke hostname(1) now. # - check_startmsgs && echo -n "Setting hostname: ${hostname}" + startmsg -n "Setting hostname: ${hostname}" /bin/hostname "${hostname}" - check_startmsgs && echo '.' + startmsg '.' } load_rc_config $name diff --git a/libexec/rc/rc.d/ldconfig b/libexec/rc/rc.d/ldconfig index 03627df6da06..6e59bc641a0a 100755 --- a/libexec/rc/rc.d/ldconfig +++ b/libexec/rc/rc.d/ldconfig @@ -37,7 +37,7 @@ ldconfig_start() _LDC="${_LDC} ${i}" fi done - check_startmsgs && echo 'ELF ldconfig path:' ${_LDC} + startmsg 'ELF ldconfig path:' ${_LDC} ${ldconfig} -elf ${_ins} ${_LDC} machine_arch=$(sysctl -n hw.machine_arch) @@ -58,8 +58,7 @@ ldconfig_start() _LDC="${_LDC} ${i}" fi done - check_startmsgs && - echo '32-bit compatibility ldconfig path:' ${_LDC} + startmsg '32-bit compatibility ldconfig path:' ${_LDC} ${ldconfig} -32 ${_ins} ${_LDC} ;; esac diff --git a/libexec/rc/rc.d/motd b/libexec/rc/rc.d/motd index e63973945f9d..d9dd60a0f59a 100755 --- a/libexec/rc/rc.d/motd +++ b/libexec/rc/rc.d/motd @@ -26,7 +26,7 @@ motd_start() # Must be done *before* interactive logins are possible # to prevent possible race conditions. # - check_startmsgs && echo -n 'Updating motd:' + startmsg -n 'Updating motd:' if [ ! -f "${TEMPLATE}" ]; then # Create missing template from existing regular motd file, if # one exists. @@ -51,7 +51,7 @@ motd_start() install -C -o root -g wheel -m "${PERMS}" "$T" "${TARGET}" rm -f "$T" - check_startmsgs && echo '.' + startmsg '.' } load_rc_config $name diff --git a/libexec/rc/rc.d/mountcritlocal b/libexec/rc/rc.d/mountcritlocal index f52c565d65c6..c3df4cdbea69 100755 --- a/libexec/rc/rc.d/mountcritlocal +++ b/libexec/rc/rc.d/mountcritlocal @@ -29,7 +29,7 @@ mountcritlocal_start() esac # Mount everything except nfs filesystems. - check_startmsgs && echo -n 'Mounting local filesystems:' + startmsg -n 'Mounting local filesystems:' mount_excludes='no' for i in ${netfs_types}; do fstype=${i%:*} @@ -47,7 +47,7 @@ mountcritlocal_start() err=$? fi - check_startmsgs && echo '.' + startmsg '.' case ${err} in 0) diff --git a/libexec/rc/rc.d/moused b/libexec/rc/rc.d/moused index 84f886c0d9c3..b9ac9e0bd3aa 100755 --- a/libexec/rc/rc.d/moused +++ b/libexec/rc/rc.d/moused @@ -52,9 +52,9 @@ moused_start() mytype="$moused_type" fi - check_startmsgs && echo -n "Starting ${ms} moused" + startmsg -n "Starting ${ms} moused" /usr/sbin/moused ${myflags} -p ${myport} -t ${mytype} ${pidarg} - check_startmsgs && echo '.' + startmsg '.' mousechar_arg= case ${mousechar_start} in diff --git a/libexec/rc/rc.d/newsyslog b/libexec/rc/rc.d/newsyslog index 740fcfeefaf4..38ad64b3d4a0 100755 --- a/libexec/rc/rc.d/newsyslog +++ b/libexec/rc/rc.d/newsyslog @@ -18,9 +18,9 @@ stop_cmd=":" newsyslog_start() { - check_startmsgs && echo -n 'Creating and/or trimming log files' + startmsg -n 'Creating and/or trimming log files' ${command} ${rc_flags} - check_startmsgs && echo '.' + startmsg '.' } load_rc_config $name diff --git a/libexec/rc/rc.d/nfsclient b/libexec/rc/rc.d/nfsclient index 2acfb84d8b09..7516ab6703f4 100755 --- a/libexec/rc/rc.d/nfsclient +++ b/libexec/rc/rc.d/nfsclient @@ -23,8 +23,7 @@ nfsclient_start() # if [ -n "${nfs_access_cache}" ]; then - check_startmsgs && - echo "NFS access cache time=${nfs_access_cache}" + startmsg "NFS access cache time=${nfs_access_cache}" if ! sysctl vfs.nfs.access_cache_timeout=${nfs_access_cache} >/dev/null; then warn "failed to set access cache timeout" fi diff --git a/libexec/rc/rc.d/os-release b/libexec/rc/rc.d/os-release index 16f8cb178db8..4614fb8cc18b 100755 --- a/libexec/rc/rc.d/os-release +++ b/libexec/rc/rc.d/os-release @@ -21,7 +21,7 @@ osrelease_start() { local _version _version_id - check_startmsgs && echo -n "Updating ${osrelease_file} " + startmsg -n "Updating ${osrelease_file} " _version=$(freebsd-version -u) _version_id=${_version%%[^0-9.]*} t=$(mktemp -t os-release) @@ -38,7 +38,7 @@ osrelease_start() __EOF__ install -C -o root -g wheel -m ${osrelease_perms} "$t" "${osrelease_file}" rm -f "$t" - check_startmsgs && echo 'done.' + startmsg 'done.' } load_rc_config $name diff --git a/libexec/rc/rc.d/pf b/libexec/rc/rc.d/pf index fa1b49643cc5..eb9cea6c271e 100755 --- a/libexec/rc/rc.d/pf +++ b/libexec/rc/rc.d/pf @@ -42,13 +42,13 @@ pf_fallback() pf_start() { - check_startmsgs && echo -n 'Enabling pf' + startmsg -n 'Enabling pf' $pf_program -F all > /dev/null 2>&1 $pf_program -f "$pf_rules" $pf_flags || pf_fallback if ! $pf_program -s info | grep -q "Enabled" ; then $pf_program -eq fi - check_startmsgs && echo '.' + startmsg '.' } pf_stop() diff --git a/libexec/rc/rc.d/savecore b/libexec/rc/rc.d/savecore index c39872cf1729..5d8204a1e805 100755 --- a/libexec/rc/rc.d/savecore +++ b/libexec/rc/rc.d/savecore @@ -74,7 +74,7 @@ savecore_start() fi sync else - check_startmsgs && echo 'No core dumps found.' + startmsg 'No core dumps found.' fi } diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr index df91737566d5..db49e79ccaf8 100644 --- a/libexec/rc/rc.subr +++ b/libexec/rc/rc.subr @@ -715,6 +715,15 @@ check_startmsgs() fi } +# +# startmsg +# Preferred method to use when displaying start messages in lieu of echo. +# +startmsg() +{ + check_startmsgs && echo "$@" +} + # # run_rc_command argument # Search for argument in the list of supported commands, which is: @@ -1106,7 +1115,7 @@ run_rc_command() # setup the full command to run # - check_startmsgs && echo "Starting ${name}." + startmsg "Starting ${name}." if [ -n "$_chroot" ]; then _cd= _doit="\ diff --git a/share/man/man8/rc.subr.8 b/share/man/man8/rc.subr.8 index b4de4ea060ad..130962ecdcdf 100644 --- a/share/man/man8/rc.subr.8 +++ b/share/man/man8/rc.subr.8 @@ -73,6 +73,8 @@ .It .Ic run_rc_script Ar file Ar argument .It +.Ic startmsg Oo Fl n Oc Ar message +.It .Ic wait_for_pids Op Ar pid ... .It .Ic warn Ar message @@ -882,6 +884,17 @@ otherwise source .Ar file into the current shell. .El +.It Ic startmsg Oo Fl n Oc Ar message +Display a start message to +.Va stdout . +It should be used instead of +.Xr echo 1 . +The display of this output can be turned off if the +.Xr rc.conf 5 +variable +.Va rc_startmsgs +is set to +.Dq Li NO . .It Ic stop_boot Op Ar always Prevent booting to multiuser mode. If the