16
16
PATH=/sbin:/usr/sbin:/bin:/usr/bin
19
# Un-comment the following for debugging.
19
# Un-comment the following for interactive debugging. Do not un-comment
20
# this for debugging a real boot process as no scripts will be executed.
22
23
# Specify method used to enable concurrent init.d scripts.
23
# Valid options are 'none', 'shell' and 'startpar'. To enable the
24
# concurrent boot option, the init.d script order must allow for
24
# Valid options are 'none', 'startpar' and 'makefile'. To enable
25
# the concurrent boot option, the init.d script order must allow for
25
26
# concurrency. This is not the case with the default boot sequence in
26
27
# Debian as of 2008-01-20. Before enabling concurrency, one need to
27
28
# check the sequence values of all boot scripts, and make sure only
72
73
export runlevel previous
75
if [ -f /etc/default/rcS ] ; then
77
80
if [ -f /lib/lsb/init-functions ] ; then
78
. /lib/lsb/init-functions
81
. /lib/lsb/init-functions
80
log_action_msg() { echo $@; }
83
log_action_msg() { echo $@; }
84
log_failure_msg() { echo $@; }
85
log_warning_msg() { echo $@; }
84
89
# Stub to do progress bar ticks (for splash programs) on startup
86
91
startup_progress() {
87
# Avoid divide by zero if anyone moved xdm/kdm/gdm first in a runlevel.
88
if [ 0 -eq "$num_steps" ] ; then return; fi
92
# Avoid divide by zero if anyone moved xdm/kdm/gdm first in a runlevel.
93
if [ 0 -eq "$num_steps" ] ; then return; fi
90
step=$(($step + $step_change))
91
progress=$(($step * $progress_size / $num_steps + $first_step))
92
$debug splash_progress "$progress" || true
95
step=$(($step + $step_change))
96
progress=$(($step * $progress_size / $num_steps + $first_step))
97
$debug splash_progress "$progress" || true
96
# Debian Policy §9.3.1 requires .sh scripts in runlevel S to be
97
# sourced However, some important packages currently contain .sh
98
# scripts that do "exit" at some point, thus killing this process and
99
# the boot. Bad! See also bug #339955.
100
#[ S = "$runlevel" ] && sh=.
103
101
# Check if we are able to use make like booting. It require the
104
# insserv package to be enabled.
102
# insserv package to be enabled. Boot concurrency also requires
103
# startpar to be installed.
106
if [ startpar = "$CONCURRENCY" ] ; then
107
test -s /etc/init.d/.depend.boot || CONCURRENCY="none"
108
test -s /etc/init.d/.depend.start || CONCURRENCY="none"
109
test -s /etc/init.d/.depend.stop || CONCURRENCY="none"
110
startpar -v > /dev/null 2>&1 || CONCURRENCY="none"
112
# startpar do not work properly at the start of rcS.d/. Avoid it.
113
# See #457896 for details.
115
if [ S = "$runlevel" ] ; then
105
if [ "none" != "$CONCURRENCY" ] ; then
106
test -s /etc/init.d/.depend.boot || CONCURRENCY="none"
107
test -s /etc/init.d/.depend.start || CONCURRENCY="none"
108
test -s /etc/init.d/.depend.stop || CONCURRENCY="none"
109
startpar -v > /dev/null 2>&1 || CONCURRENCY="none"
121
113
# Start script or program.
123
115
case "$CONCURRENCY" in
125
log_action_msg "Using shell-style concurrent boot in runlevel $runlevel"
131
for script in $scripts ; do
134
if [ "." = "$sh" ] ; then
141
$debug $sh "$script" $action
146
$debug "$script" $action &
152
[ 1 = "$backgrounded" ] && wait
156
log_action_msg "Using startpar-style concurrent boot in runlevel $runlevel"
161
# Make sure .sh scripts are sourced in runlevel S
162
if [ "." = "$sh" ] ; then
164
for script in $scripts ; do
174
newscripts="$newscripts $script"
175
step=$(($step + $step_change))
179
scripts="$newscripts"
116
startpar|shell) # shell is obsolete
117
log_action_msg "Using startpar-style concurrent boot in runlevel $runlevel"
181
123
# Update progress bar counter and jump to the new position
182
124
for script in $scripts ; do
183
125
step=$(($step + $step_change))
187
# startpar is not able to handle time jumps. So the
188
# hwclock.sh scripts should not be executed from
189
# within startpar. The .sh hack above make this
190
# problem irrelevant. [pere 2005-09-10]
191
[ -n "$scripts" ] && $debug startpar -a $action $scripts
193
# Jump back one step to compencate for stepping one
194
# time too many in the for loop, and to keep the same
195
# location as the startup_progress call in the *.sh
197
step=$(($step - $step_change))
206
for script in $scripts ; do
209
if [ "." = "$sh" ] ; then
216
$debug $sh "$script" $action
128
[ -n "$scripts" ] && $debug startpar -a $action $scripts
130
# Jump back one step to compencate for stepping one
131
# time too many in the for loop.
132
step=$(($step - $step_change))
137
log_action_msg "Using makefile-style concurrent boot in runlevel $runlevel"
138
# The splash API is not handled with this CONCURRENCY mode
140
eval "$(startpar -p 4 -t 20 -T 3 -M $1 -P $previous -R $runlevel)"
142
if [ -n "$failed_service" ]
144
log_failure_msg "startpar: service(s) returned failure: $failed_service"
147
if [ -n "$skipped_service" ]
149
log_warning_msg "startpar: service(s) skipped: $skipped_service"
152
unset failed_service skipped_service
160
for script in $scripts ; do
221
161
$debug "$script" $action
230
168
# Check if the splash screen should be stopped before the given
232
170
is_splash_stop_scripts() {
234
case "$scriptname" in
235
# killprocs is used in runlevel 1
236
gdm|xdm|kdm|ltsp-client|ltsp-client-core|reboot|halt|killprocs)
172
case "$scriptname" in
173
# killprocs is used in runlevel 1
174
gdm|xdm|kdm|ltsp-client|ltsp-client-core|reboot|halt|killprocs)
243
181
# Is there an rc directory for this new runlevel?
326
267
# Stop the service.
327
268
SCRIPTS="$SCRIPTS $i"
328
269
if is_splash_stop_scripts "$suffix" ; then
270
$debug splash_stop || true
332
273
startup stop $SCRIPTS
336
# Now run the START scripts for this runlevel.
337
# Run all scripts with the same level in parallel
339
for s in /etc/rc$runlevel.d/S*
341
# Extract order value from symlink
342
level=${s#/etc/rc$runlevel.d/S}
343
level=${level%%[a-zA-Z]*}
344
if [ "$level" = "$CURLEVEL" ]
277
if [ makefile = "$CONCURRENCY" ]
279
if [ S = "$runlevel" ]
350
for i in /etc/rc$runlevel.d/S$level*
286
# Now run the START scripts for this runlevel.
287
# Run all scripts with the same level in parallel
289
for s in /etc/rc$runlevel.d/S*
352
[ ! -f $i ] && continue
354
suffix=${i#/etc/rc$runlevel.d/S[0-9][0-9]}
355
if [ "$previous" != N ]
291
# Extract order value from symlink
292
level=${s#/etc/rc$runlevel.d/S}
293
level=${level%%[a-zA-Z]*}
294
if [ "$level" = "$CURLEVEL" ]
358
# Find start script in previous runlevel and
359
# stop script in this runlevel.
361
stop=/etc/rc$runlevel.d/K[0-9][0-9]$suffix
362
previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix
364
# If there is a start script in the previous level
365
# and _no_ stop script in this level, we don't
366
# have to re-start the service.
368
if [ start = "$ACTION" ] ; then
369
[ -f $previous_start ] && [ ! -f $stop ] && continue
371
# Workaround for the special
372
# handling of runlevels 0 and 6.
373
previous_stop=/etc/rc$previous.d/K[0-9][0-9]$suffix
375
# If there is a stop script in the previous level
376
# and _no_ start script there, we don't
377
# have to re-stop the service.
379
[ -f $previous_stop ] && [ ! -f $previous_start ] && continue
383
SCRIPTS="$SCRIPTS $i"
384
if is_splash_stop_scripts "$suffix" ; then
300
for i in /etc/rc$runlevel.d/S$level*
302
[ ! -f $i ] && continue
304
suffix=${i#/etc/rc$runlevel.d/S[0-9][0-9]}
305
if [ "$previous" != N ]
308
# Find start script in previous runlevel and
309
# stop script in this runlevel.
311
stop=/etc/rc$runlevel.d/K[0-9][0-9]$suffix
312
previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix
314
# If there is a start script in the previous level
315
# and _no_ stop script in this level, we don't
316
# have to re-start the service.
318
if [ start = "$ACTION" ] ; then
319
[ -f $previous_start ] && [ ! -f $stop ] && continue
321
# Workaround for the special
322
# handling of runlevels 0 and 6.
323
previous_stop=/etc/rc$previous.d/K[0-9][0-9]$suffix
325
# If there is a stop script in the previous level
326
# and _no_ start script there, we don't
327
# have to re-stop the service.
329
[ -f $previous_stop ] && [ ! -f $previous_start ] && continue
333
SCRIPTS="$SCRIPTS $i"
334
if is_splash_stop_scripts "$suffix" ; then
335
$debug splash_stop || true
338
startup $ACTION $SCRIPTS
388
startup $ACTION $SCRIPTS
392
if [ S = "$runlevel" ]
395
# For compatibility, run the files in /etc/rc.boot too.
397
[ -d /etc/rc.boot ] && run-parts /etc/rc.boot
400
343
trap - EXIT # Disable emergency handler