~ubuntu-branches/ubuntu/natty/sysvinit/natty-updates

« back to all changes in this revision

Viewing changes to debian/sysv-rc/etc/init.d/rc

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2009-09-07 19:56:53 UTC
  • mfrom: (1.1.4 upstream) (2.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20090907195653-2i6t0j91wfbf1f0d
Tags: 2.87dsf-4ubuntu1
* Merge from debian unstable, remaining changes:
  - Support Cell processor:
    + debian/initscripts/postinst: Create spu system group and /spu mount
      point if we are running on a Cell processor.
    + debian/initscripts/etc/init.d/mountkernfs.sh: Mount spufs if Cell
      processor is detected.
    + debian/initscripts/lib/init/mount-functions.sh: Modprobe spufs
      if not available.
    + debian/control: Add initscripts dependency 'passwd' for groupadd.
    (Forwarded to Debian #483399)
  - Use tmpfs mounts for /var/lock and /var/run:
    + debian/initscripts/share/default.rcS: Enable RAMRUN and RAMLOCK by
      default.
    + debian/initscripts.postinst: Enable RAMRUN and RAMLOCK in
      /etc/default/rcS on upgrades. This needs to be kept until the next
      LTS.
    + debian/initscripts/etc/init.d/mountkernfs.sh: Propagate files from the
      initramfs to our new /var/run, so that we can populate
      /var/run/sendsigs.omit from initramfs.
  - Boot ordering differences:
    + mountkernfs.sh: 02 -> 01
    + mountdevsubfs.sh: 04 -> 11
    + bootlogd: disabled by default
    + checkroot.sh: 10 -> 20
    + mtab.sh: 12 -> 22
  - debian/patches/91_sulogin_lockedpw.dpatch: Disable "root account is
    locked" warning, since this is the default in Ubuntu. Document this in
    sulogin.8.
  - debian/control: Drop Essential: yes from packages since we use Upstart.
  - debian/control: Conflict/Replace sysvconfig which has also previously
    provided service(8).
  - debian/control, debian/rules: Previous name for sysvinit-utils was
    'sysvutils' in Ubuntu, so Conflict/Replace/Provide it. Also create a
    dummy sysvutils package, since Hardy has reverse versioned dependencies
    to it. This needs to be kept until after the next LTS.
  - debian/control: Depend on lsb-base (>= 3.2-14) for status_of_proc()
    function.
  - debian/initscripts/etc/init.d/checkfs.sh: Don't depend on hwclockfirst
    which Ubuntu does not have.
  - debian/initscripts/etc/init.d/mountkernfs.sh: Always mount devpts, and
    do not touch /dev/ptmx (which is already managed by udev).
  - debian/initscripts/etc/init.d/mountkernfs.sh: mount fusectl if it is
    available
  - debian/initscripts/etc/init.d/mountkernfs.sh: mount securityfs if it is
    available. This allows for easier AppArmor confinement of applications
    early in the boot process. LP: #399954
  - debian/initscripts/etc/init.d/mountkernfs.sh: mount debugfs if it is
    available.
  - debian/initscripts/etc/init.d/ondemand: Sleep for 60 seconds, then
    set CPU Frequency Scaling governor to "ondemand".   LP: #341573.
  - debian/initscripts/etc/init.d/umountfs: Don't unmount filesystems
    that precede root or use force for some mountpoints.
  - debian/initscripts/etc/network/if-up.d/mountnfs: Rename ifstate
    file to /var/run/network/ifstate
  - ./debian/initscripts/lib/init/usplash-fsck-functions.sh: Use blkid,
    vol_id is gone.
  - debian/initscripts.{pre,postinst}: waitnfs.sh -> mountnfs.sh renaming
    transition. This needs to be kept until after the next LTS.

LP: #32455, #94120, #160197, #382097 (amongst others).

* debian/sysv-rc/sbin/update-rc.d: Dropped support for "multiuser"
  command-line option.
* debian/rules: Compat symlink from /usr/bin/service to /usr/sbin/service
* debian/initscripts.postinst: Transition from bootlogs.sh to bootlogs

* debian/sysv-rc.postinst: Don't try and use insserv by default, though
  everything's in place for you to try if you like.  It can be activated
  with:
      USEINSSERV=yes dpkg-reconfigure sysv-rc

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
PATH=/sbin:/usr/sbin:/bin:/usr/bin
17
17
export PATH
18
18
 
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.
20
21
# debug=echo
21
22
 
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
37
38
umask 022
38
39
 
39
40
on_exit() {
40
 
    echo "error: '$scriptname' exited outside the expected code flow."
 
41
        echo "error: '$scriptname' exited outside the expected code flow."
41
42
}
42
43
trap on_exit EXIT # Enable emergency handler
43
44
 
49
50
 
50
51
# Functions for splash progress bars
51
52
if [ -e /lib/init/splash-functions-base ] ; then
52
 
    . /lib/init/splash-functions-base
 
53
        . /lib/init/splash-functions-base
53
54
else
54
 
    # Quiet down script if old initscripts version without /lib/init/splash-functions-base is used.
55
 
    splash_progress() { return 1; }
56
 
    splash_stop() { return 1; }
 
55
        # Quiet down script if old initscripts version without /lib/init/splash-functions-base is used.
 
56
        splash_progress() { return 1; }
 
57
        splash_stop() { return 1; }
57
58
fi
58
59
 
59
60
# Now find out what the current and what the previous runlevel are.
71
72
 
72
73
export runlevel previous
73
74
 
74
 
. /etc/default/rcS
 
75
if [ -f /etc/default/rcS ] ; then
 
76
        . /etc/default/rcS
 
77
fi
75
78
export VERBOSE
76
79
 
77
80
if [ -f /lib/lsb/init-functions ] ; then
78
 
    . /lib/lsb/init-functions
 
81
        . /lib/lsb/init-functions
79
82
else
80
 
    log_action_msg() { echo $@; }
 
83
        log_action_msg() { echo $@; }
 
84
        log_failure_msg() { echo $@; }
 
85
        log_warning_msg() { echo $@; }
81
86
fi
82
87
 
83
88
#
84
89
# Stub to do progress bar ticks (for splash programs) on startup
85
90
#
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
89
94
 
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
93
98
}
94
99
 
95
 
sh=sh
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=.
101
 
 
102
100
#
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.
105
104
#
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"
111
 
 
112
 
    # startpar do not work properly at the start of rcS.d/.  Avoid it.
113
 
    # See #457896 for details.
114
 
 
115
 
    if [ S = "$runlevel" ] ; then
116
 
        CONCURRENCY=none
117
 
    fi
 
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"
118
110
fi
119
111
 
120
112
#
121
113
# Start script or program.
122
114
#
123
115
case "$CONCURRENCY" in
124
 
  shell)
125
 
        log_action_msg "Using shell-style concurrent boot in runlevel $runlevel"
126
 
        startup() {
127
 
                action=$1
128
 
                shift
129
 
                scripts="$@"
130
 
                backgrounded=0
131
 
                for script in $scripts ; do
132
 
                        case "$script" in
133
 
                          *.sh)
134
 
                                if [ "." = "$sh" ] ; then
135
 
                                        RC_SAVE_PATH="$PATH"
136
 
                                        set -- "$action"
137
 
                                        $debug . "$script"
138
 
                                        PATH="$RC_SAVE_PATH"
139
 
                                        startup_progress
140
 
                                else
141
 
                                        $debug $sh "$script" $action
142
 
                                        startup_progress
143
 
                                fi
144
 
                                ;;
145
 
                          *)
146
 
                                $debug "$script" $action &
147
 
                                startup_progress
148
 
                                backgrounded=1
149
 
                                ;;
150
 
                        esac
151
 
                done
152
 
                [ 1 = "$backgrounded" ] && wait
153
 
        }
154
 
        ;;
155
 
  startpar)
156
 
        log_action_msg "Using startpar-style concurrent boot in runlevel $runlevel"
157
 
        startup() {
158
 
                action=$1
159
 
                shift
160
 
                scripts="$@"
161
 
                # Make sure .sh scripts are sourced in runlevel S
162
 
                if [ "." = "$sh" ] ; then
163
 
                        newscripts=
164
 
                        for script in $scripts ; do
165
 
                                case "$script" in
166
 
                                  *.sh)
167
 
                                        RC_SAVE_PATH="$PATH"
168
 
                                        set -- "$action"
169
 
                                        $debug . "$script"
170
 
                                        PATH="$RC_SAVE_PATH"
171
 
                                        startup_progress
172
 
                                        ;;
173
 
                                  *)
174
 
                                        newscripts="$newscripts $script"
175
 
                                        step=$(($step + $step_change))
176
 
                                        ;;
177
 
                                esac
178
 
                        done
179
 
                        scripts="$newscripts"
180
 
                else
 
116
        startpar|shell) # shell is obsolete
 
117
                log_action_msg "Using startpar-style concurrent boot in runlevel $runlevel"
 
118
                startup() {
 
119
                        action=$1
 
120
                        shift
 
121
                        scripts="$@"
 
122
 
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))
184
126
                        done
185
 
                fi
186
 
 
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
192
 
 
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
196
 
                # case.
197
 
                step=$(($step - $step_change))
198
 
                startup_progress
199
 
        }
200
 
        ;;
201
 
  none|*)
202
 
        startup() {
203
 
                action=$1
204
 
                shift
205
 
                scripts="$@"
206
 
                for script in $scripts ; do
207
 
                        case "$script" in
208
 
                          *.sh)
209
 
                                if [ "." = "$sh" ] ; then
210
 
                                        RC_SAVE_PATH="$PATH"
211
 
                                        set "$action"
212
 
                                        $debug . "$script"
213
 
                                        PATH="$RC_SAVE_PATH"
214
 
                                        startup_progress
215
 
                                else
216
 
                                        $debug $sh "$script" $action
217
 
                                        startup_progress
218
 
                                fi
219
 
                                ;;
220
 
                          *)
 
127
 
 
128
                        [ -n "$scripts" ] && $debug startpar -a $action $scripts
 
129
 
 
130
                        # Jump back one step to compencate for stepping one
 
131
                        # time too many in the for loop.
 
132
                        step=$(($step - $step_change))
 
133
                        startup_progress
 
134
                }
 
135
                ;;
 
136
        makefile)
 
137
                log_action_msg "Using makefile-style concurrent boot in runlevel $runlevel"
 
138
                # The splash API is not handled with this CONCURRENCY mode
 
139
                startup() {
 
140
                        eval "$(startpar -p 4 -t 20 -T 3 -M $1 -P $previous -R $runlevel)"
 
141
 
 
142
                        if [ -n "$failed_service" ]
 
143
                        then
 
144
                                log_failure_msg "startpar: service(s) returned failure: $failed_service"
 
145
                        fi
 
146
 
 
147
                        if [ -n "$skipped_service" ]
 
148
                        then
 
149
                                log_warning_msg "startpar: service(s) skipped: $skipped_service"
 
150
                        fi
 
151
 
 
152
                        unset failed_service skipped_service
 
153
                }
 
154
                ;;
 
155
        none|*)
 
156
                startup() {
 
157
                        action=$1
 
158
                        shift
 
159
                        scripts="$@"
 
160
                        for script in $scripts ; do
221
161
                                $debug "$script" $action
222
162
                                startup_progress
223
 
                                ;;
224
 
                        esac
225
 
                done
226
 
        }
227
 
        ;;
 
163
                        done
 
164
                }
 
165
                ;;
228
166
esac
229
167
 
230
168
# Check if the splash screen should be stopped before the given
231
169
# script.
232
170
is_splash_stop_scripts() {
233
 
    scriptname=$1
234
 
    case "$scriptname" in
235
 
        # killprocs is used in runlevel 1
236
 
        gdm|xdm|kdm|ltsp-client|ltsp-client-core|reboot|halt|killprocs)
237
 
            return 0
238
 
            ;;
239
 
    esac
240
 
    return 1
 
171
        scriptname=$1
 
172
        case "$scriptname" in
 
173
                # killprocs is used in runlevel 1
 
174
                gdm|xdm|kdm|ltsp-client|ltsp-client-core|reboot|halt|killprocs)
 
175
                        return 0
 
176
                        ;;
 
177
        esac
 
178
        return 1
241
179
}
242
180
 
243
181
# Is there an rc directory for this new runlevel?
246
184
        # Find out where in the progress bar the initramfs got to.
247
185
        PROGRESS_STATE=0
248
186
        if [ -f /dev/.initramfs/progress_state ]; then
249
 
            . /dev/.initramfs/progress_state
 
187
                . /dev/.initramfs/progress_state
250
188
        fi
251
189
 
252
190
        # Split the remaining portion of the progress bar into thirds
260
198
                        progress_size=100
261
199
                        step_change=-1
262
200
                        ;;
263
 
                S)
264
 
                        ACTION=start
 
201
                S)
 
202
                        ACTION=start
265
203
                        # Begin where the initramfs left off and use 2/3
266
204
                        # of the remaining space
267
205
                        first_step=$PROGRESS_STATE
281
219
        # (for progress bars)
282
220
        num_steps=0
283
221
        for s in /etc/rc$runlevel.d/[SK]*; do
284
 
            if is_splash_stop_scripts "${s##/etc/rc$runlevel.d/S??}" ; then
285
 
                break
286
 
            fi
287
 
            num_steps=$(($num_steps + 1))
 
222
                if is_splash_stop_scripts "${s##/etc/rc$runlevel.d/S??}" ; then
 
223
                        break
 
224
                fi
 
225
                num_steps=$(($num_steps + 1))
288
226
        done
289
227
        step=0
290
228
 
 
229
        if [ makefile = "$CONCURRENCY" ]
 
230
        then
 
231
                [ "$previous" != N ] && startup stop
291
232
        # First, run the KILL scripts.
292
 
        if [ "$previous" != N ]
 
233
        elif [ "$previous" != N ]
293
234
        then
294
235
                # Run all scripts with the same level in parallel
295
236
                CURLEVEL=""
326
267
                                # Stop the service.
327
268
                                SCRIPTS="$SCRIPTS $i"
328
269
                                if is_splash_stop_scripts "$suffix" ; then
329
 
                                    splash_stop || true
 
270
                                        $debug splash_stop || true
330
271
                                fi
331
272
                        done
332
273
                        startup stop $SCRIPTS
333
274
                done
334
275
        fi
335
276
 
336
 
        # Now run the START scripts for this runlevel.
337
 
        # Run all scripts with the same level in parallel
338
 
        CURLEVEL=""
339
 
        for s in /etc/rc$runlevel.d/S*
340
 
        do
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" ]
 
278
        then
 
279
                if [ S = "$runlevel" ]
345
280
                then
346
 
                        continue
 
281
                        startup boot
 
282
                else
 
283
                        startup $ACTION
347
284
                fi
348
 
                CURLEVEL=$level
349
 
                SCRIPTS=""
350
 
                for i in /etc/rc$runlevel.d/S$level*
 
285
        else
 
286
                # Now run the START scripts for this runlevel.
 
287
                # Run all scripts with the same level in parallel
 
288
                CURLEVEL=""
 
289
                for s in /etc/rc$runlevel.d/S*
351
290
                do
352
 
                        [ ! -f $i ] && continue
353
 
 
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" ]
356
295
                        then
357
 
                                #
358
 
                                # Find start script in previous runlevel and
359
 
                                # stop script in this runlevel.
360
 
                                #
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
363
 
                                #
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.
367
 
                                #
368
 
                                if [ start = "$ACTION" ] ; then
369
 
                                    [ -f $previous_start ] && [ ! -f $stop ] && continue
370
 
                                else
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
374
 
                                    #
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.
378
 
                                    #
379
 
                                    [ -f $previous_stop ] && [ ! -f $previous_start ] && continue
380
 
                                fi
381
 
 
382
 
                        fi
383
 
                        SCRIPTS="$SCRIPTS $i"
384
 
                        if is_splash_stop_scripts "$suffix" ; then
385
 
                            splash_stop || true
386
 
                        fi
 
296
                                continue
 
297
                        fi
 
298
                        CURLEVEL=$level
 
299
                        SCRIPTS=""
 
300
                        for i in /etc/rc$runlevel.d/S$level*
 
301
                        do
 
302
                                [ ! -f $i ] && continue
 
303
 
 
304
                                suffix=${i#/etc/rc$runlevel.d/S[0-9][0-9]}
 
305
                                if [ "$previous" != N ]
 
306
                                then
 
307
                                        #
 
308
                                        # Find start script in previous runlevel and
 
309
                                        # stop script in this runlevel.
 
310
                                        #
 
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
 
313
                                        #
 
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.
 
317
                                        #
 
318
                                        if [ start = "$ACTION" ] ; then
 
319
                                                [ -f $previous_start ] && [ ! -f $stop ] && continue
 
320
                                        else
 
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
 
324
                                                #
 
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.
 
328
                                                #
 
329
                                                [ -f $previous_stop ] && [ ! -f $previous_start ] && continue
 
330
                                        fi
 
331
 
 
332
                                fi
 
333
                                SCRIPTS="$SCRIPTS $i"
 
334
                                if is_splash_stop_scripts "$suffix" ; then
 
335
                                        $debug splash_stop || true
 
336
                                fi
 
337
                        done
 
338
                        startup $ACTION $SCRIPTS
387
339
                done
388
 
                startup $ACTION $SCRIPTS
389
 
        done
390
 
fi
391
 
 
392
 
if [ S = "$runlevel" ]
393
 
then
394
 
        #
395
 
        # For compatibility, run the files in /etc/rc.boot too.
396
 
        #
397
 
        [ -d /etc/rc.boot ] && run-parts /etc/rc.boot
 
340
        fi
398
341
fi
399
342
 
400
343
trap - EXIT # Disable emergency handler