~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, Petter Reinholdtsen, Kel Modderman
  • Date: 2009-07-27 21:12:27 UTC
  • Revision ID: james.westby@ubuntu.com-20090727211227-lxxqgakhpy83x5on
Tags: 2.87dsf-2
[ Petter Reinholdtsen ]
* Start generating MD5 sum files using dh_md5sum, build-depend
  on debhelper for this.  Use compat level 1 to get it to process
  debian/tmp/.
* Drop the stop calls for K11mountoverflowtmp in runlevels 0 and 6.
  The umountfs script will take care of that task (Closes: 526733).
* Remove setting of unused makefile variable LIBC6 from rules.
* Move copyright, preinst, postinst and postrm files for initscripts
  and sysv-rc to debian/ to make the build system closer to other
  source packages.
* Add the sysv-rc saveconfig script to /usr/share/doc/sysv-rc/
  to provide an example.
* Let sysv-rc depend on insserv (>= 1.12.0-10) to activate
  dependency based boot sequencing by default.

[ Kel Modderman ]
* Allow forcefsck on kernel cmdline to have same effect as touching
  /forcefsck in checkfs.sh and checkroot.sh. (Closes: #529498)
* Also allow fastboot on kernel cmdline to have same effect as touching
  /fastboot in checkfs.sh and checkroot.sh.
* Do not use brace expansion in debian/rules and remove need for
  setting SHELL to /bin/bash.

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
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
# In 2.87dsf-2 the "mountoverflowtmp" script was dropped
 
112
# from runlevels 0 and 6.
 
113
# We have to remove the old links _before_ we install new ones.
 
114
#
 
115
if dpkg --compare-versions "$PREV_VER" lt "2.87dsf-2" ; then
 
116
        update-rc.d -f mountoverflowtmp remove >/dev/null 2>&1 || :
 
117
fi
 
118
 
 
119
#
 
120
# Okay, we could do this with update-rc.d, but that would probably
 
121
# be pretty slow. This way we win some speed.
 
122
# DO NOT FOLLOW THIS EXAMPLE IN OTHER PACKAGES.
 
123
#
 
124
# Links in runlevel S
 
125
#
 
126
updatercd mountkernfs.sh         start 2 S .
 
127
updatercd hostname.sh            start 2 S .
 
128
updatercd mountdevsubfs.sh       start 4 S .
 
129
updatercd bootlogd               start 5 S .
 
130
updatercd checkroot.sh           start 10 S .
 
131
updatercd mtab.sh                start 12 S .
 
132
updatercd checkfs.sh             start 30 S .
 
133
updatercd mountall.sh            start 35 S .
 
134
updatercd mountall-bootclean.sh  start 36 S .
 
135
updatercd mountoverflowtmp       start 37 S .
 
136
updatercd mountnfs.sh            start 45 S .
 
137
updatercd mountnfs-bootclean.sh  start 46 S .
 
138
updatercd bootmisc.sh            start 55 S .
 
139
updatercd urandom                start 55 S . start 30 0 6 .
 
140
#
 
141
# Links in runlevels other than S
 
142
#
 
143
updatercd halt                   start 90 0 .
 
144
updatercd reboot                 start 90 6 .
 
145
updatercd umountroot             start 60 0 6 .
 
146
updatercd umountfs               start 40 0 6 .
 
147
updatercd umountnfs.sh           start 31 0 6 .
 
148
updatercd sendsigs               start 20 0 6 .
 
149
 
 
150
updatercd killprocs              start 30 1 .
 
151
updatercd single                 start 90 1 .
 
152
updatercd bootlogs               start 70 1 2 3 4 5 .
 
153
updatercd rc.local               start 99 2 3 4 5 .
 
154
updatercd rmnologin              start 99 2 3 4 5 .
 
155
updatercd stop-bootlogd-single   start 99 S .
 
156
updatercd stop-bootlogd          start 99 2 3 4 5 .
 
157
 
 
158
#
 
159
# Remove scripts that were left behind by older glibc (<< 2.3.2.ds1-12)
 
160
# versions. We have the same functionality in mount{kern,devsub}fs.sh 
 
161
#
 
162
#
 
163
# In 2.86.ds1-10 the "mountvirtfs" script was replaced by
 
164
# mountkernfs.sh and mountdevsubfs.sh.  It was removed completely in
 
165
# 2.86.ds1-16.
 
166
#
 
167
for F in mountkernfs devpts.sh mountvirtfs
 
168
do
 
169
        rm -f /etc/init.d/$F
 
170
        update-rc.d $F remove >/dev/null 2>&1 || :
 
171
done
 
172
 
 
173
#
 
174
# Create /var/run and /var/lock on the root partition to make sure
 
175
# they are available when RAMRUN or RAMLOCK is enabled.
 
176
# If mount fail (like in a vserver environment), just clean up and ignore
 
177
# it.  The admins enabling RAMRUN and RAMLOCK will have to create the
 
178
# directories themselves in this case.
 
179
#
 
180
if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-22" && ! chrooted
 
181
then
 
182
        # We need to quickly bind / to another location so we can make them
 
183
        # just in case /var is a mountpoint or a symlink to one.
 
184
        mkdir -p /.root
 
185
        if mount -n --bind / /.root ; then
 
186
                if [ -L /.root/var ] && [ ! -d /.root/var ] ; then
 
187
                        # No use trying if /var is a relative symlink.  It is not
 
188
                        # going to work.
 
189
                        :
 
190
                else
 
191
                        mkdir -p /.root/var/run /.root/var/lock
 
192
                fi
 
193
                umount /.root
 
194
        fi
 
195
        rmdir /.root
 
196
fi
 
197
 
 
198
#
 
199
# When installing for the first time or upgrading from version before 2.86.ds1-27,
 
200
# a reboot is needed to make the /lib/init/rw/ tmpfs available.  Flag this
 
201
# using notify-reboot-required.  Not mounting it here as it creates problem
 
202
# for debootstrap, vservers, pbuilder and cowbuilder.
 
203
#
 
204
if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-27" \
 
205
 && [ -x /usr/share/update-notifier/notify-reboot-required ]; then
 
206
        /usr/share/update-notifier/notify-reboot-required
 
207
fi
 
208
 
 
209
#
 
210
# Create initial log files
 
211
#
 
212
[ "$PREV_VER" ] || chmod 755 /var/log/fsck || :
 
213
for F in /var/log/dmesg /var/log/boot /var/log/fsck/checkroot /var/log/fsck/checkfs
 
214
do
 
215
        if [ ! -f "$F" ] && touch "$F" >/dev/null 2>&1
 
216
        then
 
217
                echo "(Nothing has been logged yet.)" >| "$F"
 
218
                chown root:adm "$F"
 
219
                chmod 640 "$F"
 
220
        fi
 
221
done
 
222
 
 
223
#
 
224
# Set up nologin symlink so that dynamic-login-disabling will work
 
225
# (when DELAYLOGIN is set to "yes")
 
226
#
 
227
if [ ! -L /etc/nologin ] && [ ! -e /etc/nologin ]
 
228
then
 
229
        rm -f /var/lib/initscripts/nologin
 
230
        ln -s /var/lib/initscripts/nologin /etc/nologin
 
231
fi
 
232
 
 
233
#
 
234
# Set up motd stuff, putting variable file in /var/run/
 
235
#
 
236
if [ ! -f /etc/motd.tail ]
 
237
then
 
238
        if [ -f /etc/motd ]
 
239
        then
 
240
                sed 1d /etc/motd > /etc/motd.tail
 
241
                [ -s /etc/motd.tail ] || rm -f /etc/motd.tail
 
242
        fi
 
243
fi
 
244
if [ ! -f /var/run/motd ]
 
245
then
 
246
        if [ -f /etc/motd ]
 
247
        then
 
248
                cat /etc/motd > /var/run/motd
 
249
        else
 
250
                :>/var/run/motd
 
251
        fi
 
252
fi
 
253
if [ ! -L /etc/motd ]
 
254
then
 
255
        [ -f /etc/default/rcS ] && . /etc/default/rcS
 
256
        if [ "$EDITMOTD" = no ]
 
257
        then
 
258
                cat /var/run/motd > /etc/motd.static
 
259
                ln -sf motd.static /etc/motd
 
260
        else
 
261
                ln -sf /var/run/motd /etc/motd
 
262
        fi
 
263
fi
 
264
 
 
265
#
 
266
# Mount kernel virtual filesystems...not.
 
267
# This causes problems in pbuilder.
 
268
#
 
269
#
 
270
#if [ -x /etc/init.d/mountkernfs.sh ]
 
271
#then
 
272
#       if which invoke-rc.d >/dev/null 2>&1
 
273
#       then
 
274
#               invoke-rc.d mountkernfs.sh start || :
 
275
#       else
 
276
#               /etc/init.d/mountkernfs.sh start
 
277
#       fi
 
278
#fi
 
279
 
 
280
#
 
281
# Create /dev/pts, /dev/shm directories
 
282
#
 
283
if [ "$(uname -s)" = Linux ]
 
284
then
 
285
        #
 
286
        # Only create /dev/{pts,shm} if /dev is on the
 
287
        # root file system. If some package has mounted a
 
288
        # seperate /dev (ramfs from udev, devfs) it is
 
289
        # responsible for the presence of those subdirs.
 
290
        # (it is OK for these to fail under fakechroot)
 
291
        #
 
292
        if ! mountpoint -q /dev
 
293
        then
 
294
                [ -d /dev/pts ] || { mkdir --mode=755 /dev/pts ; chown root:root /dev/pts || [ "$FAKECHROOT" = true ]; }
 
295
                [ -d /dev/shm ] || { mkdir --mode=755 /dev/shm ; chown root:root /dev/shm || [ "$FAKECHROOT" = true ]; }
 
296
        fi
 
297
fi
 
298
 
 
299
#
 
300
# Create /etc/rc.local on first time install and when upgrading from
 
301
# versions before "2.86.ds1-16"
 
302
#
 
303
if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-16"
 
304
then
 
305
        if [ ! -e /etc/rc.local ]; then
 
306
                cat << EOF > /etc/rc.local
 
307
#!/bin/sh -e
 
308
#
 
309
# rc.local
 
310
#
 
311
# This script is executed at the end of each multiuser runlevel.
 
312
# Make sure that the script will "exit 0" on success or any other
 
313
# value on error.
 
314
#
 
315
# In order to enable or disable this script just change the execution
 
316
# bits.
 
317
#
 
318
# By default this script does nothing.
 
319
 
 
320
exit 0
 
321
EOF
 
322
                # make sure it's enabled by default.
 
323
                chmod 755 /etc/rc.local
 
324
        fi
 
325
fi
 
326
 
 
327
: