diff options
author | Doug Barton <dougb@FreeBSD.org> | 2009-10-10 22:17:03 +0000 |
---|---|---|
committer | Doug Barton <dougb@FreeBSD.org> | 2009-10-10 22:17:03 +0000 |
commit | 70d4ef1ea19075a48d3dfe3012c6a1aba185c718 (patch) | |
tree | f49c4e3cc88efec4813ca1f389f8f77eca5d2ba0 /etc | |
parent | 7c3a3fbe951ba9d6e13833751ec6b64b326445e6 (diff) | |
download | src-70d4ef1ea19075a48d3dfe3012c6a1aba185c718.tar.gz src-70d4ef1ea19075a48d3dfe3012c6a1aba185c718.zip |
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
Notes
Notes:
svn path=/head/; revision=197947
Diffstat (limited to 'etc')
-rwxr-xr-x | etc/rc.d/bgfsck | 2 | ||||
-rwxr-xr-x | etc/rc.d/cleartmp | 4 | ||||
-rwxr-xr-x | etc/rc.d/faith | 4 | ||||
-rwxr-xr-x | etc/rc.d/fsck | 2 | ||||
-rwxr-xr-x | etc/rc.d/hostid | 4 | ||||
-rwxr-xr-x | etc/rc.d/hostname | 3 | ||||
-rwxr-xr-x | etc/rc.d/ldconfig | 7 | ||||
-rwxr-xr-x | etc/rc.d/motd | 4 | ||||
-rwxr-xr-x | etc/rc.d/mountcritlocal | 4 | ||||
-rwxr-xr-x | etc/rc.d/moused | 3 | ||||
-rwxr-xr-x | etc/rc.d/netif | 2 | ||||
-rwxr-xr-x | etc/rc.d/newsyslog | 4 | ||||
-rwxr-xr-x | etc/rc.d/nfsclient | 3 | ||||
-rwxr-xr-x | etc/rc.d/pf | 6 | ||||
-rwxr-xr-x | etc/rc.d/savecore | 2 | ||||
-rwxr-xr-x | etc/rc.d/stf | 5 | ||||
-rw-r--r-- | etc/rc.subr | 22 |
17 files changed, 45 insertions, 36 deletions
diff --git a/etc/rc.d/bgfsck b/etc/rc.d/bgfsck index 04c4cb529ca5..3715354fc3ed 100755 --- a/etc/rc.d/bgfsck +++ b/etc/rc.d/bgfsck @@ -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 | \ diff --git a/etc/rc.d/cleartmp b/etc/rc.d/cleartmp index a41a15ebf453..94b7799ba6d5 100755 --- a/etc/rc.d/cleartmp +++ b/etc/rc.d/cleartmp @@ -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 diff --git a/etc/rc.d/faith b/etc/rc.d/faith index 020b947ec86a..a7f4cd8cdf83 100755 --- a/etc/rc.d/faith +++ b/etc/rc.d/faith @@ -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 } diff --git a/etc/rc.d/fsck b/etc/rc.d/fsck index a2ca0b753844..c1fe155e48f4 100755 --- a/etc/rc.d/fsck +++ b/etc/rc.d/fsck @@ -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 diff --git a/etc/rc.d/hostid b/etc/rc.d/hostid index f8a3d94485f6..45d679bbabf6 100755 --- a/etc/rc.d/hostid +++ b/etc/rc.d/hostid @@ -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 } diff --git a/etc/rc.d/hostname b/etc/rc.d/hostname index 52f4408b635c..142dc4713c33 100755 --- a/etc/rc.d/hostname +++ b/etc/rc.d/hostname @@ -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 diff --git a/etc/rc.d/ldconfig b/etc/rc.d/ldconfig index 8e30576394f2..5ed1ed1d5d77 100755 --- a/etc/rc.d/ldconfig +++ b/etc/rc.d/ldconfig @@ -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 diff --git a/etc/rc.d/motd b/etc/rc.d/motd index 0b6707a58a22..8256d9682836 100755 --- a/etc/rc.d/motd +++ b/etc/rc.d/motd @@ -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 diff --git a/etc/rc.d/mountcritlocal b/etc/rc.d/mountcritlocal index 49f8f06bb8aa..789251765eb2 100755 --- a/etc/rc.d/mountcritlocal +++ b/etc/rc.d/mountcritlocal @@ -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) diff --git a/etc/rc.d/moused b/etc/rc.d/moused index 60372a020f21..fd2c447c60ad 100755 --- a/etc/rc.d/moused +++ b/etc/rc.d/moused @@ -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 diff --git a/etc/rc.d/netif b/etc/rc.d/netif index 3c8e5dc5d200..f982cfce6474 100755 --- a/etc/rc.d/netif +++ b/etc/rc.d/netif @@ -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 diff --git a/etc/rc.d/newsyslog b/etc/rc.d/newsyslog index f03d97cfb0f4..ab8f2d314971 100755 --- a/etc/rc.d/newsyslog +++ b/etc/rc.d/newsyslog @@ -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 diff --git a/etc/rc.d/nfsclient b/etc/rc.d/nfsclient index 2b26d09da6dc..d28e45f6a2e9 100755 --- a/etc/rc.d/nfsclient +++ b/etc/rc.d/nfsclient @@ -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 diff --git a/etc/rc.d/pf b/etc/rc.d/pf index f1044a36882e..9f64c04a6696 100755 --- a/etc/rc.d/pf +++ b/etc/rc.d/pf @@ -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 } diff --git a/etc/rc.d/savecore b/etc/rc.d/savecore index ff8e128eda03..2bee021392ce 100755 --- a/etc/rc.d/savecore +++ b/etc/rc.d/savecore @@ -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 } diff --git a/etc/rc.d/stf b/etc/rc.d/stf index 40b182a0de93..6f7347b98c5e 100755 --- a/etc/rc.d/stf +++ b/etc/rc.d/stf @@ -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 diff --git a/etc/rc.subr b/etc/rc.subr index fd94cc9c372c..fa372ddf3690 100644 --- a/etc/rc.subr +++ b/etc/rc.subr @@ -398,6 +398,20 @@ wait_for_pids() } # +# 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: # "start stop restart rcvar status poll ${extra_commands}" @@ -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 }\ |