-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrunlevel.conf.5
238 lines (219 loc) · 6.73 KB
/
runlevel.conf.5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
.\" Copyright (c) 1999-2006 Roland Rosenfeld <roland@debian.org>
.\"
.\" This manual page is free software; you can redistribute it and/or modify
.\" it under the terms of the GNU General Public License as published by
.\" the Free Software Foundation; either version 2 of the License, or
.\" (at your option) any later version.
.\"
.\" This program is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public License
.\" along with this program; if not, write to the Free Software
.\" Foundation, Inc.,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
.\"
.TH RUNLEVEL.CONF 5 "June 2006" "Debian Project" "Debian GNU/Linux"
.SH NAME
runlevel.conf \- The file-rc runlevel configuration file
.SH DESCRIPTION
.B runlevel.conf
is the configuration file for the package
.B file-rc
an alternative
.BR init (8)
boot concept. While the SysV init scheme implements runlevels through
symlinks in
.BI /etc/rc ? .d/*
,
.B file-rc
uses only one file
.B runlevel.conf
to replace all these symlinks.
.PP
This file consists of 4 columns separated by TABs or spaces with the
following contents:
.IP - 3
The first column is the sort criteria for starting and stopping
the scripts.
.IP - 3
The second column consists of a comma-separated list of runlevels in
which the script should be switched `off'
.I or
a single
.RB ` - '
if the script should never be stopped (within that sort-number).
.IP - 3
The third column consists of a comma-separated list of runlevels in
which the script should be switched `on'
.I or
a single
.RB ` - '
if the script should never be started (with that sort-number).
.IP - 3
The last column specifies the full name of the script.
.PP
Lines beginning with
.RB ` # '
and empty lines are ignored.
.SS Overview
All scripts executed by the init system are located in
.IR /etc/init.d .
.P
If a scripts has the
.I ".sh"
suffix it is a bourne shell script and MAY be handled in an optimized
manner. The behaviour of executing script in an optimized way will
not differ in any way from it being forked and executed in the regular
way.
.P
The following runlevels are defined:
.TP
.B N
System bootup (NONE).
.TP
.B S
Single user mode (not to be switched to directly)
.TP
.B 0
halt
.TP
.B 1
single user mode
.TP
.BR 2 .. 5
multi user mode
.TP
.B 6
reboot
.SS Boot
When the systems boots, the lines with
.RI ' S '
in the third column are executed. It in turn executes all these
scripts in alphabetical (and thus numerical) order. The
first argument passed to the executed scripts is
.IR start .
The runlevel at this point is
.RI ' N '
(none).
.P
Only things that need to be run once to get the system in a consistent
state are to be run. The
.RI ' S '
state is NOT meant to replace
.IR rc.local .
One should not start daemons in this runlevel unless absolutely
necessary. Eg, NFS might need the portmapper, so it is OK to start it
early in the bootprocess. But this is not the time to start the squid
proxy server.
.SS "Going multiuser"
After the
.RI ' S '
scripts have been executed, init switches to the default runlevel as
specified in
.IR /etc/inittab ,
usually
.RI ' 2 '.
.P
.BR init (8)
then executes the
.I /etc/init.d/rc
script which takes care of starting the services with
.RI ' 2 '
in the third column.
.P
Because the previous runlevel is
.RI ' N '
(none) the scripts with
.RI ' 2 '
in the second column will NOT be executed - there is nothing to stop
yet, the system is busy coming up.
.P
If for example there is a service that wants to run in runlevel 4
and ONLY in that level, it will place
.RI ' 2,3,5 '
in the second column to stop the service when switching out of
runlevel 4. We do not need to run that script at this point.
.P
The scripts will be executed in alphabetical order, with the first
argument set to
.RI ' start '.
.SS "Switching runlevels"
When one switches from (for example) runlevel 2 to runlevel 3,
.B /etc/init.d/rc
will first execute in alphabetical order all scripts with
.RI ' 3 '
in the second column with
.RI ' stop '
as first argument and then all scripts with
.RI ' 3 '
in the third column with
.RI ' start '
as first argument.
.P
As an optimization, a check is made for each "service" to see if it
was already running in the previous runlevel. If it was, and there is
no entry present in the second column for the new runlevel, there is
no need to start it a second time so that will not be done.
.P
On the other hand, if there was an entry in the second column, it is
assumed the service was stopped on purpose first and so needs to be
restarted.
.P
We MIGHT make the same optimization for stop scripts as well - if no
entry in the third column was present in the previous runlevel, we can
assume that service was not running and we don't need to stop it
either. In that case we can remove the "coming from level N" special
case mentioned above. But right now that has not been implemented.
.SS "Single user mode"
Switching to single user mode is done by switching to runlevel 1.
That will cause all services to be stopped (assuming they all have
.RI ' 1 '
in the second column). The runlevel 1 scripts will then switch to
runlevel
.RI ' S '
which has no scripts - all it does is spawn a shell directly on
.B /dev/console
for maintenance.
.SS "Halt/reboot"
Going to runlevel 0 or 6 will cause the system to be halted or
rebooted, respectively. For example, if we go to runlevel 6 (reboot)
first all scripts with
.RI ' 6 '
in the second column will be executed alphabetically with
.RI ' stop '
as the first argument.
.P
Then the scripts with
.RI ' 6 '
in the third column will be executed alphabetically with
.RI ' stop '
as the first argument as well. The reason is that there is nothing to
start anymore at this point - all scripts that are run are meant to
bring the system down.
.SH EXAMPLES
.nf
#<sort> <off> <on> <script>
05 - 0 /etc/init.d/halt
05 - 1 /etc/init.d/single
05 - 6 /etc/init.d/reboot
10 0,1,6 2,3,4,5 /etc/init.d/sysklogd
12 0,1,6 2,3,4,5 /etc/init.d/kerneld
[...]
89 0,1,6 2,3,4,5 /etc/init.d/cron
99 - 2,3,4,5 /etc/init.d/rmnologin
99 0,1,6 2,3,4,5 /etc/init.d/xdm
.fi
.SH FILES
/etc/runlevel.conf
.SH AUTHOR
.B file-rc
was originally written by Winfried Tr\[:u]mper <winni@xpilot.org> and
adapted to the Debian system by Tom Lees <tom@lpsg.demon.co.uk>,
Martin Schulze <joey@debian.org> and Roland Rosenfeld
<roland@debian.org>.
.PP
This man page was written by Roland Rosenfeld <roland@debian.org>.
.SH "SEE ALSO"
.BR init (8)