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

« back to all changes in this revision

Viewing changes to debian/initscripts/postinst

  • 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:
1
 
#! /bin/sh
2
 
#
3
 
# initscripts postinst
4
 
#
5
 
 
6
 
set -e
7
 
 
8
 
case "$1" in
9
 
  configure)
10
 
        PREV_VER=$2
11
 
        ;;
12
 
  abort-upgrade|abort-remove|abort-deconfigure)
13
 
        exit 0
14
 
        ;;
15
 
esac
16
 
 
17
 
umask 022
18
 
 
19
 
#
20
 
# Function like update-rc.d but simpler & faster.
21
 
# Usage: updatercd basename start|stop NN runlevel .
22
 
#
23
 
# Heuristic: use the real update-rc.d if file-rc or insserv is
24
 
# detected, or if the /etc/rc2.d directory is not present.
25
 
#
26
 
updatercd() {
27
 
 
28
 
        [ -f /etc/init.d/$1 ] || return 0
29
 
 
30
 
        if \
31
 
                [ -d /usr/share/file-rc/. ] \
32
 
                || [ -d /usr/lib/file-rc/. ] \
33
 
                || [ -d /usr/share/insserv/. ] \
34
 
                || [ ! -d /etc/rc2.d/. ]
35
 
        then
36
 
                # Funniness on next line is because we are running with set -e
37
 
                update-rc.d "$@" >/dev/null && return 0 || return $?
38
 
        fi
39
 
 
40
 
        base=$1
41
 
        shift
42
 
 
43
 
        tmp="$(echo /etc/rc?.d/[SK]??$base)"
44
 
        case "$tmp" in
45
 
                "/etc/rc?.d/[SK]??$base") : ;;
46
 
                *) return ;;
47
 
        esac
48
 
 
49
 
        while [ "$1" != "" ]
50
 
        do
51
 
                if [ "$1" = stop ]
52
 
                then
53
 
                        tlet=K
54
 
                else
55
 
                        tlet=S
56
 
                fi
57
 
                case "$2" in
58
 
                        ?) lev=0$2 ;;
59
 
                        *) lev=$2 ;;
60
 
                esac
61
 
                shift 2
62
 
                while [ "$1" != "." ]
63
 
                do
64
 
                        cd /etc/rc$1.d
65
 
                        ln -sf ../init.d/$base $tlet$lev$base
66
 
                        shift
67
 
                done
68
 
                shift
69
 
        done
70
 
}
71
 
 
72
 
chrooted() {
73
 
  if [ -r /proc/1/root ]; then
74
 
    return 1
75
 
  fi
76
 
  return 0
77
 
}
78
 
 
79
 
#
80
 
# Initialize rcS default file.
81
 
#
82
 
if [ ! -f /etc/default/rcS ]
83
 
then
84
 
        cp -p /usr/share/initscripts/default.rcS /etc/default/rcS
85
 
else
86
 
    # in Ubuntu we use /var/run and /var/lock tmpfses; transition it to the new
87
 
    # settings in /etc/default/rcS
88
 
    if dpkg --compare-versions "$PREV_VER" le-nl "2.86.ds1-56ubuntu1"
89
 
    then
90
 
            grep -wq RAMRUN /etc/default/rcS || echo 'RAMRUN=yes' >> /etc/default/rcS
91
 
            grep -wq RAMLOCK /etc/default/rcS || echo 'RAMLOCK=yes' >> /etc/default/rcS
92
 
    fi
93
 
fi
94
 
 
95
 
#
96
 
# In 2.86.ds1-7 the "single" script was moved.
97
 
# We have to remove the old links _before_ we install new ones.
98
 
#
99
 
if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-7"
100
 
then
101
 
        update-rc.d -f single remove >/dev/null 2>&1 || :
102
 
fi
103
 
 
104
 
# In 2.86.ds1-16, the mtab.sh and hostname.sh scripts were moved.
105
 
if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-16"
106
 
then
107
 
        update-rc.d -f mtab.sh remove >/dev/null 2>&1 || :
108
 
        update-rc.d -f hostname.sh remove >/dev/null 2>&1 || :
109
 
fi
110
 
 
111
 
# In 2.86.ds1-21, the sendsigs script were moved, and in 2.86.ds1-35
112
 
# it was moved back.
113
 
if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-35"
114
 
then
115
 
        update-rc.d -f sendsigs remove >/dev/null 2>&1 || :
116
 
fi
117
 
 
118
 
# In 2.86.ds1-56ubuntu1, the waitnfs.sh was renamed to mountnfs.sh to be in
119
 
# sync with Debian again.
120
 
if dpkg --compare-versions "$PREV_VER" le-nl "2.86.ds1-56ubuntu1"
121
 
then
122
 
        update-rc.d -f waitnfs.sh remove >/dev/null 2>&1 || :
123
 
fi
124
 
 
125
 
#
126
 
# Okay, we could do this with update-rc.d, but that would probably
127
 
# be pretty slow. This way we win some speed.
128
 
# DO NOT FOLLOW THIS EXAMPLE IN OTHER PACKAGES.
129
 
#
130
 
# Links in runlevel S
131
 
#
132
 
updatercd mountkernfs.sh         start 1 S .
133
 
updatercd hostname.sh            start 2 S .
134
 
updatercd mountdevsubfs.sh       start 11 S .
135
 
#updatercd bootlogd               start 5 S .
136
 
updatercd checkroot.sh           start 20 S .
137
 
updatercd mtab.sh                start 22 S .
138
 
updatercd checkfs.sh             start 30 S .
139
 
updatercd mountall.sh            start 35 S .
140
 
updatercd mountall-bootclean.sh  start 36 S .
141
 
updatercd mountoverflowtmp       start 37 S . stop 63 0 6 .
142
 
updatercd mountnfs.sh            start 45 S .
143
 
updatercd mountnfs-bootclean.sh  start 46 S .
144
 
updatercd bootmisc.sh            start 55 S .
145
 
updatercd urandom                start 55 S . start 30 0 6 .
146
 
#
147
 
# Links in runlevels other than S
148
 
#
149
 
updatercd halt                   start 90 0 .
150
 
updatercd reboot                 start 90 6 .
151
 
updatercd umountroot             start 60 0 6 .
152
 
updatercd umountfs               start 40 0 6 .
153
 
updatercd umountnfs.sh           start 31 0 6 .
154
 
updatercd sendsigs               start 20 0 6 .
155
 
 
156
 
updatercd killprocs              start 30 1 .
157
 
updatercd single                 start 90 1 .
158
 
updatercd bootlogs.sh            start 70 1 2 3 4 5 .
159
 
updatercd ondemand               start 99 2 3 4 5 .
160
 
updatercd rc.local               start 99 2 3 4 5 .
161
 
updatercd rmnologin              start 99 2 3 4 5 .
162
 
#updatercd stop-bootlogd-single   start 99 S .
163
 
#updatercd stop-bootlogd          start 99 2 3 4 5 .
164
 
 
165
 
#
166
 
# Remove scripts that were left behind by older glibc (<< 2.3.2.ds1-12)
167
 
# versions. We have the same functionality in mount{kern,devsub}fs.sh 
168
 
#
169
 
#
170
 
# In 2.86.ds1-10 the "mountvirtfs" script was replaced by
171
 
# mountkernfs.sh and mountdevsubfs.sh.  It was removed completely in
172
 
# 2.86.ds1-16.
173
 
#
174
 
for F in mountkernfs devpts.sh mountvirtfs
175
 
do
176
 
        rm -f /etc/init.d/$F
177
 
        update-rc.d $F remove >/dev/null 2>&1 || :
178
 
done
179
 
 
180
 
#
181
 
# Create /var/run and /var/lock on the root partition to make sure
182
 
# they are available when RAMRUN or RAMLOCK is enabled.
183
 
# If mount fail (like in a vserver environment), just clean up and ignore
184
 
# it.  The admins enabling RAMRUN and RAMLOCK will have to create the
185
 
# directories themselves in this case.
186
 
#
187
 
if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-22" && ! chrooted
188
 
then
189
 
        # We need to quickly bind / to another location so we can make them
190
 
        # just in case /var is a mountpoint or a symlink to one.
191
 
        mkdir -p /.root
192
 
        if mount -n --bind / /.root ; then
193
 
                if [ -L /.root/var ] && [ ! -d /.root/var ] ; then
194
 
                        # No use trying if /var is a relative symlink.  It is not
195
 
                        # going to work.
196
 
                        :
197
 
                else
198
 
                        mkdir -p /.root/var/run /.root/var/lock
199
 
                fi
200
 
                umount /.root
201
 
        fi
202
 
        rmdir /.root
203
 
fi
204
 
 
205
 
#
206
 
# When installing for the first time or upgrading from version before 2.86.ds1-27,
207
 
# a reboot is needed to make the /lib/init/rw/ tmpfs available.  Flag this
208
 
# using notify-reboot-required.  Not mounting it here as it creates problem
209
 
# for debootstrap, vservers, pbuilder and cowbuilder.
210
 
#
211
 
if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-27" \
212
 
 && [ -x /usr/share/update-notifier/notify-reboot-required ]; then
213
 
        /usr/share/update-notifier/notify-reboot-required
214
 
fi
215
 
 
216
 
#
217
 
# Create mount point for spufs, and create spu system group
218
 
#
219
 
if mountpoint -q /proc && grep -qs '^cpu.*Cell' /proc/cpuinfo; then
220
 
        if ! getent group spu >/dev/null; then
221
 
                # the adduser package is priority important; cannot use addgroup
222
 
                groupadd -K GID_MAX=1000 spu
223
 
        fi
224
 
        mkdir -p /spu
225
 
        if ! mountpoint -q /spu; then
226
 
                # No need to fail configuration if this isn't possible. Mount
227
 
                # will still display an error. See LP #261490 and #251593.
228
 
                mount -t spufs -ogid=spu spufs /spu || true
229
 
        fi
230
 
fi
231
 
 
232
 
#
233
 
# Create initial log files
234
 
#
235
 
[ "$PREV_VER" ] || chmod 755 /var/log/fsck || :
236
 
for F in /var/log/dmesg /var/log/boot /var/log/fsck/checkroot /var/log/fsck/checkfs
237
 
do
238
 
        if [ ! -f "$F" ] && touch "$F" >/dev/null 2>&1
239
 
        then
240
 
                echo "(Nothing has been logged yet.)" >| "$F"
241
 
                chown root:adm "$F"
242
 
                chmod 640 "$F"
243
 
        fi
244
 
done
245
 
 
246
 
#
247
 
# Set up nologin symlink so that dynamic-login-disabling will work
248
 
# (when DELAYLOGIN is set to "yes")
249
 
#
250
 
if [ ! -L /etc/nologin ] && [ ! -e /etc/nologin ]
251
 
then
252
 
        rm -f /var/lib/initscripts/nologin
253
 
        ln -s /var/lib/initscripts/nologin /etc/nologin
254
 
fi
255
 
 
256
 
#
257
 
# Set up motd stuff, putting variable file in /var/run/
258
 
#
259
 
if [ ! -f /etc/motd.tail ]
260
 
then
261
 
        if [ -f /etc/motd ]
262
 
        then
263
 
                sed 1d /etc/motd > /etc/motd.tail
264
 
                [ -s /etc/motd.tail ] || rm -f /etc/motd.tail
265
 
        fi
266
 
fi
267
 
if [ ! -f /var/run/motd ]
268
 
then
269
 
        if [ -f /etc/motd ]
270
 
        then
271
 
                cat /etc/motd > /var/run/motd
272
 
        else
273
 
                :>/var/run/motd
274
 
        fi
275
 
fi
276
 
if [ ! -L /etc/motd ]
277
 
then
278
 
        [ -f /etc/default/rcS ] && . /etc/default/rcS
279
 
        if [ "$EDITMOTD" = no ]
280
 
        then
281
 
                cat /var/run/motd > /etc/motd.static
282
 
                ln -sf motd.static /etc/motd
283
 
        else
284
 
                ln -sf /var/run/motd /etc/motd
285
 
        fi
286
 
fi
287
 
 
288
 
#
289
 
# Mount kernel virtual filesystems...not.
290
 
# This causes problems in pbuilder.
291
 
#
292
 
#
293
 
#if [ -x /etc/init.d/mountkernfs.sh ]
294
 
#then
295
 
#       if which invoke-rc.d >/dev/null 2>&1
296
 
#       then
297
 
#               invoke-rc.d mountkernfs.sh start || :
298
 
#       else
299
 
#               /etc/init.d/mountkernfs.sh start
300
 
#       fi
301
 
#fi
302
 
 
303
 
#
304
 
# Create /dev/pts, /dev/shm directories
305
 
#
306
 
if [ "$(uname -s)" = Linux ]
307
 
then
308
 
        #
309
 
        # Only create /dev/{pts,shm} if /dev is on the
310
 
        # root file system. If some package has mounted a
311
 
        # seperate /dev (ramfs from udev, devfs) it is
312
 
        # responsible for the presence of those subdirs.
313
 
        #
314
 
        if ! mountpoint -q /dev
315
 
        then
316
 
                [ -d /dev/pts ] || { mkdir --mode=755 /dev/pts ; chown root:root /dev/pts ; }
317
 
                [ -d /dev/shm ] || { mkdir --mode=755 /dev/shm ; chown root:root /dev/shm ; }
318
 
        fi
319
 
fi
320
 
 
321
 
#
322
 
# Create /etc/rc.local on first time install and when upgrading from
323
 
# versions before "2.86.ds1-16"
324
 
#
325
 
if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-16"
326
 
then
327
 
        if [ ! -e /etc/rc.local ]; then
328
 
                cat << EOF > /etc/rc.local
329
 
#!/bin/sh -e
330
 
#
331
 
# rc.local
332
 
#
333
 
# This script is executed at the end of each multiuser runlevel.
334
 
# Make sure that the script will "exit 0" on success or any other
335
 
# value on error.
336
 
#
337
 
# In order to enable or disable this script just change the execution
338
 
# bits.
339
 
#
340
 
# By default this script does nothing.
341
 
 
342
 
exit 0
343
 
EOF
344
 
                # make sure it's enabled by default.
345
 
                chmod 755 /etc/rc.local
346
 
        fi
347
 
fi
348
 
 
349
 
: