]> git.pld-linux.org Git - projects/rc-scripts.git/blame - rc.d/rc.sysinit
- use shell construct
[projects/rc-scripts.git] / rc.d / rc.sysinit
CommitLineData
12de71be 1#!/bin/sh
7742e157
AF
2#
3# /etc/rc.d/rc.sysinit - run once at boot time
ec8b15cb 4# $Id$
7742e157
AF
5#
6# Taken in part from Miquel van Smoorenburg's bcheckrc.
7#
8
b6509675
AM
9# reasonable start values for bootsplash progress.
10export progress=0
11export sscripts=45
12export kscripts=45
13
38198f50 14# NLS
de1fc6ce 15if [ -r /etc/sysconfig/i18n ]; then
38198f50
AM
16 . /etc/sysconfig/i18n
17 [ -n "$LANG" ] && export LANG || unset LANG
18 [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
19 [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE
20 [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES
21 [ -n "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC
22 [ -n "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY
23 [ -n "$LC_TIME" ] && export LC_TIME || unset LC_TIME
24 [ -n "$LC_ALL" ] && export LC_ALL || unset LC_ALL
25 [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE
26 [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS
27fi
28
418c0cf3 29# Read network config data
de1fc6ce 30if [ -r /etc/sysconfig/network ]; then
1b228409 31 . /etc/sysconfig/network
7742e157 32else
1b228409 33 NETWORKING=no
34 HOSTNAME=localhost
7742e157
AF
35fi
36
277e5f53 37CONSOLE_LOGLEVEL=1
45e88cd0 38
e298d489
JR
39# Read functions
40. /etc/rc.d/init.d/functions
41
483f1dda 42disable_selinux() {
944d6d80 43 local _d selinuxfs _t _r
483f1dda
ER
44
45 while read _d selinuxfs _t _r; do
46 [ "$_t" = "selinuxfs" ] && break
47 done </proc/mounts
48 echo "*** Warning -- SELinux is active"
49 echo "*** Disabling security enforcement for system recovery."
50 echo "*** Run 'setenforce 1' to reenable."
51 echo "0" > $selinuxfs/enforce
52}
53
54relabel_selinux() {
944d6d80 55 local _d selinuxfs _t _r
483f1dda
ER
56
57 while read _d selinuxfs _t _r; do
58 [ "$_t" = "selinuxfs" ] && break
59 done </proc/mounts
60 echo "
61 *** Warning -- SELinux relabel is required. ***
62 *** Disabling security enforcement. ***
63 *** Relabeling could take a very long time, ***
64 *** depending on file system size. ***
65 "
66 echo "0" > $selinuxfs/enforce
67 /sbin/fixfiles -F relabel > /dev/null 2>&1
68 rm -f /.autorelabel
69 echo "*** Enabling security enforcement. ***"
70 echo $SELINUX > $selinuxfs/enforce
71}
72
73# Remove duplicate entries from mtab (for vserver guest use only)
74clean_vserver_mtab() {
75 :>/etc/mtab.clean
76 while read device mountpoint line; do
77 grep -qs "$mountpoint" /etc/mtab.clean || \
78 echo "$device $mountpoint $line" >> /etc/mtab.clean
79 done < /etc/mtab
80 cat /etc/mtab.clean > /etc/mtab
81 rm -f /etc/mtab.clean
82}
83
3aabb390
ER
84# Loads modules from /etc/modules, /etc/modules.X.Y and /etc/modules.X.Y.Z
85load_kernel_modules() {
86 {
87 local _x _y v _z
88 read _x _y v _z
89 old_IFS=$IFS
90 IFS='.'
91 set -- $v
92 IFS=$old_IFS
93 kernel="$1.$2"
94 kerneleq="$1.$2.$3"
95 } < /proc/version
96
97 local module
98 # Loop over every line in modules file
99 ( \
a51d5138 100 grep -hvE '^(#|[[:blank:]]*$)' /etc/modules /etc/modules.$kernel /etc/modules.$kerneleq 2>/dev/null
3aabb390
ER
101 echo '' # make sure there is a LF at the end
102 ) | while read module args; do
103 [ -z "$module" ] && continue
55bf7b40
ER
104 # strip comments
105 args=${args%%#*}
3aabb390
ER
106 modprobe -s $module -- $args
107 done
108}
483f1dda 109
48e500cd
ER
110# boot logging to /var/log/boot.msg. install showconsole package to get it.
111if [ -x /sbin/blogd ] && ! is_no "$RC_BOOTLOG"; then
112 RC_BOOTLOG=1
113else
114 RC_BOOTLOG=
115fi
116
5163449d 117if ! is_yes "$VSERVER" ; then
a1ad6ea5 118 # we need /proc mounted before everything
90f9c9ad 119 is_fsmounted proc /proc || mount -n -o gid=17 -t proc /proc /proc
a1ad6ea5 120
b0290bbb
ER
121 # Only read this once.
122 cmdline=$(cat /proc/cmdline)
123
5163449d
JR
124 # sysfs is also needed before any other things (under kernel > 2.5)
125 if grep -q sysfs /proc/filesystems 2>/dev/null ; then
90f9c9ad 126 is_fsmounted sysfs /sys || mount -n -o gid=17 -t sysfs sysfs /sys
5163449d
JR
127 if [ "$(kernelver)" -ge "002006014" ] && \
128 grep -q securityfs /proc/filesystems 2>/dev/null ; then
129 mount -n -o gid=17 -t securityfs securityfs /sys/kernel/security
130 fi
defac991 131 fi
e298d489 132
5163449d 133 # selinux
3f9e71a5 134 if grep -q selinuxfs /proc/filesystems 2>/dev/null && ! is_fsmounted selinuxfs /selinux; then
5163449d
JR
135 mount -n -o gid=17 -t selinuxfs selinuxfs /selinux
136 fi
e298d489 137
ffe19b59 138 # PLD Linux LiveCD support
01b60fd3
JR
139 if [ -x /etc/rc.d/rc.live ]; then
140 /etc/rc.d/rc.live
141 fi
e298d489 142
01b60fd3
JR
143 # Choose Hardware profile
144 if [ -f /etc/sysconfig/hwprof ]; then
145 . /etc/sysconfig/hwprof
146 if is_yes "${HWPROFILES}" && [ -x /sbin/hwprofile -a -d /etc/sysconfig/hwprofiles/data ]; then
147 mount -n / -o rw,remount
148 /sbin/hwprofile -qf
149 mount -n / -o ro,remount
150 fi
5e6dfc29 151 fi
e298d489 152
01b60fd3
JR
153 # Disable splash when requested
154 [ -e /proc/splash ] && is_no "$BOOT_SPLASH" && echo "0" > /proc/splash
5b0f5a94 155
c5e74817
ER
156 # Check SELinux status
157 selinuxfs=$(awk '/ selinuxfs / { print $2 }' /proc/mounts 2> /dev/null)
158 SELINUX=
159 if [ -n "$selinuxfs" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then
160 if [ -r $selinuxfs/enforce ] ; then
161 SELINUX=$(cat $selinuxfs/enforce)
162 else
163 # assume enforcing if you can't read it
164 SELINUX=1
165 fi
5e6dfc29 166 fi
677fdd75 167
3f9e71a5 168 if [ -x /sbin/restorecon ] && is_fsmounted tmpfs /dev; then
c5e74817
ER
169 /sbin/restorecon -R /dev 2>/dev/null
170 fi
677fdd75 171
7e16b45e
ER
172 [ -z "${CONSOLETYPE}" ] && CONSOLETYPE="$(/sbin/consoletype)"
173
c5e74817
ER
174 if [ "$CONSOLETYPE" = "vt" -a -x /sbin/setsysfont ]; then
175 /sbin/setsysfont
176 fi
12c4fb70 177fi
5b0f5a94 178
652dbae5 179
458f14b7 180# Print welcome message
503bfc80 181nls "\t\t\t%sPowered by %sPLD Linux Distribution%s" "$(termput setaf $CPOWEREDBY)" "$(termput setaf $CPLD)" "$(termput op)"
8a917f32 182if ! is_no "$RC_PROMPT"; then
503bfc80 183 nls -n "\t\t Press %sI%s to enter interactive startup" "$(termput setaf $CI)" "$(termput op)"
6b4a354c 184 echo
6b4a354c 185fi
201c98b9 186
cc10e704 187# Set the hostname
499b251c
JR
188if [ -z "${HOSTNAME}" ]; then
189 show "$(nls 'Host:') $(hostname)" ; ok
190else
191 run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME}
192fi
6956336c 193
cc10e704
JR
194# Set the NIS domain name
195if [ -n "$NISDOMAIN" ]; then
196 run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN
197else
198 domainname ""
4289a4ff
AM
199fi
200
cc10e704
JR
201if ! is_yes "$VSERVER"; then
202 # Set console loglevel
203 if [ -n "$CONSOLE_LOGLEVEL" ]; then
204 /bin/dmesg -n $CONSOLE_LOGLEVEL
205 fi
6bf50269 206
348aacfc 207 if ! is_no "$START_UDEV"; then
f71c07f8 208 if [ -x /sbin/start_udev ]; then
209 /sbin/start_udev
210 elif [ -x /lib/firmware/firmware-loader.sh ]; then
211 /sbin/sysctl -e -w kernel.hotplug=/lib/firmware/firmware-loader.sh
212 fi
348aacfc 213 fi
5e6dfc29 214
6a8f0f05 215 # Unmount the initrd, if necessary
426e1497 216 if grep -q /initrd /proc/mounts 2>/dev/null && ! grep -q /initrd/loopfs /proc/mounts 2>/dev/null; then
426e1497 217 umount /initrd/dev 2>/dev/null
6a8f0f05
ER
218 umount /initrd
219 /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1
220 fi
221
33c6207a
ER
222 # Start logging console output since we have all /dev stuff setup
223 if [ "$RC_BOOTLOG" ]; then
0868c9a6 224 /sbin/blogd
33c6207a
ER
225 fi
226
cc10e704 227 # cpuset support (mounted unconditionally, shouldn't be a problem)
5bae5434 228 if grep -q cgroup /proc/filesystems 2>/dev/null ; then
3f9e71a5 229 mount -n -t cgroup none /dev/cpuset -o cpuset,noprefix
5bae5434
JR
230 [ $? -eq 0 ] && echo "/sbin/cpuset_release_agent" > /dev/cpuset/release_agent
231 elif grep -q cpuset /proc/filesystems 2>/dev/null ; then
5e6dfc29 232 mount -n -t cpuset none /dev/cpuset
cc10e704 233 fi
201c98b9 234
cc10e704
JR
235 # Configure Linux kernel (initial configuration, some required modules still
236 # may be missing).
237 /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
201c98b9 238
cc10e704
JR
239 # Set the system clock.
240 ARC=0
241 SRM=0
242 UTC=0
201c98b9 243
cc10e704
JR
244 if [ -f /etc/sysconfig/clock ]; then
245 . /etc/sysconfig/clock
201c98b9 246
cc10e704
JR
247 # convert old style clock config to new values
248 if [ "${CLOCKMODE}" = "GMT" ]; then
249 UTC=true
250 elif [ "${CLOCKMODE}" = "ARC" ]; then
251 ARC=true
252 fi
253 fi
201c98b9 254
cc10e704
JR
255 if grep "system serial" /proc/cpuinfo 2>/dev/null | grep -q MILO 2>/dev/null ; then
256 ARC=true
257 fi
cb4d1aa7 258
cc10e704
JR
259 CLOCKDEF=""
260 CLOCKFLAGS="--hctosys"
cb4d1aa7 261
cc10e704
JR
262 if is_yes "$UTC" ; then
263 CLOCKFLAGS="$CLOCKFLAGS --utc"
264 CLOCKDEF="$CLOCKDEF (utc)"
265 else
266 CLOCKFLAGS="$CLOCKFLAGS --localtime"
267 CLOCKDEF="$CLOCKDEF (local)"
268 fi
201c98b9 269
cc10e704
JR
270 if is_yes "$ARC" ; then
271 CLOCKFLAGS="$CLOCKFLAGS -A"
272 CLOCKDEF="$CLOCKDEF (arc)"
0bbfed6f 273 fi
e4b0481f 274
cc10e704
JR
275 if is_yes "$SRM" ; then
276 CLOCKFLAGS="$CLOCKFLAGS -S"
277 CLOCKDEF="$CLOCKDEF (srm)"
278 fi
7742e157 279
cc10e704 280 # Check if timezone definition is available
5ad31754 281 if [ -e /etc/localtime ] ; then
cc10e704
JR
282 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
283 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
284 fi
285 else
286 TIME_SETUP_DELAYED=yes
287 fi
7742e157 288
6b496866 289 if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then
dd23d50d
ER
290 # XXX might need modules dep
291 # Device mapper & related initialization
a51d5138 292 if ! grep -qF device-mapper /proc/devices; then
dd23d50d
ER
293 modprobe dm-mod
294 fi
295
296 # but should do this before swapon?
297 . /etc/rc.d/init.d/cryptsetup
8710c4b5 298 show "Starting disk encryption"
dd23d50d
ER
299 init_crypto 0 && ok || fail
300 fi
301
cc10e704
JR
302 # Start up swapping
303 run_cmd "Activating swap partitions" swapon -a -e
304
305 # Initialize USB controllers
306 usb=0
3f9e71a5 307 if ! strstr "$cmdline" "nousb" && ! is_fsmounted usbfs /proc/bus/usb ; then
86711d93 308 aliases=$(/sbin/modprobe -c | awk '/^alias[\t ]+usb-controller/ { print $3 }')
cc10e704 309 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
170103c8 310 /sbin/modprobe -s usbcore
cc10e704
JR
311 for alias in $aliases ; do
312 [ "$alias" = "off" ] && continue
a6a4a758 313 run_cmd "$(nls 'Initializing USB controller') ($alias)" /sbin/modprobe -s $alias
cc10e704
JR
314 done
315 [ $? -eq 0 -a -n "$aliases" ] && usb=1
316 fi
317 if grep -iq "usb" /proc/devices 2>/dev/null ; then
318 usb=1
319 fi
320 fi
7742e157 321
ff474752 322 if [ "$usb" = "1" ] && ! is_fsmounted usbfs /proc/bus/usb ; then
a40bbbec 323 run_cmd "Mounting USB filesystem" mount -n -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb
b3965b3d 324 fi
b3965b3d 325
cc10e704
JR
326 needusbstorage=
327 if [ "$usb" = "1" ]; then
328 needusbstorage=$(LC_ALL=C cat /proc/bus/usb/devices 2>/dev/null|grep -e "^I.*Cls=08" 2>/dev/null)
329 if [ "$(kernelverser)" -lt "002006" ]; then
5e6dfc29
JR
330 LC_ALL=C grep -q 'hid' /proc/bus/usb/drivers 2>/dev/null || run_cmd "Initializing USB HID interface" modprobe hid 2> /dev/null
331 mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02" 2>/dev/null)
332 kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01" 2>/dev/null)
333 if [ -n "$kbdoutput" ]; then
334 run_cmd "Initializing USB keyboard" modprobe keybdev
335 fi
336 if [ -n "$mouseoutput" ]; then
337 run_cmd "Initializing USB mouse" modprobe mousedev
338 fi
cc10e704
JR
339 fi
340 fi
b3965b3d 341
cc10e704 342 # Setup hdparm thing (if exists and is needed)
07ea1da7 343 if ! strstr "$cmdline" nohdparm; then
cc10e704 344 [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
ebd1845b 345 fi
b3965b3d 346
07ea1da7 347 if [ -f /fastboot ] || strstr "$cmdline" "fastboot"; then
cc10e704
JR
348 fastboot=yes
349 else
350 fastboot=
351 fi
03f9cfee 352
cc10e704
JR
353 if [ -f /fsckoptions ]; then
354 fsckoptions=$(cat /fsckoptions)
355 else
356 fsckoptions=''
357 fi
cb4d1aa7 358
cc10e704
JR
359 if [ -f /forcefsck ]; then
360 fsckoptions="-f $fsckoptions"
790968dd
ER
361 else
362 # Obey the fs_passno setting for / (see fstab(5))
363 # - find the / entry
6fe4e4eb
ER
364 # - make sure we have at least 6 fields
365 _ROOTFS_PASSNO=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $6}' /etc/fstab)
cc10e704 366 fi
7742e157 367
cc10e704 368 _RUN_QUOTACHECK=0
dc12b33c 369 _ROOTFS_DEVICE=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $1}' /etc/fstab)
2fce16f9 370 _ROOTFS_TYPE=$(awk '$2 == "/" && $3 != "rootfs" { print $3 }' /proc/mounts 2>/dev/null)
cc10e704 371
dc12b33c 372 if [ -z "$fastboot" -a "$_ROOTFS_TYPE" != "nfs" -a "$_ROOTFS_TYPE" != "romfs" -a "$_ROOTFS_PASSNO" != 0 -a -e $_ROOTFS_DEVICE ]; then
cc10e704
JR
373 show "Checking root filesystem"; started
374 initlog -c "fsck -C -T -a $fsckoptions /"
375
376 rc=$?
377
378 # A return of 4 or higher means there were serious problems.
379 if [ $rc -gt 3 ]; then
380 [ -e /proc/splash ] && echo "verbose" > /proc/splash
381 # don't use '\n' in nls macro !
382 echo
383 echo
384 nls "*** An error occurred during the file system check."
385 nls "*** Dropping you to a shell; the system will reboot"
386 nls "*** when you leave the shell."
387 echo
388
526b7c62 389 PS1="`nls '(Repair filesystem)# '`"; export PS1
cc10e704 390 [ "$SELINUX" = "1" ] && disable_selinux
277e5f53 391 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
cc10e704
JR
392 /sbin/sulogin
393 else
394 /bin/sh
395 fi
cee18a41 396
cc10e704
JR
397 run_cmd "Unmounting file systems" umount -a
398 mount -n -o remount,ro /
399 run_cmd "Automatic reboot in progress" reboot
400 # A return of 2 or 3 means that filesystem was repaired but we need
401 # to reboot.
402 elif [ "$rc" = "2" -o "$rc" = "3" ]; then
403 [ -e /proc/splash ] && echo "verbose" > /proc/splash
404 echo
405 nls "*** Filesystem was repaired but system needs to be"
406 nls "*** rebooted before mounting it."
407 nls "*** REBOOTING ***"
408 echo
409
410 run_cmd "Unmounting file systems" umount -a
411 mount -n -o remount,ro /
412 run_cmd "Automatic reboot in progress" reboot
413 elif [ "$rc" = "1" ]; then
414 _RUN_QUOTACHECK=1
cb4d1aa7 415 fi
cb4d1aa7 416 fi
7742e157 417
5e6dfc29 418 # Check for arguments
07ea1da7 419 if strstr "$cmdline" nopnp; then
cc10e704
JR
420 PNP=
421 else
422 PNP=yes
423 fi
7742e157 424
cc10e704
JR
425 # set up pnp and kernel pnp
426 if [ -n "$PNP" ]; then
277e5f53 427 if ! is_no "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
5e6dfc29
JR
428 run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf
429 fi
277e5f53 430 if ! is_no "$RUN_KERNELPNP"; then
170103c8 431 /sbin/modprobe isa-pnp 2> /dev/null
5e6dfc29
JR
432 if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then
433 show "Setting up ISA PNP devices (kernelspace pnp)"; busy
434 grep -v "^#" /etc/isapnp/isapnp-kernel.conf 2>/dev/null >/proc/isapnp && (deltext; ok) || (deltext; fail)
435 fi
cc10e704 436 fi
b68f99e5 437 fi
7742e157 438
41c877f2 439 _ROOTFS_RO=$(awk '($1 !~ /^#/ && $2 == "/" && ($4 == "ro" || $4 ~ /,ro$/ || $4 ~ /^ro,/ || $4 ~ /,ro,/ ) && NF >= 6) { print "ro" }' /etc/fstab)
cc10e704 440 # Remount the root filesystem read-write
41c877f2 441 if [ -z "$_ROOTFS_RO" ]; then
47e385fd 442 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
443 fi
cee18a41 444
cc10e704
JR
445 # Update quotas if fsck was run on /
446 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
447 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vnug /
448 fi
aa362992 449
5475bb0f
ER
450 # Clean up SELinux labels
451 if [ -n "$SELINUX" ]; then
452 for file in /etc/mtab /etc/cryptomtab /etc/ld.so.cache ; do
453 [ -r $file ] && restorecon $file >/dev/null 2>&1
454 done
455 fi
652dbae5 456
6b496866 457 if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then
dd23d50d 458 # XXX, this must be probably done after random is initialized from /var/run/random-seed
1b05bb8a 459 show "Starting disk encryption using the RNG"
dd23d50d
ER
460 init_crypto 1 && ok || fail
461 fi
652dbae5
ER
462else
463 # Start logging console output since we have all /dev stuff setup
464 if [ "$RC_BOOTLOG" ]; then
465 /sbin/blogd -q
466 fi
677fdd75 467fi
5e6dfc29 468
cb4d1aa7 469# Remove stale backups
47e385fd 470rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~ >/dev/null 2>&1
cb4d1aa7 471
ef05209d
JR
472# Remove /etc/nologin when starting system
473[ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
474
277e5f53 475if ! is_no "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
ef05209d
JR
476 show "Enabling Delay Login"; busy
477 echo > /etc/nologin
478 nls "System bootup in progress - please wait" >> /etc/nologin
479 echo >> /etc/nologin
480 chmod 644 /etc/nologin
481 cp -fp /etc/nologin /etc/nologin.boot
482 ok
483fi
484
485# The root filesystem is now read-write, so we can now log via
486# syslog() directly...
487if [ -n "$IN_INITLOG" ]; then
488 IN_INITLOG=""
489fi
490
cc10e704 491if ! is_yes "$VSERVER"; then
220df3e7
JR
492 # Clear mtab
493 :>/etc/mtab
494 [ -f /etc/cryptomtab ] && :>/etc/cryptomtab
495
34c624e7 496 # Enter root, /proc, /sys and other into mtab.
cc10e704
JR
497 mount -f /
498 mount -f /proc
3f9e71a5
JR
499 if is_fsmounted usbfs /proc/bus/usb; then
500 mount -f -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb
501 fi
7d45bad6 502
3f9e71a5 503 if is_fsmounted sysfs /sys; then
cc10e704 504 mount -f -t sysfs sysfs /sys
3f9e71a5
JR
505 if is_fsmounted securityfs /sys/kernel/security ; then
506 mount -f -t securityfs securityfs /sys/kernel/security
defac991 507 fi
cc10e704 508 fi
ad084d91 509
3f9e71a5 510 if is_fsmounted selinuxfs /selinux; then
cc10e704
JR
511 mount -f -t selinuxfs selinuxfs /selinux
512 fi
cb4d1aa7 513
3f9e71a5
JR
514 if is_fsmounted cgroup /dev/cpuset; then
515 mount -f -t cgroup -o cpuset,noprefix none /dev/cpuset
516 elif is_fsmounted cpuset /dev/cpuset; then
2d495b7f 517 mount -f -t cpuset none /dev/cpuset
cc10e704 518 fi
fd6887dc 519
cc10e704
JR
520 if [ ! -f /proc/modules ]; then
521 USEMODULES=
07ea1da7 522 elif ! strstr "$cmdline" nomodules; then
cc10e704
JR
523 USEMODULES=y
524 else
525 USEMODULES=
4cc4301b 526 fi
de1fc6ce 527
0b38e7f1 528 uname_r=$(uname -r)
cc10e704
JR
529 # Adjust symlinks as necessary in /boot to keep system services from
530 # spewing messages about mismatched System maps and so on.
277e5f53 531 if ! is_no "$SET_SLINKS"; then
c14f9857
ER
532 if [ -L /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
533 ln -s -f System.map-$uname_r /boot/System.map
cc10e704 534 fi
c14f9857
ER
535 if [ ! -e /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
536 ln -s -f System.map-$uname_r /boot/System.map
cc10e704 537 fi
418c0cf3 538 fi
7742e157 539
cc10e704
JR
540 # Run depmod if RUN_DEPMOD != "no" and:
541 # a) user requested or RUN_DEPMOD="";
542 # b) modules.dep is missing
cc10e704
JR
543 if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
544 if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then
545 run_cmd "Finding module dependencies" depmod -a
0b38e7f1 546 elif [ "$RUN_DEPMOD" = "ifmissing" ] && [ ! -f /lib/modules/$uname_r/modules.dep ]; then
cc10e704
JR
547 run_cmd "Finding module dependencies" depmod -A
548 fi
aa362992 549 fi
0b38e7f1 550 unset uname_r
5bb58804 551
cc10e704
JR
552 if [ -f /proc/sys/kernel/modprobe ]; then
553 if [ -n "$USEMODULES" ]; then
554 sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
cc10e704
JR
555 else
556 # We used to set this to NULL, but that causes
557 # 'failed to exec' messages"
558 sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
cc10e704 559 fi
cb4d1aa7 560 fi
cb4d1aa7 561
cc10e704
JR
562 # Load usb storage here, to match most other things
563 if [ -n "$needusbstorage" ]; then
170103c8 564 modprobe usb-storage >/dev/null 2>&1
cc10e704 565 fi
cb4d1aa7 566
cc10e704 567 # Load firewire devices
07ea1da7 568 if ! strstr "$cmdline" nofirewire; then
cc10e704
JR
569 aliases=$(/sbin/modprobe -c | awk '/^alias ieee1394-controller/ { print $3 }')
570 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
5e6dfc29
JR
571 for alias in $aliases ; do
572 [ "$alias" = "off" ] && continue
573 run_cmd "$(nls 'Initializing firewire controller') ($alias)" /sbin/modprobe $alias
574 done
575 LC_ALL=C grep -E "SBP2" /proc/bus/ieee1394/devices 2>/dev/null && /sbin/modprobe -s sbp2 > /dev/null 2>&1
cc10e704 576 fi
5e6dfc29
JR
577 fi
578
cc10e704 579 # Load sound modules if they need persistent DMA buffers
e0fdf0af 580 if /sbin/modprobe -c | grep -q "^options sound dmabuf=1"; then
cc10e704 581 RETURN=0
a51d5138 582 alias=$(/sbin/modprobe -c | grep -sE "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
cc10e704
JR
583 if [ -n "$alias" -a "$alias" != "off" ] ; then
584 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
585 RETURN=$?
586 fi
a51d5138 587 alias=$(/sbin/modprobe -c | grep -sE "^alias[[:space:]]+sound-slot-0[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
cc10e704
JR
588 if [ -n "$alias" -a "$alias" != "off" ] ; then
589 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
590 RETURN=$?
f47acf6f
JR
591 fi
592 fi
472fa41e 593
cc10e704 594 # Load modules
3aabb390 595 load_kernel_modules
7742e157 596
e62309d9 597 if [ -x /sbin/multipath ]; then
2607b4f4 598 # first make nodes that were discarded due (possible) new /dev mount
6dbec259 599 modprobe -s dm-mod
2607b4f4 600 /sbin/dmsetup mknodes
7da998bd 601 modprobe -s dm-multipath
e62309d9 602 run_cmd "Activating dm-multipath" /sbin/multipath -v 0
094b84e1 603 /sbin/dmsetup ls --target multipath --exec '/sbin/kpartx -a -p p'
e62309d9
ER
604 fi
605
3a4304f3
AM
606 if [ -x /sbin/dmraid ]; then
607 run_cmd "Activating ATARAID devices" /sbin/dmraid -ay
608 fi
609
cc10e704
JR
610 # Find and activate volume groups:
611 # EVMS
612 if [ -x /sbin/evms_activate ]; then
cc10e704 613 if [ "$(kernelverser)" -lt "002006" ]; then
5e6dfc29 614 # Linux 2.4 core modules
170103c8 615 modprobe -s evms > /dev/null 2>&1
616 modprobe -s evms_passthru > /dev/null 2>&1
617 modprobe -s ldev_mgr > /dev/null 2>&1
618 modprobe -s dos_part > /dev/null 2>&1
cc10e704 619 else
5e6dfc29 620 # Linux 2.6 core module
170103c8 621 modprobe -s evmscore > /dev/null 2>&1
d6749722 622 fi
5e6dfc29 623
170103c8 624 is_yes "$EVMS_GUID_PTABLE" && modprobe -s gpt_part >/dev/null 2>&1
625 is_yes "$EVMS_LVM" && modprobe -s lvm_vge >/dev/null 2>&1
626 is_yes "$EVMS_AIX" && modprobe -s AIXlvm_vge >/dev/null 2>&1
627 is_yes "$EVMS_OS2" && modprobe -s os2lvm_vge >/dev/null 2>&1
cc10e704
JR
628 run_cmd "Discovering EVMS volumes" /sbin/evms_activate
629 if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then
630 # Link nodes for compatibility with LVM
24fec6e3
ER
631 if [ "$(echo /dev/evms/lvm/*)" != '/dev/evms/lvm/*' ] ; then
632 ln -s /dev/evms/lvm/* /dev
de1fc6ce 633 fi
cc10e704
JR
634 fi
635 fi
49c61c56 636
cc10e704
JR
637 # LVM (keep in sync with LVM starting after RAID run!)
638 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
0174ae89 639 lvmversion=$(LC_ALL=C /sbin/vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}')
cc10e704 640 if [ "$lvmversion" = "1" ] ; then
170103c8 641 modprobe -s lvm-mod >/dev/null 2>&1
cc10e704
JR
642 lvmignorelock=""
643 elif [ "$lvmversion" = "2" ] ; then
170103c8 644 modprobe -s dm-mod >/dev/null 2>&1
cc10e704
JR
645 lvmignorelock="--ignorelockingfailure"
646 else
170103c8 647 modprobe -s lvm-mod >/dev/null 2>&1
5e6dfc29 648 # device mapper (2.5+ and patched 2.4)
170103c8 649 modprobe -s dm-mod >/dev/null 2>&1
5e6dfc29 650 lvmignorelock=""
cc10e704 651 fi
5e6dfc29 652
2607b4f4 653 run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelock
cc10e704 654 run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmignorelock
fcc79c02
ER
655 if [ "$lvmversion" = "2" ]; then
656 /sbin/vgmknodes
657 # display VG statistics
658 /sbin/vgdisplay -s
659 fi
cc10e704
JR
660 fi
661
662 # Add raid devices
663 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ] || [ -f /etc/raidtab ]; then
cc10e704
JR
664 modprobe -s md >/dev/null 2>&1
665 if [ -f /proc/mdstat ]; then
5e6dfc29
JR
666 goraidtab=1
667 golvm=0
668 rc=0
669 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
670 if (grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null); then
0fe527f8 671 run_cmd "Starting up RAID devices" /sbin/mdadm --assemble --scan --auto=yes
5e6dfc29
JR
672 rc=$?
673 [ "$rc" -eq 0 ] && goraidtab=0 && golvm=1
cc10e704 674 fi
5e6dfc29
JR
675 fi
676
677 if [ -f /etc/raidtab -a "$goraidtab" -eq 1 ]; then
49c61c56 678 for i in $(awk '!/^#/ && /raiddev/{print $2}' /etc/raidtab 2>/dev/null); do
5e6dfc29
JR
679 golvm=1
680 RAIDDEV=$(basename $i)
681 RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat 2>/dev/null)
682 show "Starting up RAID device %s" $RAIDDEV
683 busy
684 if [ -z "$RAIDSTAT" ]; then
685 # Try raidstart first...if that fails then
686 # fall back to raid0run and if that fails too
687 # fall back to raidadd, raidrun.
688 RESULT=1
689 if [ -x /sbin/raidstart ]; then
690 /sbin/raidstart $i
691 RESULT=$?
692 fi
693 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
694 /sbin/raid0run $i
695 RESULT=$?
696 fi
697 if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
698 /sbin/raidadd $i
699 /sbin/raidrun $i
700 RESULT=$?
701 fi
702 if [ $RESULT -gt 0 ]; then
703 rc=1
704 fail
705 else
706 ok
707 fi
708 else
709 ok
710 fi
711 done
712 fi
713
714 # A non-zero return means there were problems
715 if [ $rc -gt 0 ]; then
716 [ -e /proc/splash ] && echo "verbose" > /proc/splash
717 show "Starting up RAID devices"; fail
718 echo
719 echo
720 nls "*** An error occurred during the RAID startup."
721 nls "*** Dropping you to a shell; the system will reboot"
722 nls "*** when you leave the shell."
723 echo
724
725 PS1="$(nls '(RAID Repair)# ')"; export PS1
726 [ "$SELINUX" = "1" ] && disable_selinux
277e5f53 727 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
5e6dfc29 728 /sbin/sulogin
cc10e704 729 else
5e6dfc29 730 /bin/sh
cc10e704 731 fi
12de71be 732
5e6dfc29
JR
733 run_cmd "Unmounting file systems" umount -a
734 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
735 run_cmd "Automatic reboot in progress" reboot
cc10e704 736 fi
5e6dfc29
JR
737 # LVM on RAID (keep in sync with LVM setting few lines above)
738 if [ "$golvm" -eq "1" ]; then
739 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
2607b4f4 740 run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmignorelock
5e6dfc29 741 run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmignorelock
2607b4f4 742 [ "$lvmversion" = "2" ] && /sbin/vgmknodes
5e6dfc29 743 fi
cc10e704 744 fi
5e6dfc29 745 show "Starting up RAID devices"; ok
2619a5cf 746 fi
12de71be 747 fi
7742e157 748
cc10e704
JR
749 _RUN_QUOTACHECK=0
750 # Check filesystems
07ea1da7 751 if [ -z "$fastboot" ] && ! strstr "$cmdline" nofsck; then
cc10e704
JR
752 rc_splash "fsck start"
753 show "Checking filesystems"; started
790968dd 754 initlog -c "fsck -C -T -R -A -a -P $fsckoptions"
cc10e704
JR
755
756 rc=$?
757
758 # A return of 2 or higher means there were serious problems
759 if [ $rc -gt 1 ]; then
760 [ -e /proc/splash ] && echo "verbose" > /proc/splash
761 echo
762 echo
763 nls "*** An error occurred during the file system check."
764 nls "*** Dropping you to a shell; the system will reboot"
765 nls "*** when you leave the shell."
766 echo
767
768 PS1="$(nls '(Repair filesystem)# ')"; export PS1
769 [ "$SELINUX" = "1" ] && disable_selinux
277e5f53 770 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
cc10e704
JR
771 /sbin/sulogin
772 else
773 /bin/sh
774 fi
7742e157 775
cc10e704
JR
776 run_cmd "Unmounting file systems" umount -a
777 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
778 run_cmd "Automatic reboot in progress" reboot
779 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
780 _RUN_QUOTACHECK=1
781 fi
782 rc_splash "fsck stop"
7742e157 783 fi
7742e157 784
cc10e704
JR
785 # Mount all other filesystems (except for NFS and /proc, which is already
786 # mounted). Contrary to standard usage,
787 # filesystems are NOT unmounted in single user mode.
788
438bf720 789 run_cmd "Mounting local filesystems" mount -a -t nonfs,nfs4,smbfs,ncpfs,proc,cifs -O no_netdev
cc10e704 790
9a0a016d
ER
791 # now we have /usr mounted, recheck if we have gettext and tput available.
792 if is_no "$TPUT"; then
793 GETTEXT=
348aacfc 794 TPUT=
04342743 795 rc_gettext_init
9a0a016d
ER
796 fi
797
cc10e704
JR
798 # Now do some workaround - encrypted filesystems couldn't have been fsck-ed
799 # before mount - that's where the password is entered.
800 # mount is buggy - when remounting loopback filesystem, loop=XXX
801 # option is removed from /etc/mtab
802 if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then
803 show "Checking encrypted filesystems"; started
fea9b6da 804 LOOPLIST="$(LC_ALL=C awk '
cc10e704
JR
805 FILENAME=="/proc/mounts" {
806 TAB[$2]=$1;
807 }
808 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ {
809 if ($2 in TAB){print TAB[$2];}
810 }
811 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
812 if ($2 in TAB){print TAB[$2];}
813 sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4);
814 cmd="mount " $2 " -o remount," $4;
815 system(cmd);
816 }
817 ' /proc/mounts /etc/fstab)"
818 initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST"
819 rc=$?
820
821 # A return of 2 or higher means there were serious problems.
822 if [ $rc -gt 1 ]; then
823 [ -e /proc/splash ] && echo "verbose" > /proc/splash
824 echo
825 echo
826 nls "*** An error occurred during the file system check."
827 nls "*** Dropping you to a shell; the system will reboot"
828 nls "*** when you leave the shell."
829 echo
830
bf14fcab 831 PS1="$(nls '(Repair filesystem)# ')"; export PS1
cc10e704 832 [ "$SELINUX" = "1" ] && disable_selinux
277e5f53 833 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
cc10e704
JR
834 /sbin/sulogin
835 else
836 /bin/sh
837 fi
6fa97a5d 838
cc10e704
JR
839 run_cmd "Unmounting file systems" umount -a
840 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
841 run_cmd "Automatic reboot in progress" reboot
842 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
843 _RUN_QUOTACHECK=1
844 fi
5e6dfc29 845
cc10e704
JR
846 show "Remounting encrypted filesystems back in rw mode"; busy
847 awk '
848 FILENAME=="/proc/mounts" {
849 TAB[$2]=$1;
850 }
851 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
852 sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4);
853 cmd="mount " $2 " -o remount," $4;
854 system(cmd);
855 }
856 ' /proc/mounts /etc/fstab
857 ok
858 fi
6e16ab8f 859
9a0a016d 860 # /var/log should be writable now, so start saving the boot output
652dbae5
ER
861 if [ "$RC_BOOTLOG" ]; then
862 echo > /var/log/boot.msg
863 killall -IO blogd
864 fi
cb4d1aa7 865
1aaf8c92
JR
866 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
867 run_cmd "Checking filesystem quotas" /sbin/quotacheck -vnugRa
868 fi
cb4d1aa7 869
1aaf8c92
JR
870 # Turn on quota
871 if [ -x /sbin/quotaon ]; then
872 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug
873 fi
677fdd75 874
1aaf8c92
JR
875 # Turn on process accounting
876 if [ -x /etc/rc.d/rc.acct ]; then
877 /etc/rc.d/rc.acct start
878 fi
cb4d1aa7 879
cc10e704 880 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
280fc816 881 if is_yes "$TIME_SETUP_DELAYED"; then
cc10e704
JR
882 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
883 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
884 fi
0bbfed6f 885 fi
0bbfed6f 886
cc10e704
JR
887 # Initialize the serial ports
888 if [ -f /etc/rc.d/rc.serial ]; then
889 . /etc/rc.d/rc.serial
890 fi
201c98b9 891
277e5f53 892 if [ -f /proc/sys/kernel/panic -a -n "$PANIC_REBOOT_TIME" -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
cc10e704
JR
893 show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy
894 if (sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1); then ok; else fail; fi
895 fi
201c98b9 896
cc10e704
JR
897 # ... and here finish configuring parameters
898 /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
ef05209d 899else
fea9b6da 900 # /var/log should be writable now, so start saving the boot output
652dbae5
ER
901 if [ "$RC_BOOTLOG" ]; then
902 echo > /var/log/boot.msg
903 killall -IO blogd
904 fi
905
ef05209d 906 clean_vserver_mtab
cc10e704 907fi
adec827a 908
652dbae5 909
1aaf8c92
JR
910[ -n "$SELINUX" ] && [ -f /.autorelabel ] && relabel_selinux
911
6239bd5c 912# Clean up /.
47e385fd 913rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff >/dev/null 2>&1
cb4d1aa7
JR
914
915# Clean up /var
5145ce41 916# /usr could be still not mounted if it is on NFS.
cb4d1aa7 917for afile in /var/lock/* /var/run/*; do
fea9b6da 918 bafile=${afile##*/}
cb4d1aa7 919 if [ -d "$afile" ]; then
38b419e3 920 case $bafile in
fea9b6da
ER
921 news|sudo|mon|cvs)
922 ;;
923 *)
91dc9337 924 echo $afile/* | xargs rm -rf
fea9b6da 925 ;;
38b419e3 926 esac
cb4d1aa7 927 else
5e6dfc29 928 [ "$bafile" != "hwprofile" ] && rm -f $afile 2> /dev/null
cb4d1aa7
JR
929 fi
930done
5145ce41 931
e0cba078 932# Delete stale files
4eb58d70
AM
933rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \
934 /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.*
935rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \
5e6dfc29
JR
936 /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \
937 /tmp/scrollkeeper-* /tmp/ssh-*
45955ed4 938
201c98b9 939{
6b4a354c 940# Clean up utmp/wtmp
fea9b6da 941if ! is_no "$NEED_XFILES"; then
6b4a354c
AM
942 :>/var/run/utmpx
943 touch /var/log/wtmpx
afa9b748 944 chown root:utmp /var/run/utmpx /var/log/wtmpx
19b0557d 945 chmod 0664 /var/run/utmpx /var/log/wtmpx
054a52c9
JR
946else
947 :>/var/run/utmp
948 touch /var/log/wtmp
afa9b748 949 chown root:utmp /var/run/utmp /var/log/wtmp
19b0557d 950 chmod 0664 /var/run/utmp /var/log/wtmp
6b4a354c 951fi
7e04fe0e 952
7e04fe0e 953# Clean /tmp
fcf89189 954if is_yes "$CLEAN_TMP"; then
fea9b6da 955 # XXX LC_ALL needed here
cb4d1aa7 956 rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
7e04fe0e 957fi
7742e157 958
e6c8dd44
AM
959# System protected dirs
960mkdir -m 1777 -p /tmp/.ICE-unix > /dev/null 2>&1
961chown root:root /tmp/.ICE-unix
677fdd75 962[ -n "$SELINUX" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1
e6c8dd44 963
1aaf8c92 964if ! is_yes "$VSERVER"; then
fea9b6da 965 run_cmd "Enabling swap space" /bin/true
1aaf8c92
JR
966 # Right, now turn on swap in case we swap to files
967 swapon -a >/dev/null 2>&1
7742e157 968
0d60cc3e
JR
969 # If a SCSI tape has been detected, load the st module unconditionally
970 # since many SCSI tapes don't deal well with st being loaded and unloaded
971 if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then
972 if grep -qv ' 9 st' /proc/devices 2>/dev/null; then
973 if [ -n "$USEMODULES" ] ; then
974 # Try to load the module. If it fails, ignore it...
975 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
976 fi
7742e157
AF
977 fi
978 fi
7742e157 979
cc10e704
JR
980 # Now that we have all of our basic modules loaded and the kernel going,
981 # let's dump the syslog ring somewhere so we can find it later
c8f4b766 982 dmesg > /var/log/dmesg
cc10e704
JR
983 i=5
984 while [ $i -ge 0 ]; do
985 if [ -f /var/log/dmesg.$i ]; then
5e6dfc29
JR
986 chmod 0600 /var/log/dmesg.$i
987 mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1))
cc10e704
JR
988 fi
989 i=$(($i-1))
990 done
991 cp -f /var/log/dmesg /var/log/dmesg.0
992 chmod 0600 /var/log/dmesg /var/log/dmesg.0
993fi
7742e157 994
a81df7c5
AM
995if ! is_no "$RC_PROMPT"; then
996 while :; do
997 pid=$(/sbin/pidof getkey)
998 [ -n "$pid" -o -e /var/run/getkey_done ] && break
999 usleep 100000
1000 done
1001 [ -n "$pid" ] && kill -TERM "$pid" >/dev/null 2>&1
1002fi
6b4a354c 1003} &
385dc542 1004
863baad1 1005# /proc extra check if the background process we just spawned is still running,
385dc542 1006# as in case of vserver bootup it finishes quite instantly.
863baad1 1007if ! is_no "$RC_PROMPT" && [ -d /proc/$! ]; then
a81df7c5
AM
1008 /sbin/getkey i && touch /var/run/confirm
1009 touch /var/run/getkey_done
6b4a354c
AM
1010fi
1011wait
a81df7c5
AM
1012if ! is_no "$RC_PROMPT"; then
1013 rm -f /var/run/getkey_done
1014fi
de1fc6ce 1015echo
This page took 0.289355 seconds and 4 git commands to generate.