Gentoo Archives: gentoo-doc-cvs

From: "Sven Vermeulen (swift)" <swift@g.o>
To: gentoo-doc-cvs@l.g.o
Subject: [gentoo-doc-cvs] gentoo commit in xml/htdocs/doc/en/handbook: hb-working-rcscripts.xml
Date: Wed, 17 Aug 2011 07:57:36
Message-Id: 20110817075723.5ECF62004C@flycatcher.gentoo.org
1 swift 11/08/17 07:57:23
2
3 Modified: hb-working-rcscripts.xml
4 Log:
5 Part of bug #337140 - Improve description of use/need/before/after (or clarify it more since it was already documented)
6
7 Revision Changes Path
8 1.35 xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml
9
10 file : http://sources.gentoo.org/viewvc.cgi/gentoo/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml?rev=1.35&view=markup
11 plain: http://sources.gentoo.org/viewvc.cgi/gentoo/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml?rev=1.35&content-type=text/plain
12 diff : http://sources.gentoo.org/viewvc.cgi/gentoo/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml?r1=1.34&r2=1.35
13
14 Index: hb-working-rcscripts.xml
15 ===================================================================
16 RCS file: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml,v
17 retrieving revision 1.34
18 retrieving revision 1.35
19 diff -u -r1.34 -r1.35
20 --- hb-working-rcscripts.xml 14 Aug 2011 16:12:13 -0000 1.34
21 +++ hb-working-rcscripts.xml 17 Aug 2011 07:57:23 -0000 1.35
22 @@ -4,7 +4,7 @@
23 <!-- The content of this document is licensed under the CC-BY-SA license -->
24 <!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
25
26 -<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml,v 1.34 2011/08/14 16:12:13 swift Exp $ -->
27 +<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml,v 1.35 2011/08/17 07:57:23 swift Exp $ -->
28
29 <sections>
30
31 @@ -14,8 +14,8 @@
32 these aspects and explains how to deal with these scripts.
33 </abstract>
34
35 -<version>3</version>
36 -<date>2011-08-12</date>
37 +<version>4</version>
38 +<date>2011-08-17</date>
39
40 <section>
41 <title>Runlevels</title>
42 @@ -454,10 +454,58 @@
43 <body>
44
45 <p>
46 -There are two dependencies you can define: <c>use</c> and <c>need</c>. As we
47 -have mentioned before, the <c>need</c> dependency is more strict than the
48 -<c>use</c> dependency. Following this dependency type you enter the service
49 -you depend on, or the <e>virtual</e> dependency.
50 +There are two dependency-alike settings you can define that influence the
51 +start-up or sequencing of init scripts: <c>use</c> and <c>need</c>. Next to
52 +these two, there are also two order-influencing methods called <c>before</c> and
53 +<c>after</c>. These last two are no dependencies per se - they do not make the
54 +original init script fail if the selected one isn't scheduled to start (or fails
55 +to start).
56 +</p>
57 +
58 +<ul>
59 + <li>
60 + The <c>use</c> settings informs the init system that this script <e>uses</e>
61 + functionality offered by the selected script, but does not directly depend
62 + on it. A good example would be <c>use logger</c> or <c>use dns</c>. If those
63 + services are available, they will be put in good use, but if you do not have
64 + a logger or DNS server the services will still work. If the services exist,
65 + then they are started before the script that <c>use</c>'s them.
66 + </li>
67 + <li>
68 + The <c>need</c> setting is a hard dependency. It means that the script that
69 + is <c>need</c>'ing another script will not start before the other script is
70 + launched successfully. Also, if that other script is restarted, then this
71 + one will be restarted as well.
72 + </li>
73 + <li>
74 + When using <c>before</c>, then the given script is launched before the
75 + selected one <e>if</e> the selected one is part of the init level. So an
76 + init script <path>xdm</path> that defines <c>before alsasound</c> will start
77 + before the <path>alsasound</path> script, but only if <path>alsasound</path>
78 + is scheduled to start as well in the same init level. If
79 + <path>alsasound</path> is not scheduled to start too, then this particular
80 + setting has no effect and <path>xdm</path> will be started when the init
81 + system deems it most appropriate.
82 + </li>
83 + <li>
84 + Similarly, <c>after</c> informs the init system that the given script should
85 + be launched after the selected one <e>if</e> the selected one is part of the
86 + init level. If not, then the setting has no effect and the script will be
87 + launched by the init system when it deems it most appropriate.
88 + </li>
89 +</ul>
90 +
91 +<p>
92 +It should be clear from the above that <c>need</c> is the only "true" dependency
93 +setting as it affects if the script will be started or not. All the others are
94 +merely pointers towards the init system to clarify in which order scripts can be
95 +(or should be) launched.
96 +</p>
97 +
98 +<p>
99 +Now, if you look at many of Gentoo's available init scripts, you will notice
100 +that some have dependencies on things that are no init scripts. These "things"
101 +we call <e>virtuals</e>.
102 </p>
103
104 <p>
105 @@ -511,16 +559,12 @@
106 <body>
107
108 <p>
109 -In some cases you might not require a service, but want your service to be
110 -started <c>before</c> (or <c>after</c>) another service <e>if</e> it is
111 -available on the system (note the conditional - this is no dependency anymore)
112 -<e>and</e> run in the same runlevel (note the conditional - only services in the
113 -same runlevel are involved). You can provide this information using the
114 -<c>before</c> or <c>after</c> settings.
115 -</p>
116 -
117 -<p>
118 -As an example we view the settings of the Portmap service:
119 +As we described in the previous section, you can tell the init system what order
120 +it should use for starting (or stopping) scripts. This ordering is handled both
121 +through the dependency settings <c>use</c> and <c>need</c>, but also through the
122 +order settings <c>before</c> and <c>after</c>. As we have described these
123 +earlier already, let's take a look at the Portmap service as an example of such
124 +init script.
125 </p>
126
127 <pre caption="The depend() function in the Portmap service">