/[gentoo]/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml
Gentoo

Diff of /xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.15 Revision 1.16
2<!DOCTYPE sections SYSTEM "/dtd/book.dtd"> 2<!DOCTYPE sections SYSTEM "/dtd/book.dtd">
3 3
4<!-- The content of this document is licensed under the CC-BY-SA license --> 4<!-- The content of this document is licensed under the CC-BY-SA license -->
5<!-- See http://creativecommons.org/licenses/by-sa/1.0 --> 5<!-- See http://creativecommons.org/licenses/by-sa/1.0 -->
6 6
7<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml,v 1.15 2004/08/28 19:26:18 dertobi123 Exp $ --> 7<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml,v 1.16 2004/08/30 17:44:00 neysx Exp $ -->
8 8
9<sections> 9<sections>
10<section> 10<section>
11<title>Runlevels</title> 11<title>Runlevels</title>
12<subsection> 12<subsection>
83configuration file that specifies what actions need to be taken. This 83configuration file that specifies what actions need to be taken. This
84configuration file is <path>/etc/inittab</path>. 84configuration file is <path>/etc/inittab</path>.
85</p> 85</p>
86 86
87<p> 87<p>
88If you remember the boot sequence we have just explained to you, you will 88If you remember the boot sequence we have just described, you will remember
89remember that <c>init</c>'s first action is to mount all filesystems. This is 89that <c>init</c>'s first action is to mount all filesystems. This is defined in
90defined in the following line from <path>/etc/inittab</path>: 90the following line from <path>/etc/inittab</path>:
91</p> 91</p>
92 92
93<pre caption="The system initialisation line in /etc/inittab"> 93<pre caption="The system initialisation line in /etc/inittab">
94si::sysinit:/sbin/rc sysinit 94si::sysinit:/sbin/rc sysinit
95</pre> 95</pre>
271<pre caption="Requesting a list of all services that require Postfix"> 271<pre caption="Requesting a list of all services that require Postfix">
272# <i>/etc/init.d/postfix needsme</i> 272# <i>/etc/init.d/postfix needsme</i>
273</pre> 273</pre>
274 274
275<p> 275<p>
276Finally, you can ask what dependencies the service requires but that are 276Finally, you can ask what dependencies the service requires that are missing:
277missing:
278</p> 277</p>
279 278
280<pre caption="Requesting a list of missing dependencies for Postfix"> 279<pre caption="Requesting a list of missing dependencies for Postfix">
281# <i>/etc/init.d/postfix broken</i> 280# <i>/etc/init.d/postfix broken</i>
282</pre> 281</pre>
290<title>What is rc-update?</title> 289<title>What is rc-update?</title>
291<body> 290<body>
292 291
293<p> 292<p>
294Gentoo's init system uses a dependency-tree to decide what service needs to be 293Gentoo's init system uses a dependency-tree to decide what service needs to be
295started first. As this is a tedious task that we wouldn't want our users to do 294started first. As this is a tedious task that we wouldn't want our users to
296manually, we have created tools that ease the administration of the runlevels 295have to do manually, we have created tools that ease the administration of the
297and init scripts. 296runlevels and init scripts.
298</p> 297</p>
299 298
300<p> 299<p>
301With <c>rc-update</c> you can add and remove init scripts to a runlevel. The 300With <c>rc-update</c> you can add and remove init scripts to a runlevel. The
302<c>rc-update</c> tool will then automatically ask the <c>depscan.sh</c> script 301<c>rc-update</c> tool will then automatically ask the <c>depscan.sh</c> script
342<subsection> 341<subsection>
343<title>Why the Need for Extra Configuration?</title> 342<title>Why the Need for Extra Configuration?</title>
344<body> 343<body>
345 344
346<p> 345<p>
347Init scripts can be quite complex. It is therefore not really interesting to 346Init scripts can be quite complex. It is therefore not really desirable to
348have the users directly edit the init script, as it would make it more 347have the users edit the init script directly, as it would make it more
349error-prone. It is however important to be able to configure such a service. For 348error-prone. It is however important to be able to configure such a service. For
350instance, you might want to give more options to the service itself. 349instance, you might want to give more options to the service itself.
351</p> 350</p>
352 351
353<p> 352<p>
354A second reason to have this configuration outside the init script is to be able 353A second reason to have this configuration outside the init script is to be
355to update the init scripts without being afraid that your configuration changes 354able to update the init scripts without the fear that your configuration
356are undone. 355changes will be undone.
357</p> 356</p>
358 357
359</body> 358</body>
360</subsection> 359</subsection>
361<subsection> 360<subsection>
388<subsection> 387<subsection>
389<title>Do I Have To?</title> 388<title>Do I Have To?</title>
390<body> 389<body>
391 390
392<p> 391<p>
393No. Writing an init script is usually not necessary as Gentoo provides 392No, writing an init script is usually not necessary as Gentoo provides
394ready-to-use init scripts for all provided services. However, you might have 393ready-to-use init scripts for all provided services. However, you might have
395installed a service without using Portage, in which case you will most likely 394installed a service without using Portage, in which case you will most likely
396have to create an init script. 395have to create an init script.
397</p> 396</p>
398 397
521} 520}
522</pre> 521</pre>
523 522
524<p> 523<p>
525You can also use the "*" glob to catch all services in the same runlevel, 524You can also use the "*" glob to catch all services in the same runlevel,
526although this isn't adviseable. 525although this isn't advisable.
527</p> 526</p>
528 527
529<pre caption="Running an init script as first script in the runlevel"> 528<pre caption="Running an init script as first script in the runlevel">
530depend() { 529depend() {
531 before * 530 before *
539<body> 538<body>
540 539
541<p> 540<p>
542Next to the <c>depend()</c> functionality, you also need to define the 541Next to the <c>depend()</c> functionality, you also need to define the
543<c>start()</c> function. This one contains all the commands necessary to 542<c>start()</c> function. This one contains all the commands necessary to
544initialize your service. It is adviseable to use the <c>ebegin</c> and 543initialize your service. It is advisable to use the <c>ebegin</c> and
545<c>eend</c> functions to inform the user about what is happening: 544<c>eend</c> functions to inform the user about what is happening:
546</p> 545</p>
547 546
548<pre caption="Example start() function"> 547<pre caption="Example start() function">
549start() { 548start() {

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

  ViewVC Help
Powered by ViewVC 1.1.20