website view en/doc/scratchbook/boot-scripts.html @ rev 1344

Resize balinor logo to 120px
author Christophe Lincoln <pankso@slitaz.org>
date Fri Jan 22 23:02:15 2021 +0100 (2021-01-22)
parents c2f9d5d0f314
children
line source
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="UTF-8">
5 <title>SliTaz Scratchbook - Boot Scripts</title>
6 <meta name="description" content="">
7 <meta name="expires" content="never">
8 <meta name="modified" content="2008-11-22 17:00:00">
9 <meta name="publisher" content="www.slitaz.org">
10 <meta name="author" content="Christophe Lincoln">
11 <link rel="shortcut icon" href="favicon.ico">
12 <link rel="stylesheet" href="book.css">
13 </head>
14 <body>
16 <!-- Header and quick navigation -->
17 <div id="header">
18 <div align="right" id="quicknav">
19 <span id="top"></span>
20 <a href="locale.html">Locale &amp; i18n</a> |
21 <a href="index.html">Table of contents</a> |
22 <a href="x-window-system.html">X window system</a>
23 </div>
24 <h1><font color="#3E1220">SliTaz Scratchbook</font></h1>
25 </div>
27 <!-- Content. -->
28 <div id="content">
29 <div class="content-right"></div>
31 <h2><font color="#df8f06">Boot scripts</font></h2>
32 <p>
33 The startup and shutdown scripts with their configuration files.
34 </p>
36 <ul>
37 <li><a href="#intro">SliTaz and startup.</a></li>
38 <li><a href="#init.d">/etc/init.d/*</a> - Directory of scripts and daemons.</li>
39 <li><a href="#rcS">/etc/init.d/rcS</a> - Primary initialization script.</li>
40 <li><a href="#rc-scripts">Specific scripts and daemons</a> - Scripts and
41 daemons with a very specific task.</li>
42 <li><a href="#inittab">/etc/inittab</a> - Configuration file init.</li>
43 </ul>
45 <h3 id="intro">SliTaz and startup</h3>
47 <p>
48 SliTaz does not use a level of execution (runlevel), the
49 system is initialized via a primary script and its main
50 configuration file. This script itself launches some other smaller
51 scripts which deal with the internationalization or the
52 commands placed for the system to start.
53 </p>
55 <h3 id="init.d">/etc/init.d/* - Directory of scripts and daemons</h3>
56 <p>
57 The directory /etc/init.d contains all of the rc scripts,
58 scripts finishing with ‘.sh’ are simple shell scripts and
59 daemons such as ‘dropbear’ or ‘lighttpd’ are scripts
60 that launch a service. The daemon scripts can start, stop or
61 restart through the command:
62 </p>
63 <pre> # /etc/init.d/daemon [start|stop|restart]
64 </pre>
65 <p>
66 On SliTaz you will find a /etc/init.d/README describing the
67 basic function of rc scripts. Also note that all startup
68 scripts and daemons can call upon the <code>/etc/init.d/rc.functions</code>
69 file. This file makes it possible to include various functions
70 in rc scripts. SliTaz uses a function <code>status</code> to check whether
71 the previous command has succeeded (0) or not.
72 </p>
74 <h3 id="rcS">/etc/init.d/rcS - Primary initialization script</h3>
75 <p>
76 The <code>/etc/init.d/rcS</code> script configures all the
77 basic services and initializes the base system. It begins by
78 mounting the filesystems and starts services like syslogd, klogd,
79 mdev and cleans up the system and so on. It
80 uses the configuration file <code>/etc/rcS.conf</code> to locate which daemons
81 and scripts to launch at startup. You can browse the script
82 to know which commands are executed:
83 </p>
84 <pre> # nano rootfs/etc/init.d/rcS
85 </pre>
88 <h3 id="rc-scripts">Specific scripts and daemons</h3>
90 <h4>bootopts.sh - LiveCD mode options</h4>
91 <p>
92 This script is used to configure the LiveCD options passed
93 at boot time and is readable via the /proc/cmdline file.
94 This is the script that allows you to use a USB key or
95 external hard disk <code>/home</code> partition with the option home=usb
96 or home=sda[1-9] or directly specify the language and
97 keyboard parameters.
98 </p>
100 <h4>network.sh - Initializing the network</h4>
101 <p>
102 This script searches the network.sh configuration file
103 /etc/network.conf for the network interface to use; if one wants to
104 launch the DHCP client (or not) or if you want to use a fixed
105 (static) IP. On SliTaz the /etc/init.d/network.sh
106 script configures the network interfaces to start using the
107 information contained in /etc/network.conf. If the variable
108 $DHCP is equal to yes, then the /etc/init.d/network.sh
109 script launches the DHCP client on the $INTERFACE interface.
110 </p>
112 <h4>i18n.sh - Internationalization</h4>
113 <p>
114 SliTaz backs up the configuration of the default locale in
115 /etc/locale.conf which is read by /etc/profile at each
116 login. The /etc/locale.conf is generated during boot time
117 thanks to the /etc/i18n.sh script. This script launches the
118 ‘tazlocale’ application if /etc/locale.conf doesn't exist.
119 We use the same process for the keyboard layout using ‘tazkmap’
120 and the /etc/kmap.conf configuration file. Both applications
121 are installed and located in /sbin and use dialog and the
122 ncurses library. The script also checks whether the
123 configuration file for the time zone /etc/TZ exists,
124 otherwise it creates one relying on the keyboard configuration.
125 </p>
127 <h4>local.sh - Local commands</h4>
128 <p>
129 The /etc/init.d/local.sh script allows the system administrator
130 to add local commands to be executed at boot. Example:
131 </p>
132 <pre class="script">#!/bin/sh
133 # /etc/init.d/local.sh: Local startup commands.
134 # All commands here will be executed at boot time.
135 #
136 . /etc/init.d/rc.functions
138 echo "Starting local startup commands... "
140 </pre>
142 <h4>rc.shutdown</h4>
143 <p>
144 This script is invoked by /etc/inittab during system shutdown.
145 It also stops all daemons via the variable RUN_DAEMONS in
146 the primary <code>/etc/rcS.conf</code> configuration file.
147 </p>
149 <h3 id="inittab">/etc/inittab - Configuration file init</h3>
150 <p>
151 The first file read by the Kernel at boot. It defines the
152 initialization script (/etc/init.d/rcS), shells (ttys) and
153 actions in the event of a reboot or disruption. You will find
154 a complete example with accompanying notes in <a href="http://doc.slitaz.org/en:cookbook:slitaztools">SliTaz tools</a>:
155 </p>
156 <pre class="script"># /etc/inittab: init configuration for SliTaz GNU/Linux.
157 # Boot-time system configuration/initialization script.
158 #
159 ::sysinit:/etc/init.d/rcS
161 # /sbin/getty respawn shell invocations for selected ttys.
162 tty1::respawn:/sbin/getty 38400 tty1
163 tty2::respawn:/sbin/getty 38400 tty2
164 tty3::respawn:/sbin/getty 38400 tty3
165 tty4::respawn:/sbin/getty 38400 tty4
166 tty5::respawn:/sbin/getty 38400 tty5
167 tty6::respawn:/sbin/getty 38400 tty6
169 # Stuff to do when restarting the init
170 # process, or before rebooting.
171 ::restart:/etc/init.d/rc.shutdown
172 ::restart:/sbin/init
173 ::ctrlaltdel:/sbin/reboot
174 ::shutdown:/etc/init.d/rc.shutdown
176 </pre>
177 <h4>Following chapter</h4>
178 <p>
179 The next chapter continues on with the <a href="x-window-system.html">X window system</a>.
180 </p>
182 <!-- End of content -->
183 </div>
185 <!-- Footer. -->
186 <div id="footer">
187 <div class="footer-right"></div>
188 <a href="#top">Top of the page</a> |
189 <a href="index.html">Table of contents</a>
190 </div>
192 <div id="copy">
193 Copyright &copy; <span class="year"></span> <a href="http://www.slitaz.org/en/">SliTaz</a> -
194 <a href="http://www.gnu.org/licenses/gpl.html">GNU General Public License</a>;<br />
195 Documentation is under
196 <a href="http://www.gnu.org/copyleft/fdl.html">GNU Free Documentation License</a>
197 and code is <a href="http://validator.w3.org/">valid xHTML 1.0</a>.
198 </div>
200 </body>
201 </html>