aboutsummaryrefslogtreecommitdiff
path: root/en_US.ISO8859-1/articles/rc-scripting/article.xml
diff options
context:
space:
mode:
Diffstat (limited to 'en_US.ISO8859-1/articles/rc-scripting/article.xml')
-rw-r--r--en_US.ISO8859-1/articles/rc-scripting/article.xml146
1 files changed, 68 insertions, 78 deletions
diff --git a/en_US.ISO8859-1/articles/rc-scripting/article.xml b/en_US.ISO8859-1/articles/rc-scripting/article.xml
index c12a4a58d6..97684cb2d4 100644
--- a/en_US.ISO8859-1/articles/rc-scripting/article.xml
+++ b/en_US.ISO8859-1/articles/rc-scripting/article.xml
@@ -1,20 +1,13 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!DOCTYPE article PUBLIC "-//FreeBSD//DTD DocBook XML V4.5-Based Extension//EN"
- "../../../share/xml/freebsd45.dtd">
+<!DOCTYPE article PUBLIC "-//FreeBSD//DTD DocBook XML V5.0-Based Extension//EN"
+ "../../../share/xml/freebsd50.dtd">
+<article xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" xml:lang="en">
+ <info><title>Practical rc.d scripting in BSD</title>
+
-<article lang='en'>
- <articleinfo>
- <title>Practical rc.d scripting in BSD</title>
-
- <author>
- <firstname>Yar</firstname>
-
- <surname>Tikhiy</surname>
-
- <affiliation>
+ <author><personname><firstname>Yar</firstname><surname>Tikhiy</surname></personname><affiliation>
<address><email>yar@FreeBSD.org</email></address>
- </affiliation>
- </author>
+ </affiliation></author>
<copyright>
<year>2005</year>
@@ -24,7 +17,7 @@
<holder>The FreeBSD Project</holder>
</copyright>
- <legalnotice id="trademarks" role="trademarks">
+ <legalnotice xml:id="trademarks" role="trademarks">
&tm-attrib.freebsd;
&tm-attrib.netbsd;
&tm-attrib.general;
@@ -45,9 +38,9 @@
provide reference points for further study of the design
and efficient application of <filename>rc.d</filename>.</para>
</abstract>
- </articleinfo>
+ </info>
- <sect1 id="rcng-intro">
+ <sect1 xml:id="rcng-intro">
<title>Introduction</title>
<para>The historical BSD had a monolithic startup script,
@@ -164,7 +157,7 @@
authors.</para>
</sect1>
- <sect1 id="rcng-task">
+ <sect1 xml:id="rcng-task">
<title>Outlining the task</title>
<para>A little consideration before starting
@@ -193,28 +186,28 @@
important to know the answers to these questions.</para>
</sect1>
- <sect1 id="rcng-dummy">
+ <sect1 xml:id="rcng-dummy">
<title>A dummy script</title>
<para>The following script just emits a message each time the
system boots up:</para>
<informalexample>
- <programlisting>#!/bin/sh<co id="rcng-dummy-shebang"/>
+ <programlisting>#!/bin/sh<co xml:id="rcng-dummy-shebang"/>
-. /etc/rc.subr<co id="rcng-dummy-include"/>
+. /etc/rc.subr<co xml:id="rcng-dummy-include"/>
-name="dummy"<co id="rcng-dummy-name"/>
-start_cmd="${name}_start"<co id="rcng-dummy-startcmd"/>
-stop_cmd=":"<co id="rcng-dummy-stopcmd"/>
+name="dummy"<co xml:id="rcng-dummy-name"/>
+start_cmd="${name}_start"<co xml:id="rcng-dummy-startcmd"/>
+stop_cmd=":"<co xml:id="rcng-dummy-stopcmd"/>
-dummy_start()<co id="rcng-dummy-startfn"/>
+dummy_start()<co xml:id="rcng-dummy-startfn"/>
{
echo "Nothing started."
}
-load_rc_config $name<co id="rcng-dummy-loadconfig"/>
-run_rc_command "$1"<co id="rcng-dummy-runcommand"/></programlisting>
+load_rc_config $name<co xml:id="rcng-dummy-loadconfig"/>
+run_rc_command "$1"<co xml:id="rcng-dummy-runcommand"/></programlisting>
</informalexample>
<para>Things to note are:</para>
@@ -283,7 +276,7 @@ run_rc_command "$1"<co id="rcng-dummy-runcommand"/></programlisting>
</callout>
<callout arearefs="rcng-dummy-name">
- <para><anchor id="name-var"/>The mandatory variable
+ <para><anchor xml:id="name-var"/>The mandatory variable
<envar>name</envar> specifies the name of our script. It
is required by &man.rc.subr.8;. That is, each
<filename>rc.d</filename> script <emphasis>must</emphasis>
@@ -369,7 +362,7 @@ run_rc_command "$1"<co id="rcng-dummy-runcommand"/></programlisting>
</calloutlist>
</sect1>
- <sect1 id="rcng-confdummy">
+ <sect1 xml:id="rcng-confdummy">
<title>A configurable dummy script</title>
<para>Now let us add some controls to our dummy script. As you
@@ -391,18 +384,18 @@ run_rc_command "$1"<co id="rcng-dummy-runcommand"/></programlisting>
. /etc/rc.subr
name=dummy
-rcvar=dummy_enable<co id="rcng-confdummy-rcvar"/>
+rcvar=dummy_enable<co xml:id="rcng-confdummy-rcvar"/>
start_cmd="${name}_start"
stop_cmd=":"
-load_rc_config $name<co id="rcng-confdummy-loadconfig"/>
-: ${dummy_enable:=no} <co id="rcng-confdummy-enable"/>
-: ${dummy_msg="Nothing started."}<co id="rcng-confdummy-opt"/>
+load_rc_config $name<co xml:id="rcng-confdummy-loadconfig"/>
+: ${dummy_enable:=no} <co xml:id="rcng-confdummy-enable"/>
+: ${dummy_msg="Nothing started."}<co xml:id="rcng-confdummy-opt"/>
dummy_start()
{
- echo "$dummy_msg"<co id="rcng-confdummy-msg"/>
+ echo "$dummy_msg"<co xml:id="rcng-confdummy-msg"/>
}
run_rc_command "$1"</programlisting>
@@ -509,7 +502,7 @@ run_rc_command "$1"</programlisting>
</calloutlist>
</sect1>
- <sect1 id="rcng-daemon">
+ <sect1 xml:id="rcng-daemon">
<title>Startup and shutdown of a simple daemon</title>
<para>We said earlier that &man.rc.subr.8; could provide default
@@ -527,7 +520,7 @@ run_rc_command "$1"</programlisting>
name=mumbled
rcvar=mumbled_enable
-command="/usr/sbin/${name}"<co id="rcng-daemon-basic-cmd"/>
+command="/usr/sbin/${name}"<co xml:id="rcng-daemon-basic-cmd"/>
load_rc_config $name
run_rc_command "$1"</programlisting>
@@ -603,7 +596,7 @@ run_rc_command "$1"</programlisting>
</calloutlist>
</sect1>
- <sect1 id="rcng-daemon-adv">
+ <sect1 xml:id="rcng-daemon-adv">
<title>Startup and shutdown of an advanced daemon</title>
<para>Let us add some meat onto the bones of the previous
@@ -621,26 +614,26 @@ name=mumbled
rcvar=mumbled_enable
command="/usr/sbin/${name}"
-command_args="mock arguments &gt; /dev/null 2&gt;&amp;1"<co id="rcng-daemon-adv-args"/>
+command_args="mock arguments &gt; /dev/null 2&gt;&amp;1"<co xml:id="rcng-daemon-adv-args"/>
-pidfile="/var/run/${name}.pid"<co id="rcng-daemon-adv-pid"/>
+pidfile="/var/run/${name}.pid"<co xml:id="rcng-daemon-adv-pid"/>
-required_files="/etc/${name}.conf /usr/share/misc/${name}.rules"<co id="rcng-daemon-adv-reqfiles"/>
+required_files="/etc/${name}.conf /usr/share/misc/${name}.rules"<co xml:id="rcng-daemon-adv-reqfiles"/>
-sig_reload="USR1"<co id="rcng-daemon-adv-sig"/>
+sig_reload="USR1"<co xml:id="rcng-daemon-adv-sig"/>
-start_precmd="${name}_prestart"<co id="rcng-daemon-adv-precmd"/>
-stop_postcmd="echo Bye-bye"<co id="rcng-daemon-adv-postcmd"/>
+start_precmd="${name}_prestart"<co xml:id="rcng-daemon-adv-precmd"/>
+stop_postcmd="echo Bye-bye"<co xml:id="rcng-daemon-adv-postcmd"/>
-extra_commands="reload plugh xyzzy"<co id="rcng-daemon-adv-extra"/>
+extra_commands="reload plugh xyzzy"<co xml:id="rcng-daemon-adv-extra"/>
-plugh_cmd="mumbled_plugh"<co id="rcng-daemon-adv-methods"/>
+plugh_cmd="mumbled_plugh"<co xml:id="rcng-daemon-adv-methods"/>
xyzzy_cmd="echo 'Nothing happens.'"
mumbled_prestart()
{
- if checkyesno mumbled_smart; then<co id="rcng-daemon-adv-yn"/>
- rc_flags="-o smart ${rc_flags}"<co id="rcng-daemon-adv-rcflags"/>
+ if checkyesno mumbled_smart; then<co xml:id="rcng-daemon-adv-yn"/>
+ rc_flags="-o smart ${rc_flags}"<co xml:id="rcng-daemon-adv-rcflags"/>
fi
case "$mumbled_mode" in
foo)
@@ -650,15 +643,15 @@ mumbled_prestart()
rc_flags="-baz ${rc_flags}"
;;
*)
- warn "Invalid value for mumbled_mode"<co id="rcng-daemon-adv-warn"/>
- return 1<co id="rcng-daemon-adv-preret"/>
+ warn "Invalid value for mumbled_mode"<co xml:id="rcng-daemon-adv-warn"/>
+ return 1<co xml:id="rcng-daemon-adv-preret"/>
;;
esac
- run_rc_command xyzzy<co id="rcng-daemon-adv-run"/>
+ run_rc_command xyzzy<co xml:id="rcng-daemon-adv-run"/>
return 0
}
-mumbled_plugh()<co id="rcng-daemon-adv-plugh"/>
+mumbled_plugh()<co xml:id="rcng-daemon-adv-plugh"/>
{
echo 'A hollow voice says "plugh".'
}
@@ -688,8 +681,7 @@ run_rc_command "$1"</programlisting>
A better way of passing additional options
to <envar>$command</envar> is to add them
to the beginning of <envar>${name}_flags</envar>.
- Another way is to modify <envar>rc_flags</envar> <link
- linkend="rc-flags">as shown later</link>.</para>
+ Another way is to modify <envar>rc_flags</envar> <link linkend="rc-flags">as shown later</link>.</para>
</note>
</callout>
@@ -882,7 +874,7 @@ fi</programlisting>
</callout>
<callout arearefs="rcng-daemon-adv-rcflags">
- <para><anchor id="rc-flags"/>We can affect the flags to be
+ <para><anchor xml:id="rc-flags"/>We can affect the flags to be
passed to <envar>$command</envar> by modifying
<envar>rc_flags</envar> in <envar>$start_precmd</envar>.</para>
</callout>
@@ -918,7 +910,7 @@ fi</programlisting>
</calloutlist>
</sect1>
- <sect1 id="rcng-hookup">
+ <sect1 xml:id="rcng-hookup">
<title>Connecting a script to the rc.d framework</title>
<para>After a script has been written, it needs to be integrated
@@ -931,9 +923,9 @@ fi</programlisting>
the proper ownership and mode. System scripts should be
installed from <filename>src/etc/rc.d</filename> through the
<filename>Makefile</filename> found there. Port scripts can
- be installed using <makevar>USE_RC_SUBR</makevar> as described
- <ulink url="&url.books.porters-handbook;/rc-scripts.html">in
- the Porter's Handbook</ulink>.</para>
+ be installed using <varname>USE_RC_SUBR</varname> as described
+ <link xlink:href="&url.books.porters-handbook;/rc-scripts.html">in
+ the Porter's Handbook</link>.</para>
<para>However, we should consider beforehand the place of
our script in the system startup sequence. The service handled
@@ -995,10 +987,10 @@ fi</programlisting>
<informalexample>
<programlisting>#!/bin/sh
-# PROVIDE: mumbled oldmumble <co id="rcng-hookup-provide"/>
-# REQUIRE: DAEMON cleanvar frotz<co id="rcng-hookup-require"/>
-# BEFORE: LOGIN<co id="rcng-hookup-before"/>
-# KEYWORD: nojail shutdown<co id="rcng-hookup-keyword"/>
+# PROVIDE: mumbled oldmumble <co xml:id="rcng-hookup-provide"/>
+# REQUIRE: DAEMON cleanvar frotz<co xml:id="rcng-hookup-require"/>
+# BEFORE: LOGIN<co xml:id="rcng-hookup-before"/>
+# KEYWORD: nojail shutdown<co xml:id="rcng-hookup-keyword"/>
. /etc/rc.subr
@@ -1011,8 +1003,8 @@ start_precmd="${name}_prestart"
mumbled_prestart()
{
if ! checkyesno frotz_enable &amp;&amp; \
- ! /etc/rc.d/frotz forcestatus 1>/dev/null 2>&amp;1; then
- force_depend frotz || return 1<co id="rcng-hookup-force"/>
+ ! /etc/rc.d/frotz forcestatus 1&gt;/dev/null 2&gt;&amp;1; then
+ force_depend frotz || return 1<co xml:id="rcng-hookup-force"/>
fi
return 0
}
@@ -1067,7 +1059,7 @@ run_rc_command "$1"</programlisting>
<quote>placeholder</quote> scripts used to ensure that
certain groups of operations are performed before others.
These are denoted by
- <filename><replaceable>UPPERCASE</replaceable></filename>
+ <filename>UPPERCASE</filename>
names. Their list and purposes can be found in
&man.rc.8;.</para>
@@ -1080,13 +1072,12 @@ run_rc_command "$1"</programlisting>
will not do that either. Consequently, the application
started by our script should be able to cope with any
required services being unavailable. In certain cases,
- we can help it as discussed <link
- linkend="forcedep">below.</link></para>
+ we can help it as discussed <link linkend="forcedep">below.</link></para>
</note>
</callout>
<callout arearefs="rcng-hookup-keyword">
- <para><anchor id="keywords"/>As we remember from the above text,
+ <para><anchor xml:id="keywords"/>As we remember from the above text,
&man.rcorder.8; keywords can be used to select or leave
out some scripts. Namely any &man.rcorder.8; consumer
can specify through <option>-k</option> and <option>-s</option>
@@ -1173,7 +1164,7 @@ run_rc_command "$1"</programlisting>
</callout>
<callout arearefs="rcng-hookup-force">
- <para><anchor id="forcedep"/>To begin with,
+ <para><anchor xml:id="forcedep"/>To begin with,
<function>force_depend</function> should be used with
much care. It is generally better to revise the hierarchy
of configuration variables for your <filename>rc.d</filename>
@@ -1200,7 +1191,7 @@ run_rc_command "$1"</programlisting>
</calloutlist>
</sect1>
- <sect1 id="rcng-args">
+ <sect1 xml:id="rcng-args">
<title>Giving more flexibility to an rc.d script</title>
<para>When invoked during startup or shutdown, an
@@ -1261,7 +1252,7 @@ extra_commands="kiss"
dummy_start()
{
- if [ $# -gt 0 ]; then<co id="rcng-args-start"/>
+ if [ $# -gt 0 ]; then<co xml:id="rcng-args-start"/>
echo "Greeting message: $*"
else
echo "Nothing started."
@@ -1271,7 +1262,7 @@ dummy_start()
dummy_kiss()
{
echo -n "A ghost gives you a kiss"
- if [ $# -gt 0 ]; then<co id="rcng-args-kiss"/>
+ if [ $# -gt 0 ]; then<co xml:id="rcng-args-kiss"/>
echo -n " and whispers: $*"
fi
case "$*" in
@@ -1285,7 +1276,7 @@ dummy_kiss()
}
load_rc_config $name
-run_rc_command "$@"<co id="rcng-args-all"/></programlisting>
+run_rc_command "$@"<co xml:id="rcng-args-all"/></programlisting>
</informalexample>
<para>What essential changes can we notice in the script?</para>
@@ -1347,18 +1338,17 @@ A ghost gives you a kiss and whispers: Once I was Etaoin Shrdlu...</screen>
</calloutlist>
</sect1>
- <sect1 id="rcng-furthur">
+ <sect1 xml:id="rcng-furthur">
<title>Further reading</title>
- <para><anchor id="lukem"/><ulink
- url="http://www.mewburn.net/luke/papers/rc.d.pdf">The original
- article by Luke Mewburn</ulink> offers a general overview of
+ <para><anchor xml:id="lukem"/><link xlink:href="http://www.mewburn.net/luke/papers/rc.d.pdf">The original
+ article by Luke Mewburn</link> offers a general overview of
<filename>rc.d</filename> and detailed rationale for its
design decisions. It provides insight on the whole
<filename>rc.d</filename> framework and its place in a modern
BSD operating system.</para>
- <para><anchor id="manpages"/>The manual pages &man.rc.8;,
+ <para><anchor xml:id="manpages"/>The manual pages &man.rc.8;,
&man.rc.subr.8;, and &man.rcorder.8; document the
<filename>rc.d</filename> components in great detail. You
cannot fully use the <filename>rc.d</filename> power without