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