File: postinst

package info (click to toggle)
sysvinit 2.84-2woody1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 652 kB
  • ctags: 463
  • sloc: ansic: 5,282; sh: 1,193; perl: 158; makefile: 156
file content (270 lines) | stat: -rw-r--r-- 5,570 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
#! /bin/sh
#
# debian.postinst
#		Creates /dev/initctl if not already there.
#		Also checks /etc/inittab for single user entry.
#
# Version:	debian.postinst  2.83-2  01-Oct-2001  miquels@cistron.nl
#


case "$1" in
	configure)
		oldver=$2
		;;
	abort-upgrade|abort-remove|abort-deconfigure)
		exit 0
		;;
esac
umask 022

# Compatibility symlinks into /usr/doc
if [ -d /usr/doc -a ! -e /usr/doc/sysvinit \
	-a -d /usr/share/doc/sysvinit ]
then
	ln -sf ../share/doc/sysvinit /usr/doc/sysvinit
fi

#
#	Check /dev/initctl
#
if [ ! -p /dev/initctl ]
then
	echo "sysvinit: creating /dev/initctl"
	rm -f /dev/initctl
	mknod -m 600 /dev/initctl p
fi

#
#	Restore network and inittab files.
#	Should be taken out for woody, I guess as this is for
#	backwards compat with Debian 1.1 (see preinst as well)
#
if [ ! -f /etc/init.d/network ]
then
	if [ -f /etc/init.d/network.saved ]
	then
		cp -a /etc/init.d/network.saved /etc/init.d/network
	fi
fi
rm -f /etc/init.d/network.saved
if [ ! -f /etc/inittab ]
then
	if [ -f /etc/inittab.saved ]
	then
		cp -a /etc/inittab.saved /etc/inittab
	else
		# Prefer arch-specific inittab.
		arch=`dpkg --print-installation-architecture`
		expl=/usr/share/doc/sysvinit/examples
		if [ -f $expl/inittab.$arch ]; then
			inittab=$expl/inittab.$arch
		else
			inittab=$expl/inittab
		fi
		cp -a $inittab /etc/inittab
	fi
fi
rm -f /etc/inittab.saved
if [ ! -f /etc/default/rcS ]
then
	#
	#	Install sample rcS file.
	#
	cp /usr/share/doc/sysvinit/examples/default.rcS /etc/default/rcS
else
	#
	#	Change GMT=-u to UTC=yes etc in existing rcS file.
	#
	if grep -q ^GMT /etc/default/rcS
	then
		cp /etc/default/rcS /etc/default/rcS.TMP
		sed	-e "s/^GMT=.*\(-u\|--utc\).*/UTC=yes/" \
			-e "s/^GMT=.*/UTC=no/" \
			-e 's/# Set GMT="-u".*/# Set UTC to yes or no/' \
			< /etc/default/rcS.TMP > /etc/default/rcS
		if [ -s /etc/default/rcS ]
		then
			rm -f /etc/default/rcS.TMP
		fi
	fi
fi

#
#	See if there were saved variables.
#
if [ -f /etc/default/rcS.sed ]
then
	cp /etc/default/rcS /etc/default/rcS.TMP
	sed -f /etc/default/rcS.sed < /etc/default/rcS.TMP > /etc/default/rcS
	if [ -s /etc/default/rcS ]
	then
		rm -f /etc/default/rcS.TMP
	fi
	rm -f /etc/default/rcS.sed
fi

#
#	Check single user entry in /etc/inittab
#
if ! grep -q '^[^:]\{1,4\}:S:' /etc/inittab
then
	cat <<EOF

WARNING: you don't have a single user entry in /etc/inittab. Consider
         adding an entry like this after installation:

         ~~:S:wait:/sbin/sulogin

EOF
	echo -n "Hit Enter key to continue...."
	read junk
fi

#
#	Fix up /etc/inittab for the new rcS
#
if grep -q '/etc/init.d/boot$' /etc/inittab
then
	sed -e 's!^.*\(sysinit\|boot\|bootwait\):/etc/init.d/boot.*$!si::sysinit:/etc/init.d/rcS!' < /etc/inittab > /etc/inittab.tmp
	if [ ! -s /etc/inittab.tmp ]
	then
		echo "$0: installation severely fubared !! HELP" >&2
		exit 1
	fi
	mv /etc/inittab.tmp /etc/inittab
fi

#
#	Fix the call to shutdown in /etc/inittab (add -a).
#
if grep -q 'ca:12345:ctrlaltdel:/sbin/shutdown -t1 -r now$' /etc/inittab
then
	sed -e 's!ca:12345:ctrlaltdel:/sbin/shutdown -t1 -r now$!ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now!' < /etc/inittab > /etc/inittab.tmp
	if [ ! -s /etc/inittab.tmp ]
	then
		echo "$0: installation severely fubared !! HELP" >&2
		exit 1
	fi
	mv /etc/inittab.tmp /etc/inittab
fi

#
# Bugs 2.72 -> 2.73
# 1. mv settime.sh hwclock.sh
# 2. mv mdinit.sh mdutils.sh
#
rm -f /etc/init.d/settime.sh /etc/rcS.d/S??settime.sh
rm -f /etc/init.d/mdinit.sh /etc/rcS.d/S??mdinit.sh
#
#	Remove the old S20halt and S20 reboot links.
#
rm -f /etc/rc0.d/S20halt   /etc/rc0.d/S05halt
rm -f /etc/rc6.d/S20reboot /etc/rc6.d/S05reboot

#
#	Function like update-rc.d but simpler & faster.
#	Usage: updatercd basename start|stop NN runlevel .
#
#	Uses the real update-rc.d if file-rc is detected.
#
updatercd() {

	if [ ! -f /etc/init.d/$1 ]
	then
		return
	fi

	if [ -d /usr/lib/file-rc/. ]
	then
		update-rc.d "$@" > /dev/null
		return $?
	fi

	base=$1
	shift
	while [ "$1" != "" ]
	do
		if [ "$1" = stop ]
		then
			tlet=K
		else
			tlet=S
		fi
		lev=$2
		shift 2
		while [ "$1" != "." ]
		do
			cd /etc/rc$1.d
			tmp="`echo $tlet??$base`"
			case "$tmp" in
				"$tlet??$base")
					# Not present yet.
					ln -s ../init.d/$base $tlet$lev$base
					;;
				*)
					# Already present.
					;;
			esac
			shift
		done
		shift
	done
}

#
#	Okay, we could do this with update-rc.d, but that would probably
#	be pretty slow. This way we win some speed.
#	DO NOT FOLLOW THIS EXAMPLE IN OTHER PACKAGES.
#
#updatercd bootlogd	start 5 S .
updatercd checkroot.sh	start 10 S .
updatercd modutils	start 20 S .
updatercd checkfs.sh	start 30 S .
updatercd mountall.sh	start 35 S .
updatercd hostname.sh	start 40 S .
updatercd network	start 40 S .
updatercd mountnfs.sh	start 45 S .
updatercd bootmisc.sh	start 55 S .
updatercd urandom	start 55 S . start 30 0 6 .

#
#	Links in "normal" runlevels.
#
updatercd sendsigs	start 20 0 6 .
updatercd umountnfs.sh	start 31 0 6 .
updatercd umountfs	start 40 0 6 .
updatercd halt		start 90 0 .
updatercd reboot	start 90 6 .
updatercd rmnologin	start 99 2 3 4 5 .
updatercd single        start 20 1 .
#updatercd stop-bootlogd	start 99 2 3 4 5 .

#
#	Upgrade init if possible. There was a bug in all versions
#	up to and including 2.75-4, which didn't affect i386 but
#	did affect most other architectures.
#
case "`uname -m`" in
	i?86)
		badver="2.[0-6]*|2.7[0-3]*"
		;;
	*)
		badver="2.[0-6]*|2.7[0-4]*|2.75-*"
		;;
esac
eval "case \"$oldver\" in
	$badver)
		;;
	*)
		init u
		sleep 1
esac"

#
#	Tell init to re-read inittab.
#
init q

exit 0