~ubuntu-branches/debian/experimental/sysvinit/experimental

« back to all changes in this revision

Viewing changes to debian/initscripts/postinst

  • Committer: Bazaar Package Importer
  • Author(s): Petter Reinholdtsen
  • Date: 2008-08-12 16:07:50 UTC
  • Revision ID: james.westby@ubuntu.com-20080812160750-65gpyv74vh4qr69w
Tags: 2.86.ds1-61
* Fix typo in rcS(5), proberly->properly (Closes: #484233).  Thanks to
  Julien Danjou for noticing.
* Fix typo in rcS(5), maually->manually (Closes: #493680).  Thanks to
  Xr for noticing.
* Modify runlevel detection code in invoke-rc.d to notice the
  difference between runlevels 0 and 6, and the boot runlevel, to
  make it possible to use invoke-rc.d during boot (Closes: 384509).
* Make sure to call restorecon after mounting tmpfs file systems, to
  set SELinux permissions (Closes: #493679).  Patch from Russell
  Coker.
* Move responsibility of stopping the splash screen process from
  individual init.d scripts to init.d/rc.  This make sure the
  progress calculation reflect reality, and that the splash screen
  is taken down in runlevel 1 (Closes: #431560) and that it stop
  before gdm and kdm (Closes: #422922, #489734).
* Skip error message from checkfs.sh when / is read-only.  Patch
  from Mirek Slugen (Closes: #492214).

Show diffs side-by-side

added added

removed removed

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