Bring the RC article up to date.

PR:		docs/172692
Submitted by:	crees
Reviewed by:	Michael Telahun Makonnen <mmakonnen@gmail.com>
Approved by:	bcr (mentor)
This commit is contained in:
Eitan Adler 2012-10-31 21:24:26 +00:00
parent ceba215583
commit 36a62c0fe5
Notes: svn2git 2020-12-08 03:00:23 +00:00
svn path=/head/; revision=39880

View file

@ -400,8 +400,8 @@ start_cmd="${name}_start"
stop_cmd=":" stop_cmd=":"
load_rc_config $name<co id="rcng-confdummy-loadconfig"/> load_rc_config $name<co id="rcng-confdummy-loadconfig"/>
eval "${rcvar}=\${${rcvar}:-'NO'}"<co id="rcng-confdummy-enable"/> : ${dummy_enable:=no} <co id="rcng-confdummy-enable"/>
dummy_msg=${dummy_msg:-"Nothing started."}<co id="rcng-confdummy-opt"/> : ${dummy_msg="Nothing started."}<co id="rcng-confdummy-opt"/>
dummy_start() dummy_start()
{ {
@ -448,7 +448,7 @@ run_rc_command "$1"</programlisting>
system, you should add a default setting for the knob to system, you should add a default setting for the knob to
<filename>/etc/defaults/rc.conf</filename> and document <filename>/etc/defaults/rc.conf</filename> and document
it in &man.rc.conf.5;. Otherwise it is your script that it in &man.rc.conf.5;. Otherwise it is your script that
should provide a default setting for the knob. A portable should provide a default setting for the knob. The canonical
approach to the latter case is shown in the example.</para> approach to the latter case is shown in the example.</para>
<note> <note>
@ -479,7 +479,7 @@ run_rc_command "$1"</programlisting>
<important> <important>
<para>The names of all &man.rc.conf.5; variables used <para>The names of all &man.rc.conf.5; variables used
exclusively by our script <emphasis>must</emphasis> exclusively by our script <emphasis>must</emphasis>
have the same prefix: <envar>${name}</envar>. For have the same prefix: <envar>${name}_</envar>. For
example: <envar>dummy_mode</envar>, example: <envar>dummy_mode</envar>,
<envar>dummy_state_file</envar>, and so on.</para> <envar>dummy_state_file</envar>, and so on.</para>
</important> </important>
@ -487,19 +487,10 @@ run_rc_command "$1"</programlisting>
<note> <note>
<para>While it is possible to use a shorter name internally, <para>While it is possible to use a shorter name internally,
e.g., just <envar>msg</envar>, adding the unique prefix e.g., just <envar>msg</envar>, adding the unique prefix
<envar>${name}</envar> to all global names introduced by <envar>${name}_</envar> to all global names introduced by
our script will save us from possible our script will save us from possible
collisions with the &man.rc.subr.8; namespace.</para> collisions with the &man.rc.subr.8; namespace.</para>
<para>As long as an &man.rc.conf.5; variable and its
internal equivalent are the same, we can use a more
compact expression to set the default value:</para>
<programlisting>: ${dummy_msg:="Nothing started."}</programlisting>
<para>The current style is to use the more verbose form
though.</para>
<para>As a rule, <filename>rc.d</filename> scripts of the <para>As a rule, <filename>rc.d</filename> scripts of the
base system need not provide defaults for their base system need not provide defaults for their
&man.rc.conf.5; variables because the defaults should &man.rc.conf.5; variables because the defaults should
@ -512,7 +503,11 @@ run_rc_command "$1"</programlisting>
<callout arearefs="rcng-confdummy-msg"> <callout arearefs="rcng-confdummy-msg">
<para>Here we use <envar>dummy_msg</envar> to actually <para>Here we use <envar>dummy_msg</envar> to actually
control our script, i.e., to emit a variable message.</para> control our script, i.e., to emit a variable message.
Use of a shell function is overkill here, since it only
runs a single command; an equally valid alternative is:</para>
<programlisting>start_cmd="echo \"$dummy_msg\""</programlisting>
</callout> </callout>
</calloutlist> </calloutlist>
</sect1> </sect1>