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