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 <jlduran@gmail.com> Reviewed by: imp, 0mp Approved by: imp (src) Differential Revision: https://reviews.freebsd.org/D34514
This commit is contained in:
parent
e83a53abeb
commit
325ebf37d8
@ -39,7 +39,7 @@ bgfsck_start()
|
|||||||
bgfsck_msg="${bgfsck_msg} in ${background_fsck_delay} seconds"
|
bgfsck_msg="${bgfsck_msg} in ${background_fsck_delay} seconds"
|
||||||
fi
|
fi
|
||||||
if [ -z "${rc_force}" ]; then
|
if [ -z "${rc_force}" ]; then
|
||||||
check_startmsgs && echo "${bgfsck_msg}."
|
startmsg "${bgfsck_msg}."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
(sleep ${background_fsck_delay}; nice -4 fsck -B -p) 2>&1 | \
|
(sleep ${background_fsck_delay}; nice -4 fsck -B -p) 2>&1 | \
|
||||||
|
@ -26,7 +26,7 @@ cleartmp_start()
|
|||||||
${tmp}/.ICE-unix ${tmp}/.font-unix"
|
${tmp}/.ICE-unix ${tmp}/.font-unix"
|
||||||
|
|
||||||
if checkyesno ${rcvar1}; then
|
if checkyesno ${rcvar1}; then
|
||||||
check_startmsgs && echo "Clearing ${tmp}."
|
startmsg "Clearing ${tmp}."
|
||||||
|
|
||||||
# This is not needed for mfs, but doesn't hurt anything.
|
# This is not needed for mfs, but doesn't hurt anything.
|
||||||
# Things to note:
|
# Things to note:
|
||||||
@ -48,7 +48,7 @@ cleartmp_start()
|
|||||||
elif checkyesno clear_tmp_X; then
|
elif checkyesno clear_tmp_X; then
|
||||||
# Remove X lock files, since they will prevent you from
|
# Remove X lock files, since they will prevent you from
|
||||||
# restarting X. Remove other X related directories.
|
# 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}
|
rm -rf ${tmp}/.X[0-9]-lock ${x11_socket_dirs}
|
||||||
fi
|
fi
|
||||||
if checkyesno clear_tmp_X; then
|
if checkyesno clear_tmp_X; then
|
||||||
|
@ -24,7 +24,7 @@ fsck_start()
|
|||||||
# During fsck ignore SIGQUIT
|
# During fsck ignore SIGQUIT
|
||||||
trap : 3
|
trap : 3
|
||||||
|
|
||||||
check_startmsgs && echo "Starting file system checks:"
|
startmsg "Starting file system checks:"
|
||||||
# Background fsck can only be run with -p
|
# Background fsck can only be run with -p
|
||||||
if checkyesno background_fsck; then
|
if checkyesno background_fsck; then
|
||||||
fsck -F -p
|
fsck -F -p
|
||||||
@ -37,7 +37,7 @@ fsck_start()
|
|||||||
echo "Warning! Some of the devices might not be" \
|
echo "Warning! Some of the devices might not be" \
|
||||||
"available; retrying"
|
"available; retrying"
|
||||||
root_hold_wait
|
root_hold_wait
|
||||||
check_startmsgs && echo "Restarting file system checks:"
|
startmsg "Restarting file system checks:"
|
||||||
# Background fsck can only be run with -p
|
# Background fsck can only be run with -p
|
||||||
if checkyesno background_fsck; then
|
if checkyesno background_fsck; then
|
||||||
fsck -F -p
|
fsck -F -p
|
||||||
|
@ -50,9 +50,9 @@ hostid_set()
|
|||||||
|
|
||||||
# Set both kern.hostuuid and kern.hostid.
|
# Set both kern.hostuuid and kern.hostid.
|
||||||
#
|
#
|
||||||
check_startmsgs && echo "Setting hostuuid: ${uuid}."
|
startmsg "Setting hostuuid: ${uuid}."
|
||||||
${SYSCTL} kern.hostuuid="${uuid}" >/dev/null
|
${SYSCTL} kern.hostuuid="${uuid}" >/dev/null
|
||||||
check_startmsgs && echo "Setting hostid: ${id}."
|
startmsg "Setting hostid: ${id}."
|
||||||
${SYSCTL} kern.hostid=${id} >/dev/null
|
${SYSCTL} kern.hostid=${id} >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,9 +72,9 @@ hostname_start()
|
|||||||
|
|
||||||
# All right, it is safe to invoke hostname(1) now.
|
# 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}"
|
/bin/hostname "${hostname}"
|
||||||
check_startmsgs && echo '.'
|
startmsg '.'
|
||||||
}
|
}
|
||||||
|
|
||||||
load_rc_config $name
|
load_rc_config $name
|
||||||
|
@ -37,7 +37,7 @@ ldconfig_start()
|
|||||||
_LDC="${_LDC} ${i}"
|
_LDC="${_LDC} ${i}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
check_startmsgs && echo 'ELF ldconfig path:' ${_LDC}
|
startmsg 'ELF ldconfig path:' ${_LDC}
|
||||||
${ldconfig} -elf ${_ins} ${_LDC}
|
${ldconfig} -elf ${_ins} ${_LDC}
|
||||||
|
|
||||||
machine_arch=$(sysctl -n hw.machine_arch)
|
machine_arch=$(sysctl -n hw.machine_arch)
|
||||||
@ -58,8 +58,7 @@ ldconfig_start()
|
|||||||
_LDC="${_LDC} ${i}"
|
_LDC="${_LDC} ${i}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
check_startmsgs &&
|
startmsg '32-bit compatibility ldconfig path:' ${_LDC}
|
||||||
echo '32-bit compatibility ldconfig path:' ${_LDC}
|
|
||||||
${ldconfig} -32 ${_ins} ${_LDC}
|
${ldconfig} -32 ${_ins} ${_LDC}
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -26,7 +26,7 @@ motd_start()
|
|||||||
# Must be done *before* interactive logins are possible
|
# Must be done *before* interactive logins are possible
|
||||||
# to prevent possible race conditions.
|
# to prevent possible race conditions.
|
||||||
#
|
#
|
||||||
check_startmsgs && echo -n 'Updating motd:'
|
startmsg -n 'Updating motd:'
|
||||||
if [ ! -f "${TEMPLATE}" ]; then
|
if [ ! -f "${TEMPLATE}" ]; then
|
||||||
# Create missing template from existing regular motd file, if
|
# Create missing template from existing regular motd file, if
|
||||||
# one exists.
|
# one exists.
|
||||||
@ -51,7 +51,7 @@ motd_start()
|
|||||||
install -C -o root -g wheel -m "${PERMS}" "$T" "${TARGET}"
|
install -C -o root -g wheel -m "${PERMS}" "$T" "${TARGET}"
|
||||||
rm -f "$T"
|
rm -f "$T"
|
||||||
|
|
||||||
check_startmsgs && echo '.'
|
startmsg '.'
|
||||||
}
|
}
|
||||||
|
|
||||||
load_rc_config $name
|
load_rc_config $name
|
||||||
|
@ -29,7 +29,7 @@ mountcritlocal_start()
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
# Mount everything except nfs filesystems.
|
# Mount everything except nfs filesystems.
|
||||||
check_startmsgs && echo -n 'Mounting local filesystems:'
|
startmsg -n 'Mounting local filesystems:'
|
||||||
mount_excludes='no'
|
mount_excludes='no'
|
||||||
for i in ${netfs_types}; do
|
for i in ${netfs_types}; do
|
||||||
fstype=${i%:*}
|
fstype=${i%:*}
|
||||||
@ -47,7 +47,7 @@ mountcritlocal_start()
|
|||||||
err=$?
|
err=$?
|
||||||
fi
|
fi
|
||||||
|
|
||||||
check_startmsgs && echo '.'
|
startmsg '.'
|
||||||
|
|
||||||
case ${err} in
|
case ${err} in
|
||||||
0)
|
0)
|
||||||
|
@ -52,9 +52,9 @@ moused_start()
|
|||||||
mytype="$moused_type"
|
mytype="$moused_type"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
check_startmsgs && echo -n "Starting ${ms} moused"
|
startmsg -n "Starting ${ms} moused"
|
||||||
/usr/sbin/moused ${myflags} -p ${myport} -t ${mytype} ${pidarg}
|
/usr/sbin/moused ${myflags} -p ${myport} -t ${mytype} ${pidarg}
|
||||||
check_startmsgs && echo '.'
|
startmsg '.'
|
||||||
|
|
||||||
mousechar_arg=
|
mousechar_arg=
|
||||||
case ${mousechar_start} in
|
case ${mousechar_start} in
|
||||||
|
@ -18,9 +18,9 @@ stop_cmd=":"
|
|||||||
|
|
||||||
newsyslog_start()
|
newsyslog_start()
|
||||||
{
|
{
|
||||||
check_startmsgs && echo -n 'Creating and/or trimming log files'
|
startmsg -n 'Creating and/or trimming log files'
|
||||||
${command} ${rc_flags}
|
${command} ${rc_flags}
|
||||||
check_startmsgs && echo '.'
|
startmsg '.'
|
||||||
}
|
}
|
||||||
|
|
||||||
load_rc_config $name
|
load_rc_config $name
|
||||||
|
@ -23,8 +23,7 @@ nfsclient_start()
|
|||||||
#
|
#
|
||||||
|
|
||||||
if [ -n "${nfs_access_cache}" ]; then
|
if [ -n "${nfs_access_cache}" ]; then
|
||||||
check_startmsgs &&
|
startmsg "NFS access cache time=${nfs_access_cache}"
|
||||||
echo "NFS access cache time=${nfs_access_cache}"
|
|
||||||
if ! sysctl vfs.nfs.access_cache_timeout=${nfs_access_cache} >/dev/null; then
|
if ! sysctl vfs.nfs.access_cache_timeout=${nfs_access_cache} >/dev/null; then
|
||||||
warn "failed to set access cache timeout"
|
warn "failed to set access cache timeout"
|
||||||
fi
|
fi
|
||||||
|
@ -21,7 +21,7 @@ osrelease_start()
|
|||||||
{
|
{
|
||||||
local _version _version_id
|
local _version _version_id
|
||||||
|
|
||||||
check_startmsgs && echo -n "Updating ${osrelease_file} "
|
startmsg -n "Updating ${osrelease_file} "
|
||||||
_version=$(freebsd-version -u)
|
_version=$(freebsd-version -u)
|
||||||
_version_id=${_version%%[^0-9.]*}
|
_version_id=${_version%%[^0-9.]*}
|
||||||
t=$(mktemp -t os-release)
|
t=$(mktemp -t os-release)
|
||||||
@ -38,7 +38,7 @@ osrelease_start()
|
|||||||
__EOF__
|
__EOF__
|
||||||
install -C -o root -g wheel -m ${osrelease_perms} "$t" "${osrelease_file}"
|
install -C -o root -g wheel -m ${osrelease_perms} "$t" "${osrelease_file}"
|
||||||
rm -f "$t"
|
rm -f "$t"
|
||||||
check_startmsgs && echo 'done.'
|
startmsg 'done.'
|
||||||
}
|
}
|
||||||
|
|
||||||
load_rc_config $name
|
load_rc_config $name
|
||||||
|
@ -42,13 +42,13 @@ pf_fallback()
|
|||||||
|
|
||||||
pf_start()
|
pf_start()
|
||||||
{
|
{
|
||||||
check_startmsgs && echo -n 'Enabling pf'
|
startmsg -n 'Enabling pf'
|
||||||
$pf_program -F all > /dev/null 2>&1
|
$pf_program -F all > /dev/null 2>&1
|
||||||
$pf_program -f "$pf_rules" $pf_flags || pf_fallback
|
$pf_program -f "$pf_rules" $pf_flags || pf_fallback
|
||||||
if ! $pf_program -s info | grep -q "Enabled" ; then
|
if ! $pf_program -s info | grep -q "Enabled" ; then
|
||||||
$pf_program -eq
|
$pf_program -eq
|
||||||
fi
|
fi
|
||||||
check_startmsgs && echo '.'
|
startmsg '.'
|
||||||
}
|
}
|
||||||
|
|
||||||
pf_stop()
|
pf_stop()
|
||||||
|
@ -74,7 +74,7 @@ savecore_start()
|
|||||||
fi
|
fi
|
||||||
sync
|
sync
|
||||||
else
|
else
|
||||||
check_startmsgs && echo 'No core dumps found.'
|
startmsg 'No core dumps found.'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -715,6 +715,15 @@ check_startmsgs()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# startmsg
|
||||||
|
# Preferred method to use when displaying start messages in lieu of echo.
|
||||||
|
#
|
||||||
|
startmsg()
|
||||||
|
{
|
||||||
|
check_startmsgs && echo "$@"
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# run_rc_command argument
|
# run_rc_command argument
|
||||||
# Search for argument in the list of supported commands, which is:
|
# Search for argument in the list of supported commands, which is:
|
||||||
@ -1111,7 +1120,7 @@ run_rc_command()
|
|||||||
|
|
||||||
# setup the full command to run
|
# setup the full command to run
|
||||||
#
|
#
|
||||||
check_startmsgs && echo "Starting ${name}."
|
startmsg "Starting ${name}."
|
||||||
if [ -n "$_chroot" ]; then
|
if [ -n "$_chroot" ]; then
|
||||||
_cd=
|
_cd=
|
||||||
_doit="\
|
_doit="\
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd November 29, 2021
|
.Dd March 13, 2022
|
||||||
.Dt RC.SUBR 8
|
.Dt RC.SUBR 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -73,6 +73,8 @@
|
|||||||
.It
|
.It
|
||||||
.Ic run_rc_script Ar file Ar argument
|
.Ic run_rc_script Ar file Ar argument
|
||||||
.It
|
.It
|
||||||
|
.Ic startmsg Oo Fl n Oc Ar message
|
||||||
|
.It
|
||||||
.Ic wait_for_pids Op Ar pid ...
|
.Ic wait_for_pids Op Ar pid ...
|
||||||
.It
|
.It
|
||||||
.Ic warn Ar message
|
.Ic warn Ar message
|
||||||
@ -881,6 +883,17 @@ otherwise source
|
|||||||
.Ar file
|
.Ar file
|
||||||
into the current shell.
|
into the current shell.
|
||||||
.El
|
.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
|
.It Ic stop_boot Op Ar always
|
||||||
Prevent booting to multiuser mode.
|
Prevent booting to multiuser mode.
|
||||||
If the
|
If the
|
||||||
|
Loading…
Reference in New Issue
Block a user