Subject: Re: Cosmetic changes to rc.d scripts
To: None <tech-userlevel@NetBSD.org>
From: David Young <dyoung@pobox.com>
List: tech-userlevel
Date: 10/13/2004 01:03:16
Julio,
I'm not too keen on this comment= idea, myself, but here is how I think
that you can make a patch with a similar function, without affecting as
many files and lines of code.
First, these two changes seem gratuitous and possibly misleading---get rid
of them:
@@ -35,7 +35,16 @@
trap : INT
trap "echo 'Boot interrupted.'; exit 1" QUIT
-date
+if [ -f /etc/release ]; then
+ version=$(head -n 1 /etc/release)
+ echo "===> Starting ${version}..."
+fi
+
+if checkyesno rc_use_comments; then
+ echo "${rc_msg_prefix}Boot started at $(date)."
+else
+ date
+fi
files=$(rcorder -s nostart ${rc_rcorder_flags} /etc/rc.d/*)
@@ -43,5 +52,9 @@
run_rc_script $_rc_elem start
done
-date
+if checkyesno rc_use_comments; then
+ echo "${rc_msg_prefix}Boot finished at $(date)."
+else
+ date
+fi
exit 0
$rc_msg_prefix is redundant. rc-script output is distinguished by
prefixes Started, Stopped, Reloaded, et cetera. It is a rare daemon
uses those same message prefixes. We can filter the exceptional daemon's
output through
sed 's/^\(Started\|Stopped\|Reloaded\)/'${name}': \1/'
If we *must* have $rc_msg_prefix, I think you can express it more
concisely with a shell subroutine, pfx_echo.
The rc-script ${name} is the "key" for a manual page, with rare exceptions
(Luke mentions nmbd/smbd). For a novice, terse comments such as "Internet
superserver" will scarcely illuminate the boot process at all; the manual
pages, however, are illuminating. Moreover, they are documentation of
first-resort on the BSDs.
Instead of interspersing comment= assignments throughout the rc files, and
adding the three separate checkyesno conditionals for Start/Stop/Reload,
I suggest a different idiom.
[ -f /etc/rc.comments ] && . /etc/rc.comments
Let rc.comments contain variables:
dhcpd_comment="DHCP daemon (dhcpd)"
dhclient_comment="DHCP client (dhclient)"
inetd_comment="Internet superserver (inetd)"
A "novice"/"tutorial" installation contains /etc/rc.comments.
At the top of run_rc_command(), set ${description} this way:
eval description=\${${name}_comment:-${name}}
Finally, print Starting/Stopping/Reloading this way:
echo "Starting ${description}."
Dave
--
David Young OJC Technologies
dyoung@ojctech.com Urbana, IL * (217) 278-3933