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