In regards to the "Starting foo:" type messages at boot time, create and

employ a more generic solution, and use it in the individual rc.d scripts
that also have an $rc_quiet test:

1. Add check_startmsgs() to rc.subr.
2. In the rc.d scripts that use rc_quiet (and rc.subr) substitute
variations of [ -z "$rc_quiet" ] with check_startmsgs
3. In savecore add a trailing '.' to the end of the message to make it
more consistent with other scripts.
4. In newsyslog remove a : before the terminal '.' since we do not expect
there to be anything printed out in between to make it more consistent.
5. In the following scripts change "quotes" to 'quotes' where no variables
exist in the message: savecore pf newsyslog
6. In the following scripts substitute if/then/fi for the simpler (and
more consistent) check_startmsgs &&: faith stf
7. In the following scripts separate the "Starting foo:" from the terminal
'.' to make them more consistent: moused hostname pf
8. In nfsclient move the message to its own line to avoid a style bug
9. In pf rc_quiet does not apply to the _stop method, so remove the
test there.
10. In motd add 'quotes' around the terminal '.' for consistency
This commit is contained in:
Doug Barton 2009-10-10 22:17:03 +00:00
parent 7c3a3fbe95
commit 70d4ef1ea1
17 changed files with 45 additions and 36 deletions

View File

@ -31,7 +31,7 @@ bgfsck_start ()
bgfsck_msg="${bgfsck_msg} in ${background_fsck_delay} seconds"
fi
if [ -z "${rc_force}" ]; then
[ -z "${rc_quiet}" ] && echo "${bgfsck_msg}."
check_startmsgs && echo "${bgfsck_msg}."
fi
(sleep ${background_fsck_delay}; nice -4 fsck -B -p) 2>&1 | \

View File

@ -25,7 +25,7 @@ cleartmp_start()
${tmp}/.ICE-unix ${tmp}/.font-unix"
if checkyesno ${rcvar1}; then
[ -z "${rc_quiet}" ] && echo "Clearing ${tmp}."
check_startmsgs && echo "Clearing ${tmp}."
# This is not needed for mfs, but doesn't hurt anything.
# Things to note:
@ -44,7 +44,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.
[ -z "${rc_quiet}" ] && echo "Clearing ${tmp} (X related)."
check_startmsgs && echo "Clearing ${tmp} (X related)."
rm -rf ${tmp}/.X[0-9]-lock ${x11_socket_dirs}
fi
if checkyesno clear_tmp_X; then

View File

@ -39,9 +39,7 @@ faith_up()
route change -inet6 ${prefix} -prefixlen ${prefixlen} \
-ifp faith0
done
if [ -z "${rc_quiet}" ]; then
ifconfig faith0
fi
check_startmsgs && ifconfig faith0
;;
esac
}

View File

@ -23,7 +23,7 @@ fsck_start()
# During fsck ignore SIGQUIT
trap : 3
[ -z "${rc_quiet}" ] && echo "Starting file system checks:"
check_startmsgs && echo "Starting file system checks:"
if checkyesno background_fsck; then
fsck -F -p
else

View File

@ -49,9 +49,9 @@ hostid_set()
# Set both kern.hostuuid and kern.hostid.
#
[ -z "${rc_quiet}" ] && echo "Setting hostuuid: ${uuid}."
check_startmsgs && echo "Setting hostuuid: ${uuid}."
${SYSCTL_W} kern.hostuuid="${uuid}" >/dev/null
[ -z "${rc_quiet}" ] && echo "Setting hostid: ${id}."
check_startmsgs && echo "Setting hostid: ${id}."
${SYSCTL_W} kern.hostid=${id} >/dev/null
}

View File

@ -72,8 +72,9 @@ hostname_start()
# All right, it is safe to invoke hostname(1) now.
#
[ -z "${rc_quiet}" ] && echo "Setting hostname: ${hostname}."
check_startmsgs && echo -n "Setting hostname: ${hostname}"
/bin/hostname "${hostname}"
check_startmsgs && echo '.'
}
load_rc_config $name

View File

@ -36,7 +36,7 @@ ldconfig_start()
_LDC="${_LDC} ${i}"
fi
done
[ -z "${rc_quiet}" ] && echo 'ELF ldconfig path:' ${_LDC}
check_startmsgs && echo 'ELF ldconfig path:' ${_LDC}
${ldconfig} -elf ${_ins} ${_LDC}
case `sysctl -n hw.machine_arch` in
@ -55,7 +55,7 @@ ldconfig_start()
_LDC="${_LDC} ${i}"
fi
done
[ -z "${rc_quiet}" ] &&
check_startmsgs &&
echo '32-bit compatibility ldconfig path:' ${_LDC}
${ldconfig} -32 -m ${_ins} ${_LDC}
;;
@ -72,8 +72,7 @@ ldconfig_start()
_LDC="${_LDC} ${i}"
fi
done
[ -z "${rc_quiet}" ] &&
echo 'a.out ldconfig path:' ${_LDC}
check_startmsgs && echo 'a.out ldconfig path:' ${_LDC}
${ldconfig} -aout ${_ins} ${_LDC}
;;
esac

View File

@ -22,7 +22,7 @@ motd_start()
# Must be done *before* interactive logins are possible
# to prevent possible race conditions.
#
[ -z "${rc_quiet}" ] && echo -n 'Updating motd:'
check_startmsgs && echo -n 'Updating motd:'
if [ ! -f /etc/motd ]; then
install -c -o root -g wheel -m ${PERMS} /dev/null /etc/motd
fi
@ -42,7 +42,7 @@ motd_start()
}
rm -f $T
[ -z "${rc_quiet}" ] && echo .
check_startmsgs && echo '.'
}
load_rc_config $name

View File

@ -28,7 +28,7 @@ mountcritlocal_start()
esac
# Mount everything except nfs filesystems.
[ -z "${rc_quiet}" ] && echo -n 'Mounting local file systems:'
check_startmsgs && echo -n 'Mounting local file systems:'
mount_excludes='no'
for i in ${netfs_types}; do
fstype=${i%:*}
@ -37,7 +37,7 @@ mountcritlocal_start()
mount_excludes=${mount_excludes%,}
mount -a -t ${mount_excludes}
err=$?
[ -z "${rc_quiet}" ] && echo '.'
check_startmsgs && echo '.'
case ${err} in
0)

View File

@ -51,8 +51,9 @@ moused_start()
mytype="$moused_type"
fi
[ -z "${rc_quiet}" ] && echo -n "Starting ${ms} moused."
check_startmsgs && echo -n "Starting ${ms} moused"
/usr/sbin/moused ${myflags} -p ${myport} -t ${mytype} ${pidarg}
check_startmsgs && echo '.'
mousechar_arg=
case ${mousechar_start} in

View File

@ -143,7 +143,7 @@ network_common()
;;
esac
echo "${_str} Network:${_ok}."
if [ -z "${rc_quiet}" ]; then
if check_startmsgs; then
for ifn in ${_ok}; do
/sbin/ifconfig ${ifn}
done

View File

@ -17,9 +17,9 @@ stop_cmd=":"
newsyslog_start()
{
[ -z "${rc_quiet}" ] && echo -n "Creating and/or trimming log files:"
check_startmsgs && echo -n 'Creating and/or trimming log files'
${command} ${rc_flags}
[ -z "${rc_quiet}" ] && echo "."
check_startmsgs && echo '.'
}
load_rc_config $name

View File

@ -22,7 +22,8 @@ nfsclient_start()
#
if [ -n "${nfs_access_cache}" ]; then
[ -z "${rc_quiet}" ] && echo "NFS access cache time=${nfs_access_cache}"
check_startmsgs &&
echo "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

View File

@ -25,19 +25,21 @@ required_modules="pf"
pf_start()
{
[ -z "${rc_quiet}" ] && echo "Enabling pf."
check_startmsgs && echo -n 'Enabling pf'
$pf_program -F all > /dev/null 2>&1
$pf_program -f "$pf_rules" $pf_flags
if ! $pf_program -s info | grep -q "Enabled" ; then
$pf_program -e
fi
check_startmsgs && echo '.'
}
pf_stop()
{
if $pf_program -s info | grep -q "Enabled" ; then
[ -z "${rc_quiet}" ] && echo "Disabling pf."
echo -n 'Disabling pf'
$pf_program -d
echo '.'
fi
}

View File

@ -69,7 +69,7 @@ savecore_start()
${crashinfo_program} -d ${dumpdir}
fi
else
[ -z "${rc_quiet}" ] && echo "No core dumps found"
check_startmsgs && echo 'No core dumps found.'
fi
}

View File

@ -53,9 +53,8 @@ stf_up()
ifconfig stf0 create >/dev/null 2>&1
ifconfig stf0 inet6 2002:${ipv4_in_hexformat}:${stf_interface_ipv6_slaid:-0}:${stf_interface_ipv6_ifid} \
prefixlen ${stf_prefixlen}
if [ -z "${rc_quiet}" ]; then
/sbin/ifconfig stf0
fi
check_startmsgs && /sbin/ifconfig stf0
# disallow packets to malicious 6to4 prefix
route add -inet6 2002:e000:: -prefixlen 20 ::1 -reject
route add -inet6 2002:7f00:: -prefixlen 24 ::1 -reject

View File

@ -397,6 +397,20 @@ wait_for_pids()
fi
}
#
# check_startmsgs
# If rc_quiet is set (usually as a result of using faststart at
# boot time) check if rc_startmsgs is enabled.
#
check_startmsgs()
{
if [ -n "$rc_quiet" ]; then
checkyesno rc_startmsgs
else
return 0
fi
}
#
# run_rc_command argument
# Search for argument in the list of supported commands, which is:
@ -708,13 +722,7 @@ run_rc_command()
# setup the full command to run
#
_show_startmsgs=1
if [ -n "${rc_quiet}" ]; then
if ! checkyesno rc_startmsgs; then
unset _show_startmsgs
fi
fi
[ -n "$_show_startmsgs" ] && echo "Starting ${name}."
check_startmsgs && echo "Starting ${name}."
if [ -n "$_chroot" ]; then
_doit="\
${_nice:+nice -n $_nice }\