/[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.35 Revision 1.38
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/2.5 --> 5<!-- See http://creativecommons.org/licenses/by-sa/2.5 -->
6 6
7<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml,v 1.35 2011/08/17 07:57:23 swift Exp $ --> 7<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/handbook/hb-working-rcscripts.xml,v 1.38 2012/10/31 19:02:20 swift Exp $ -->
8 8
9<sections> 9<sections>
10 10
11<abstract> 11<abstract>
12Gentoo uses a special initscript format which, amongst other features, allows 12Gentoo uses a special initscript format which, amongst other features, allows
13dependency-driven decisions and virtual initscripts. This chapter explains all 13dependency-driven decisions and virtual initscripts. This chapter explains all
14these aspects and explains how to deal with these scripts. 14these aspects and explains how to deal with these scripts.
15</abstract> 15</abstract>
16 16
17<version>4</version> 17<version>7</version>
18<date>2011-08-17</date> 18<date>2012-10-31</date>
19 19
20<section> 20<section>
21<title>Runlevels</title> 21<title>Runlevels</title>
22<subsection> 22<subsection>
23<title>Booting your System</title> 23<title>Booting your System</title>
388APACHE2_OPTS="-D PHP5" 388APACHE2_OPTS="-D PHP5"
389</pre> 389</pre>
390 390
391<p> 391<p>
392Such a configuration file contains variables and variables alone (just like 392Such a configuration file contains variables and variables alone (just like
393<path>/etc/make.conf</path>), making it very easy to configure services. It also 393<path>/etc/portage/make.conf</path>), making it very easy to configure services.
394allows us to provide more information about the variables (as comments). 394It also allows us to provide more information about the variables (as comments).
395</p> 395</p>
396 396
397</body> 397</body>
398</subsection> 398</subsection>
399</section> 399</section>
701<pre caption="Getting the man page for start-stop-daemon"> 701<pre caption="Getting the man page for start-stop-daemon">
702$ <i>man start-stop-daemon</i> 702$ <i>man start-stop-daemon</i>
703</pre> 703</pre>
704 704
705<p> 705<p>
706Gentoo's init script syntax is based on the Bourne Again Shell (bash) so you are 706Gentoo's init script syntax is based on the POSIX Shell so you are
707free to use bash-compatible constructs inside your init script. However, you may 707free to use sh-compatible constructs inside your init script. Keep other
708want to write your init scripts to be POSIX-compliant. Future init script 708constructs, like bash-specific ones, out of the init scripts to ensure that the
709systems may allow symlinking <path>/bin/sh</path> to other shells besides 709scripts remain functional regardless of the change Gentoo might do on its init
710bash. Init scripts that rely on bash-only features will then break these 710system.
711configurations.
712</p> 711</p>
713 712
714</body> 713</body>
715</subsection> 714</subsection>
716<subsection> 715<subsection>
717<title>Adding Custom Options</title> 716<title>Adding Custom Options</title>
718<body> 717<body>
719 718
720<p> 719<p>
721If you want your init script to support more options than the ones we have 720If you want your init script to support more options than the ones we have
722already encountered, you should add the option to the <c>opts</c> variable, and 721already encountered, you should add the option to the <c>extra_commands</c>
723create a function with the same name as the option. For instance, to support an 722variable, and create a function with the same name as the option. For instance,
724option called <c>restartdelay</c>: 723to support an option called <c>restartdelay</c>:
725</p> 724</p>
726 725
727<pre caption="Supporting the restartdelay option"> 726<pre caption="Supporting the restartdelay option">
728opts="${opts} restartdelay" 727extra_commands="restartdelay"
729 728
730restartdelay() { 729restartdelay() {
731 stop 730 stop
732 sleep 3 <comment># Wait 3 seconds before starting again</comment> 731 sleep 3 <comment># Wait 3 seconds before starting again</comment>
733 start 732 start

Legend:
Removed from v.1.35  
changed lines
  Added in v.1.38

  ViewVC Help
Powered by ViewVC 1.1.20