3 # /etc/rc.d/rc.sysinit - run once at boot time
6 # Taken in part from Miquel van Smoorenburg's bcheckrc.
9 # reasonable start values for bootsplash progress.
15 if [ -r /etc/sysconfig/i18n ]; then
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
29 # Read network config data
30 if [ -r /etc/sysconfig/network ]; then
31 . /etc/sysconfig/network
40 . /etc/rc.d/init.d/functions
43 typeset _d selinuxfs _t _r
45 while read _d selinuxfs _t _r; do
46 [ "$_t" = "selinuxfs" ] && break
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
55 typeset _d selinuxfs _t _r
57 while read _d selinuxfs _t _r; do
58 [ "$_t" = "selinuxfs" ] && break
61 *** Warning -- SELinux relabel is required. ***
62 *** Disabling security enforcement. ***
63 *** Relabeling could take a very long time, ***
64 *** depending on file system size. ***
66 echo "0" > $selinuxfs/enforce
67 /sbin/fixfiles -F relabel > /dev/null 2>&1
69 echo "*** Enabling security enforcement. ***"
70 echo $SELINUX > $selinuxfs/enforce
73 # Remove duplicate entries from mtab (for vserver guest use only)
74 clean_vserver_mtab() {
76 while read device mountpoint line; do
77 grep -qs "$mountpoint" /etc/mtab.clean || \
78 echo "$device $mountpoint $line" >> /etc/mtab.clean
80 cat /etc/mtab.clean > /etc/mtab
84 # Loads modules from /etc/modules, /etc/modules.X.Y and /etc/modules.X.Y.Z
85 load_kernel_modules() {
98 # Loop over every line in modules file
100 egrep -hv '^(#|[[:blank:]]*$)' /etc/modules /etc/modules.$kernel /etc/modules.$kerneleq 2>/dev/null
101 echo '' # make sure there is a LF at the end
102 ) | while read module args; do
103 [ -z "$module" ] && continue
104 modprobe -s $module -- $args
108 # boot logging to /var/log/boot.msg. install showconsole package to get it.
109 if [ -x /sbin/blogd ] && ! is_no "$RC_BOOTLOG"; then
115 if ! is_yes "$VSERVER" ; then
116 # we need /proc mounted before everything
117 mount -n -o gid=17 -t proc /proc /proc
119 # Only read this once.
120 cmdline=$(cat /proc/cmdline)
122 # sysfs is also needed before any other things (under kernel > 2.5)
123 if grep -q sysfs /proc/filesystems 2>/dev/null ; then
124 mount -n -o gid=17 -t sysfs sysfs /sys
125 if [ "$(kernelver)" -ge "002006014" ] && \
126 grep -q securityfs /proc/filesystems 2>/dev/null ; then
127 mount -n -o gid=17 -t securityfs securityfs /sys/kernel/security
132 if grep -q selinuxfs /proc/filesystems 2>/dev/null && ! grep -q selinuxfs /proc/mounts 2>/dev/null; then
133 mount -n -o gid=17 -t selinuxfs selinuxfs /selinux
136 # PLD Linux LiveCD support
137 if [ -x /etc/rc.d/rc.live ]; then
141 # Choose Hardware profile
142 if [ -f /etc/sysconfig/hwprof ]; then
143 . /etc/sysconfig/hwprof
144 if is_yes "${HWPROFILES}" && [ -x /sbin/hwprofile -a -d /etc/sysconfig/hwprofiles/data ]; then
145 mount -n / -o rw,remount
147 mount -n / -o ro,remount
151 # Disable splash when requested
152 [ -e /proc/splash ] && is_no "$BOOT_SPLASH" && echo "0" > /proc/splash
154 # Check SELinux status
155 selinuxfs=$(awk '/ selinuxfs / { print $2 }' /proc/mounts 2> /dev/null)
157 if [ -n "$selinuxfs" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then
158 if [ -r $selinuxfs/enforce ] ; then
159 SELINUX=$(cat $selinuxfs/enforce)
161 # assume enforcing if you can't read it
166 if [ -x /sbin/restorecon ] && LC_ALL=C fgrep -q " /dev " /proc/mounts 2>/dev/null ; then
167 /sbin/restorecon -R /dev 2>/dev/null
171 [ -z "${CONSOLETYPE}" ] && CONSOLETYPE="$(/sbin/consoletype)"
173 if [ "$CONSOLETYPE" = "vt" -a -x /sbin/setsysfont ]; then
179 # Print welcome message
180 nls "\t\t\t%sPowered by %sPLD Linux Distribution%s" "$(termput setaf $CPOWEREDBY)" "$(termput setaf $CPLD)" "$(termput op)"
181 if ! is_no "$RC_PROMPT"; then
182 nls -n "\t\t Press %sI%s to enter interactive startup" "$(termput setaf $CI)" "$(termput op)"
187 if [ -z "${HOSTNAME}" ]; then
188 show "$(nls 'Host:') $(hostname)" ; ok
190 run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME}
193 # Set the NIS domain name
194 if [ -n "$NISDOMAIN" ]; then
195 run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN
200 if ! is_yes "$VSERVER"; then
201 # Set console loglevel
202 if [ -n "$CONSOLE_LOGLEVEL" ]; then
203 /bin/dmesg -n $CONSOLE_LOGLEVEL
206 if ! is_no "$START_UDEV"; then
207 [ -x /sbin/start_udev ] && /sbin/start_udev
210 # Unmount the initrd, if necessary
211 if grep -q /initrd /proc/mounts 2>/dev/null && ! grep -q /initrd/loopfs /proc/mounts 2>/dev/null; then
212 umount /initrd/dev 2>/dev/null
214 /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1
217 # Start logging console output since we have all /dev stuff setup
218 if [ "$RC_BOOTLOG" ]; then
222 # cpuset support (mounted unconditionally, shouldn't be a problem)
223 if grep -q cgroup /proc/filesystems 2>/dev/null ; then
224 mount -n -t cgroup none /dev/cpuset -ocpuset
225 [ $? -eq 0 ] && echo "/sbin/cpuset_release_agent" > /dev/cpuset/release_agent
226 elif grep -q cpuset /proc/filesystems 2>/dev/null ; then
227 mount -n -t cpuset none /dev/cpuset
230 # Configure Linux kernel (initial configuration, some required modules still
232 /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
234 # Set the system clock.
239 if [ -f /etc/sysconfig/clock ]; then
240 . /etc/sysconfig/clock
242 # convert old style clock config to new values
243 if [ "${CLOCKMODE}" = "GMT" ]; then
245 elif [ "${CLOCKMODE}" = "ARC" ]; then
250 if grep "system serial" /proc/cpuinfo 2>/dev/null | grep -q MILO 2>/dev/null ; then
255 CLOCKFLAGS="--hctosys"
257 if is_yes "$UTC" ; then
258 CLOCKFLAGS="$CLOCKFLAGS --utc"
259 CLOCKDEF="$CLOCKDEF (utc)"
261 CLOCKFLAGS="$CLOCKFLAGS --localtime"
262 CLOCKDEF="$CLOCKDEF (local)"
265 if is_yes "$ARC" ; then
266 CLOCKFLAGS="$CLOCKFLAGS -A"
267 CLOCKDEF="$CLOCKDEF (arc)"
270 if is_yes "$SRM" ; then
271 CLOCKFLAGS="$CLOCKFLAGS -S"
272 CLOCKDEF="$CLOCKDEF (srm)"
275 # Check if timezone definition is available
276 if [ -e /etc/localtime -a -e /dev/rtc ] ; then
277 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
278 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
281 TIME_SETUP_DELAYED=yes
284 if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then
285 # XXX might need modules dep
286 # Device mapper & related initialization
287 if ! fgrep -q device-mapper /proc/devices; then
291 # but should do this before swapon?
292 . /etc/rc.d/init.d/cryptsetup
293 show "Starting disk encryption"
294 init_crypto 0 && ok || fail
298 run_cmd "Activating swap partitions" swapon -a -e
300 # Initialize USB controllers
302 if ! strstr "$cmdline" "nousb" && ! grep -q "/proc/bus/usb" /proc/mounts 2>/dev/null ; then
303 aliases=$(/sbin/modprobe -c | awk '/^alias[\t ]+usb-controller/ { print $3 }')
304 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
305 /sbin/modprobe -s -k usbcore
306 for alias in $aliases ; do
307 [ "$alias" = "off" ] && continue
308 run_cmd "$(nls 'Initializing USB controller') ($alias)" /sbin/modprobe -s $alias
310 [ $? -eq 0 -a -n "$aliases" ] && usb=1
312 if grep -iq "usb" /proc/devices 2>/dev/null ; then
317 if [ "$usb" = "1" -a ! -f /proc/bus/usb/devices ]; then
318 run_cmd "Mounting USB filesystem" mount -n -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb
322 if [ "$usb" = "1" ]; then
323 needusbstorage=$(LC_ALL=C cat /proc/bus/usb/devices 2>/dev/null|grep -e "^I.*Cls=08" 2>/dev/null)
324 if [ "$(kernelverser)" -lt "002006" ]; then
325 LC_ALL=C grep -q 'hid' /proc/bus/usb/drivers 2>/dev/null || run_cmd "Initializing USB HID interface" modprobe hid 2> /dev/null
326 mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02" 2>/dev/null)
327 kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01" 2>/dev/null)
328 if [ -n "$kbdoutput" ]; then
329 run_cmd "Initializing USB keyboard" modprobe keybdev
331 if [ -n "$mouseoutput" ]; then
332 run_cmd "Initializing USB mouse" modprobe mousedev
337 # Setup hdparm thing (if exists and is needed)
338 if ! strstr "$cmdline" nohdparm; then
339 [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
342 if [ -f /fastboot ] || strstr "$cmdline" "fastboot"; then
348 if [ -f /fsckoptions ]; then
349 fsckoptions=$(cat /fsckoptions)
354 if [ -f /forcefsck ]; then
355 fsckoptions="-f $fsckoptions"
357 # Obey the fs_passno setting for / (see fstab(5))
359 # - make sure we have at least 6 fields
360 _ROOTFS_PASSNO=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $6}' /etc/fstab)
364 _ROOTFS_DEVICE=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $1}' /etc/fstab)
365 _ROOTFS_TYPE=$(awk '$2 == "/" && $3 != "rootfs" { print $3 }' /proc/mounts 2>/dev/null)
367 if [ -z "$fastboot" -a "$_ROOTFS_TYPE" != "nfs" -a "$_ROOTFS_TYPE" != "romfs" -a "$_ROOTFS_PASSNO" != 0 -a -e $_ROOTFS_DEVICE ]; then
368 show "Checking root filesystem"; started
369 initlog -c "fsck -C -T -a $fsckoptions /"
373 # A return of 4 or higher means there were serious problems.
374 if [ $rc -gt 3 ]; then
375 [ -e /proc/splash ] && echo "verbose" > /proc/splash
376 # don't use '\n' in nls macro !
379 nls "*** An error occurred during the file system check."
380 nls "*** Dropping you to a shell; the system will reboot"
381 nls "*** when you leave the shell."
384 PS1="`nls '(Repair filesystem)# '`"; export PS1
385 [ "$SELINUX" = "1" ] && disable_selinux
386 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
392 run_cmd "Unmounting file systems" umount -a
393 mount -n -o remount,ro /
394 run_cmd "Automatic reboot in progress" reboot
395 # A return of 2 or 3 means that filesystem was repaired but we need
397 elif [ "$rc" = "2" -o "$rc" = "3" ]; then
398 [ -e /proc/splash ] && echo "verbose" > /proc/splash
400 nls "*** Filesystem was repaired but system needs to be"
401 nls "*** rebooted before mounting it."
402 nls "*** REBOOTING ***"
405 run_cmd "Unmounting file systems" umount -a
406 mount -n -o remount,ro /
407 run_cmd "Automatic reboot in progress" reboot
408 elif [ "$rc" = "1" ]; then
413 # Check for arguments
414 if strstr "$cmdline" nopnp; then
420 # set up pnp and kernel pnp
421 if [ -n "$PNP" ]; then
422 if ! is_no "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
423 run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf
425 if ! is_no "$RUN_KERNELPNP"; then
426 /sbin/modprobe -k isa-pnp 2> /dev/null
427 if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then
428 show "Setting up ISA PNP devices (kernelspace pnp)"; busy
429 grep -v "^#" /etc/isapnp/isapnp-kernel.conf 2>/dev/null >/proc/isapnp && (deltext; ok) || (deltext; fail)
434 # Remount the root filesystem read-write
435 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
437 # Update quotas if fsck was run on /
438 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
439 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vnug /
442 # Clean up SELinux labels
443 if [ -n "$SELINUX" ]; then
444 for file in /etc/mtab /etc/cryptomtab /etc/ld.so.cache ; do
445 [ -r $file ] && restorecon $file >/dev/null 2>&1
449 if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then
450 # XXX, this must be probably done after random is initialized from /var/run/random-seed
451 show "Starting disk encryption using the RNG"
452 init_crypto 1 && ok || fail
455 # Start logging console output since we have all /dev stuff setup
456 if [ "$RC_BOOTLOG" ]; then
461 # Remove stale backups
462 rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~
464 # Remove /etc/nologin when starting system
465 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
467 if ! is_no "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
468 show "Enabling Delay Login"; busy
470 nls "System bootup in progress - please wait" >> /etc/nologin
472 chmod 644 /etc/nologin
473 cp -fp /etc/nologin /etc/nologin.boot
477 # The root filesystem is now read-write, so we can now log via
478 # syslog() directly...
479 if [ -n "$IN_INITLOG" ]; then
483 if ! is_yes "$VSERVER"; then
486 [ -f /etc/cryptomtab ] && :>/etc/cryptomtab
488 # Enter root, /proc, /sys and other into mtab.
491 [ -f /proc/bus/usb/devices ] && mount -f -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb
493 if grep -q sysfs /proc/mounts 2>/dev/null; then
494 mount -f -t sysfs sysfs /sys
495 if grep -q securityfs /proc/mounts 2>/dev/null ; then
496 mount -f -t securityfs securityfs /sys/kernel/security
500 if grep -q selinuxfs /proc/mounts 2>/dev/null; then
501 mount -f -t selinuxfs selinuxfs /selinux
504 if grep -q cpuset /proc/mounts 2>/dev/null; then
505 mount -f -t cpuset none /dev/cpuset
508 if [ ! -f /proc/modules ]; then
510 elif ! strstr "$cmdline" nomodules; then
517 # Adjust symlinks as necessary in /boot to keep system services from
518 # spewing messages about mismatched System maps and so on.
519 if ! is_no "$SET_SLINKS"; then
520 if [ -L /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
521 ln -s -f System.map-$uname_r /boot/System.map
523 if [ ! -e /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
524 ln -s -f System.map-$uname_r /boot/System.map
528 # Run depmod if RUN_DEPMOD != "no" and:
529 # a) user requested or RUN_DEPMOD="";
530 # b) modules.dep is missing
531 if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
532 if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then
533 run_cmd "Finding module dependencies" depmod -a
534 elif [ "$RUN_DEPMOD" = "ifmissing" ] && [ ! -f /lib/modules/$uname_r/modules.dep ]; then
535 run_cmd "Finding module dependencies" depmod -A
540 if [ -f /proc/sys/kernel/modprobe ]; then
541 if [ -n "$USEMODULES" ]; then
542 sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
544 # We used to set this to NULL, but that causes
545 # 'failed to exec' messages"
546 sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
550 # Load usb storage here, to match most other things
551 if [ -n "$needusbstorage" ]; then
552 modprobe -k usb-storage >/dev/null 2>&1
555 # Load firewire devices
556 if ! strstr "$cmdline" nofirewire; then
557 aliases=$(/sbin/modprobe -c | awk '/^alias ieee1394-controller/ { print $3 }')
558 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
559 for alias in $aliases ; do
560 [ "$alias" = "off" ] && continue
561 run_cmd "$(nls 'Initializing firewire controller') ($alias)" /sbin/modprobe $alias
563 LC_ALL=C grep -E "SBP2" /proc/bus/ieee1394/devices 2>/dev/null && /sbin/modprobe -s sbp2 > /dev/null 2>&1
567 # Load sound modules if they need persistent DMA buffers
568 if [ $(kernelverser) = "002006" ]; then
569 MODULES_CONF=/etc/modprobe.conf
570 elif [ -r /etc/modules.conf ]; then
571 MODULES_CONF=/etc/modules.conf
573 MODULES_CONF=/etc/conf.modules
576 if grep -q "^options sound dmabuf=1" "$MODULES_CONF" 2>/dev/null ; then
578 alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
579 if [ -n "$alias" -a "$alias" != "off" ] ; then
580 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
583 alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound-slot-0[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
584 if [ -n "$alias" -a "$alias" != "off" ] ; then
585 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
593 if [ -x /sbin/multipath ]; then
594 # first make nodes that were discarded due (possible) new /dev mount
596 /sbin/dmsetup mknodes
597 modprobe -s dm-multipath
598 run_cmd "Activating dm-multipath" /sbin/multipath -v 0
599 /sbin/dmsetup ls --target multipath --exec '/sbin/kpartx -a -p p'
602 if [ -x /sbin/dmraid ]; then
603 run_cmd "Activating ATARAID devices" /sbin/dmraid -ay
606 # Find and activate volume groups:
608 if [ -x /sbin/evms_activate ]; then
609 if [ "$(kernelverser)" -lt "002006" ]; then
610 # Linux 2.4 core modules
611 modprobe -s -k evms > /dev/null 2>&1
612 modprobe -s -k evms_passthru > /dev/null 2>&1
613 modprobe -s -k ldev_mgr > /dev/null 2>&1
614 modprobe -s -k dos_part > /dev/null 2>&1
616 # Linux 2.6 core module
617 modprobe -s -k evmscore > /dev/null 2>&1
620 is_yes "$EVMS_GUID_PTABLE" && modprobe -s -k gpt_part >/dev/null 2>&1
621 is_yes "$EVMS_LVM" && modprobe -s -k lvm_vge >/dev/null 2>&1
622 is_yes "$EVMS_AIX" && modprobe -s -k AIXlvm_vge >/dev/null 2>&1
623 is_yes "$EVMS_OS2" && modprobe -s -k os2lvm_vge >/dev/null 2>&1
624 run_cmd "Discovering EVMS volumes" /sbin/evms_activate
625 if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then
626 # Link nodes for compatibility with LVM
627 if [ "$(echo /dev/evms/lvm/*)" != '/dev/evms/lvm/*' ] ; then
628 ln -s /dev/evms/lvm/* /dev
633 # LVM (keep in sync with LVM starting after RAID run!)
634 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
635 lvmversion=$(/sbin/vgchange --version 2>/dev/null | awk '{gsub("vgchange: Logical Volume Manager ",""); gsub("LVM version: ",""); gsub(/\..*/,"");print $1; exit}')
636 if [ "$lvmversion" = "1" ] ; then
637 modprobe -s -k lvm-mod >/dev/null 2>&1
639 elif [ "$lvmversion" = "2" ] ; then
640 modprobe -s -k dm-mod >/dev/null 2>&1
641 lvmignorelock="--ignorelockingfailure"
643 modprobe -s -k lvm-mod >/dev/null 2>&1
644 # device mapper (2.5+ and patched 2.4)
645 modprobe -s -k dm-mod >/dev/null 2>&1
649 run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelock
650 run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmignorelock
651 if [ "$lvmversion" = "2" ]; then
653 # display VG statistics
659 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ] || [ -f /etc/raidtab ]; then
660 modprobe -s md >/dev/null 2>&1
661 if [ -f /proc/mdstat ]; then
665 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
666 if (grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null); then
667 run_cmd "Starting up RAID devices" /sbin/mdadm --assemble --scan --auto=yes
669 [ "$rc" -eq 0 ] && goraidtab=0 && golvm=1
673 if [ -f /etc/raidtab -a "$goraidtab" -eq 1 ]; then
674 for i in $(awk '!/^#/ && /raiddev/{print $2}' /etc/raidtab 2>/dev/null); do
676 RAIDDEV=$(basename $i)
677 RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat 2>/dev/null)
678 show "Starting up RAID device %s" $RAIDDEV
680 if [ -z "$RAIDSTAT" ]; then
681 # Try raidstart first...if that fails then
682 # fall back to raid0run and if that fails too
683 # fall back to raidadd, raidrun.
685 if [ -x /sbin/raidstart ]; then
689 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
693 if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
698 if [ $RESULT -gt 0 ]; then
710 # A non-zero return means there were problems
711 if [ $rc -gt 0 ]; then
712 [ -e /proc/splash ] && echo "verbose" > /proc/splash
713 show "Starting up RAID devices"; fail
716 nls "*** An error occurred during the RAID startup."
717 nls "*** Dropping you to a shell; the system will reboot"
718 nls "*** when you leave the shell."
721 PS1="$(nls '(RAID Repair)# ')"; export PS1
722 [ "$SELINUX" = "1" ] && disable_selinux
723 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
729 run_cmd "Unmounting file systems" umount -a
730 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
731 run_cmd "Automatic reboot in progress" reboot
733 # LVM on RAID (keep in sync with LVM setting few lines above)
734 if [ "$golvm" -eq "1" ]; then
735 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
736 run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmignorelock
737 run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmignorelock
738 [ "$lvmversion" = "2" ] && /sbin/vgmknodes
741 show "Starting up RAID devices"; ok
747 if [ -z "$fastboot" ] && ! strstr "$cmdline" nofsck; then
748 rc_splash "fsck start"
749 show "Checking filesystems"; started
750 initlog -c "fsck -C -T -R -A -a -P $fsckoptions"
754 # A return of 2 or higher means there were serious problems
755 if [ $rc -gt 1 ]; then
756 [ -e /proc/splash ] && echo "verbose" > /proc/splash
759 nls "*** An error occurred during the file system check."
760 nls "*** Dropping you to a shell; the system will reboot"
761 nls "*** when you leave the shell."
764 PS1="$(nls '(Repair filesystem)# ')"; export PS1
765 [ "$SELINUX" = "1" ] && disable_selinux
766 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
772 run_cmd "Unmounting file systems" umount -a
773 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
774 run_cmd "Automatic reboot in progress" reboot
775 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
778 rc_splash "fsck stop"
781 # Mount all other filesystems (except for NFS and /proc, which is already
782 # mounted). Contrary to standard usage,
783 # filesystems are NOT unmounted in single user mode.
785 run_cmd "Mounting local filesystems" mount -a -t nonfs,nfs4,smbfs,ncpfs,proc,cifs -O no_netdev
787 # now we have /usr mounted, recheck if we have gettext and tput available.
788 if is_no "$TPUT"; then
794 # Now do some workaround - encrypted filesystems couldn't have been fsck-ed
795 # before mount - that's where the password is entered.
796 # mount is buggy - when remounting loopback filesystem, loop=XXX
797 # option is removed from /etc/mtab
798 if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then
799 show "Checking encrypted filesystems"; started
800 LOOPLIST="$(LC_ALL=C awk '
801 FILENAME=="/proc/mounts" {
804 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ {
805 if ($2 in TAB){print TAB[$2];}
807 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
808 if ($2 in TAB){print TAB[$2];}
809 sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4);
810 cmd="mount " $2 " -o remount," $4;
813 ' /proc/mounts /etc/fstab)"
814 initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST"
817 # A return of 2 or higher means there were serious problems.
818 if [ $rc -gt 1 ]; then
819 [ -e /proc/splash ] && echo "verbose" > /proc/splash
822 nls "*** An error occurred during the file system check."
823 nls "*** Dropping you to a shell; the system will reboot"
824 nls "*** when you leave the shell."
827 PS1="$(nls '(Repair filesystem)# ')"; export PS1
828 [ "$SELINUX" = "1" ] && disable_selinux
829 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
835 run_cmd "Unmounting file systems" umount -a
836 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
837 run_cmd "Automatic reboot in progress" reboot
838 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
842 show "Remounting encrypted filesystems back in rw mode"; busy
844 FILENAME=="/proc/mounts" {
847 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
848 sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4);
849 cmd="mount " $2 " -o remount," $4;
852 ' /proc/mounts /etc/fstab
856 # /var/log should be writable now, so start saving the boot output
857 if [ "$RC_BOOTLOG" ]; then
858 echo > /var/log/boot.msg
862 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
863 run_cmd "Checking filesystem quotas" /sbin/quotacheck -vnugRa
867 if [ -x /sbin/quotaon ]; then
868 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug
871 # Turn on process accounting
872 if [ -x /etc/rc.d/rc.acct ]; then
873 /etc/rc.d/rc.acct start
876 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
877 if is_yes "$TIME_SETUP_DELAYED" && [ -e /dev/rtc ]; then
878 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
879 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
883 # Initialize the serial ports
884 if [ -f /etc/rc.d/rc.serial ]; then
885 . /etc/rc.d/rc.serial
888 if [ -f /proc/sys/kernel/panic -a -n "$PANIC_REBOOT_TIME" -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
889 show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy
890 if (sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1); then ok; else fail; fi
893 # ... and here finish configuring parameters
894 /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
896 # /var/log should be writable now, so start saving the boot output
897 if [ "$RC_BOOTLOG" ]; then
898 echo > /var/log/boot.msg
906 [ -n "$SELINUX" ] && [ -f /.autorelabel ] && relabel_selinux
909 rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff
912 # /usr could be still not mounted if it is on NFS.
913 for afile in /var/lock/* /var/run/*; do
915 if [ -d "$afile" ]; then
920 echo $afile/* | xargs rm -rf
924 [ "$bafile" != "hwprofile" ] && rm -f $afile 2> /dev/null
929 rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \
930 /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.*
931 rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \
932 /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \
933 /tmp/scrollkeeper-* /tmp/ssh-*
937 if ! is_no "$NEED_XFILES"; then
940 chown root:utmp /var/run/utmpx /var/log/wtmpx
941 chmod 0664 /var/run/utmpx /var/log/wtmpx
945 chown root:utmp /var/run/utmp /var/log/wtmp
946 chmod 0664 /var/run/utmp /var/log/wtmp
950 if is_yes "$CLEAN_TMP"; then
951 # XXX LC_ALL needed here
952 rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
955 # System protected dirs
956 mkdir -m 1777 -p /tmp/.ICE-unix > /dev/null 2>&1
957 chown root:root /tmp/.ICE-unix
958 [ -n "$SELINUX" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1
960 if ! is_yes "$VSERVER"; then
961 run_cmd "Enabling swap space" /bin/true
962 # Right, now turn on swap in case we swap to files
963 swapon -a >/dev/null 2>&1
965 # If a SCSI tape has been detected, load the st module unconditionally
966 # since many SCSI tapes don't deal well with st being loaded and unloaded
967 if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then
968 if grep -qv ' 9 st' /proc/devices 2>/dev/null; then
969 if [ -n "$USEMODULES" ] ; then
970 # Try to load the module. If it fails, ignore it...
971 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
976 # Now that we have all of our basic modules loaded and the kernel going,
977 # let's dump the syslog ring somewhere so we can find it later
978 dmesg > /var/log/dmesg
980 while [ $i -ge 0 ]; do
981 if [ -f /var/log/dmesg.$i ]; then
982 chmod 0600 /var/log/dmesg.$i
983 mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1))
987 cp -f /var/log/dmesg /var/log/dmesg.0
988 chmod 0600 /var/log/dmesg /var/log/dmesg.0
991 kill -TERM $(/sbin/pidof getkey) >/dev/null 2>&1
994 # extra check if the background process we just spawned is still running,
995 # as in case of vserver bootup it finishes quite instantly.
996 if ! is_no "$RC_PROMPT" && [ -d /proc/$! ]; then
997 /sbin/getkey -c 5 i && touch /var/run/confirm