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 . /lib/rc-scripts/functions
44 if [ "$modprobe_c_cache" ]; then
45 echo "$modprobe_c_cache"
48 modprobe_c_cache=$(modprobe -c)
52 local _d selinuxfs _t _r
54 while read _d selinuxfs _t _r; do
55 [ "$_t" = "selinuxfs" ] && break
57 echo "*** Warning -- SELinux is active"
58 echo "*** Disabling security enforcement for system recovery."
59 echo "*** Run 'setenforce 1' to reenable."
60 echo "0" > $selinuxfs/enforce
64 local _d selinuxfs _t _r
66 while read _d selinuxfs _t _r; do
67 [ "$_t" = "selinuxfs" ] && break
70 *** Warning -- SELinux relabel is required. ***
71 *** Disabling security enforcement. ***
72 *** Relabeling could take a very long time, ***
73 *** depending on file system size. ***
75 echo "0" > $selinuxfs/enforce
76 /sbin/fixfiles -F relabel > /dev/null 2>&1
78 echo "*** Enabling security enforcement. ***"
79 echo $SELINUX > $selinuxfs/enforce
82 # Remove duplicate entries from mtab (for vserver guest use only)
83 clean_vserver_mtab() {
85 while read device mountpoint line; do
86 grep -qs "$mountpoint" /etc/mtab.clean || \
87 echo "$device $mountpoint $line" >> /etc/mtab.clean
89 cat /etc/mtab.clean > /etc/mtab
93 # Loads modules from /etc/modules, /etc/modules.X.Y and /etc/modules.X.Y.Z
94 load_kernel_modules() {
96 local _x _y _z v v1 old_IFS kernel kerneleq
100 # strip _* or -* from versions like: "2.6.25_vanilla-1", "2.6.25-1"
113 # Loop over every line in modules file
115 grep -hvE '^(#|[[:blank:]]*$)' /etc/$modules_file /etc/$modules_file.$kernel /etc/$modules_file.$kerneleq 2>/dev/null
116 echo '' # make sure there is a LF at the end
117 ) | while read module args; do
118 [ -z "$module" ] && continue
121 show "Loading %s kernel module(s)" "$module"
123 modprobe -s $module -- $args && ok || fail
128 show "Checking root filesystem"; started
129 initlog -c "fsck -C -T -a $fsckoptions /"
132 # A return of 4 or higher means there were serious problems.
133 if [ $rc -gt 3 ]; then
134 [ -e /proc/splash ] && echo "verbose" > /proc/splash
135 # don't use '\n' in nls macro !
138 nls "*** An error occurred during the file system check."
139 nls "*** Dropping you to a shell; the system will reboot"
140 nls "*** when you leave the shell."
143 PS1="$(nls '(Repair filesystem)# ')"; export PS1
144 [ "$SELINUX" = "1" ] && disable_selinux
145 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
151 run_cmd "Unmounting file systems" umount -a
152 mount -n -o remount,ro /
153 run_cmd "Automatic reboot in progress" reboot
154 # A return of 2 or 3 means that filesystem was repaired but we need
156 elif [ "$rc" = "2" -o "$rc" = "3" ]; then
157 [ -e /proc/splash ] && echo "verbose" > /proc/splash
159 nls "*** Filesystem was repaired but system needs to be"
160 nls "*** rebooted before mounting it."
161 nls "*** REBOOTING ***"
164 run_cmd "Unmounting file systems" umount -a
165 mount -n -o remount,ro /
166 run_cmd "Automatic reboot in progress" reboot
167 elif [ "$rc" = "1" ]; then
172 # boot logging to /var/log/boot.log. install showconsole package to get it.
173 if ! is_no "$RC_BOOTLOG" && [ -x /sbin/blogd ]; then
179 if ! is_yes "$VSERVER" ; then
181 is_fsmounted tmpfs /run || mount -n -t tmpfs run /run
184 # we need /proc mounted before everything
185 is_fsmounted proc /proc || mount -n /proc || mount -n -o gid=17,hidepid=2 -t proc /proc /proc
188 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
190 # Only read this once.
191 cmdline=$(cat /proc/cmdline)
192 if strstr "$cmdline" "pld.no-upstart" ; then
196 # sysfs is also needed before any other things (under kernel > 2.5)
197 if grep -q sysfs /proc/filesystems 2>/dev/null; then
198 is_fsmounted sysfs /sys || mount -n -o gid=17 -t sysfs sysfs /sys
199 if grep -q securityfs /proc/filesystems 2>/dev/null; then
200 mount -n -o gid=17 -t securityfs securityfs /sys/kernel/security
205 if grep -q selinuxfs /proc/filesystems 2>/dev/null && ! is_fsmounted selinuxfs /selinux; then
206 mount -n -o gid=17 -t selinuxfs selinuxfs /selinux
209 # PLD Linux LiveCD support
210 if [ -x /etc/rc.d/rc.live ]; then
214 # Choose Hardware profile
215 if [ -f /etc/sysconfig/hwprof ]; then
216 . /etc/sysconfig/hwprof
217 if is_yes "${HWPROFILES}" && [ -x /sbin/hwprofile -a -d /etc/sysconfig/hwprofiles/data ]; then
218 mount -n / -o rw,remount
220 mount -n / -o ro,remount
224 # Disable splash when requested
225 is_no "$BOOT_SPLASH" && [ -e /proc/splash ] && echo "0" > /proc/splash
227 # Check SELinux status
228 selinuxfs=$(awk '/ selinuxfs / { print $2 }' /proc/mounts 2> /dev/null)
230 if [ -n "$selinuxfs" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then
231 if [ -r $selinuxfs/enforce ] ; then
232 SELINUX=$(cat $selinuxfs/enforce)
234 # assume enforcing if you can't read it
239 if [ -x /sbin/restorecon ] && is_fsmounted tmpfs /dev; then
240 /sbin/restorecon -R /dev 2>/dev/null
243 [ -z "${CONSOLETYPE}" ] && CONSOLETYPE="$(/sbin/consoletype)"
245 if [ "$CONSOLETYPE" = "vt" -a -x /sbin/setsysfont ]; then
251 # Print welcome message
252 nls "\t\t\t%sPowered by %sPLD Linux Distribution%s" "$(termput setaf $CPOWEREDBY)" "$(termput setaf $CPLD)" "$(termput op)"
253 if ! is_no "$RC_PROMPT"; then
254 nls -n "\t\t Press %sI%s to enter interactive startup" "$(termput setaf $CI)" "$(termput op)"
259 if [ -z "${HOSTNAME}" ]; then
260 show "$(nls 'Host:') $(hostname)"; ok
262 run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME}
265 # Set the NIS domain name
266 if [ -n "$NISDOMAIN" ]; then
267 run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN
272 if ! is_yes "$VSERVER"; then
273 # Set console loglevel
274 if [ -n "$CONSOLE_LOGLEVEL" ]; then
275 dmesg -n $CONSOLE_LOGLEVEL
278 if ! is_no "$START_UDEV" && [ -x /sbin/start_udev ] && [[ "$container" != lxc* ]]; then
279 is_fsmounted devtmpfs /dev || mount -n -t devtmpfs devtmpfs /dev
280 load_kernel_modules modules.preudev
282 [ -x /sbin/initctl ] && /sbin/initctl -q start udev
283 elif [ -x /lib/firmware/firmware-loader.sh ]; then
284 /sbin/sysctl -e -w kernel.hotplug=/lib/firmware/firmware-loader.sh > /dev/null 2>&1
287 # Unmount the initrd, if necessary
288 if grep -q /initrd /proc/mounts 2>/dev/null && ! grep -q /initrd/loopfs /proc/mounts 2>/dev/null; then
289 umount /initrd/dev 2>/dev/null
291 /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1
294 # Start logging console output since we have all /dev stuff setup
295 if [ "$RC_BOOTLOG" ]; then
299 # Configure Linux kernel (initial configuration, some required modules still
301 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
303 # Check if timezone definition is available
304 if [ -e /etc/localtime ] && [ -e /dev/rtc -o -e /dev/rtc0 ] ; then
305 if run_cmd "$(nls 'Setting clock')" hwclock --hctosys; then
306 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
309 TIME_SETUP_DELAYED=yes
313 if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then
314 # XXX might need modules dep
315 # Device mapper & related initialization
316 if ! grep -qF device-mapper /proc/devices; then
320 . /etc/rc.d/init.d/cryptsetup
321 show "Starting disk encryption"
324 [ $delay_cryptsetup = 0 ] && ok || fail
328 run_cmd "Activating swap partitions" swapon -a -e
330 # Initialize USB controllers
332 if ! strstr "$cmdline" "nousb" && ! is_fsmounted usbfs /proc/bus/usb; then
333 aliases=$(modprobe_c | awk '/^alias[\t ]+usb-controller/ { print $3 }')
334 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
336 for alias in $aliases ; do
337 [ "$alias" = "off" ] && continue
338 run_cmd "$(nls 'Initializing USB controller') ($alias)" modprobe -s $alias
340 [ $? -eq 0 -a -n "$aliases" ] && usb=1
342 if grep -iq "usb" /proc/devices 2>/dev/null ; then
347 if [ "$usb" = "1" -a -d /proc/bus/usb ] && ! is_fsmounted usbfs /proc/bus/usb ; then
348 run_cmd "Mounting USB filesystem" mount -n -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb
352 if [ "$usb" = "1" ]; then
353 needusbstorage=$(cat /proc/bus/usb/devices 2>/dev/null | grep -e "^I.*Cls=08" 2>/dev/null)
354 if [ "$(kernelverser)" -lt "002006" ]; then
355 grep -Fq 'hid' /proc/bus/usb/drivers 2>/dev/null || run_cmd "Initializing USB HID interface" modprobe -s hid
356 mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02" 2>/dev/null)
357 kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01" 2>/dev/null)
358 if [ -n "$kbdoutput" ]; then
359 run_cmd "Initializing USB keyboard" modprobe -s keybdev
361 if [ -n "$mouseoutput" ]; then
362 run_cmd "Initializing USB mouse" modprobe -s mousedev
367 # Setup hdparm thing (if exists and is needed)
368 if ! strstr "$cmdline" nohdparm; then
369 [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
372 if [ -f /fastboot ] || strstr "$cmdline" "fastboot"; then
378 if [ -f /fsckoptions ]; then
379 fsckoptions=$(cat /fsckoptions)
384 if [ -f /forcefsck ]; then
385 fsckoptions="-f $fsckoptions"
387 # Obey the fs_passno setting for / (see fstab(5))
389 # - make sure we have at least 6 fields
390 _ROOTFS_PASSNO=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $6}' /etc/fstab)
394 _ROOTFS_DEVICE=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $1}' /etc/fstab)
395 _ROOTFS_TYPE=$(awk '$2 == "/" && $3 != "rootfs" { print $3 }' /proc/mounts 2>/dev/null)
397 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
401 # Check for arguments
402 if strstr "$cmdline" nopnp; then
408 # set up pnp and kernel pnp
409 if [ -n "$PNP" ]; then
410 if ! is_no "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
411 run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf
413 if ! is_no "$RUN_KERNELPNP"; then
415 if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then
416 show "Setting up ISA PNP devices (kernelspace pnp)"; busy
417 grep -v "^#" /etc/isapnp/isapnp-kernel.conf 2>/dev/null >/proc/isapnp && (deltext; ok) || (deltext; fail)
422 _ROOTFS_RO=$(awk '($1 !~ /^#/ && $2 == "/" && ($4 == "ro" || $4 ~ /,ro$/ || $4 ~ /^ro,/ || $4 ~ /,ro,/ ) && NF >= 6) { print "ro" }' /etc/fstab)
423 # Remount the root filesystem read-write
424 if [ -z "$_ROOTFS_RO" ]; then
425 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
428 # Update quotas if fsck was run on /
429 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
430 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vnug /
433 # Clean up SELinux labels
434 if [ -n "$SELINUX" ]; then
435 for file in /etc/mtab /etc/cryptomtab /etc/ld.so.cache; do
436 [ -r $file ] && restorecon $file >/dev/null 2>&1
440 if [ "$delay_cryptsetup" != 0 ]; then
441 show "Starting disk encryption using the RNG"
444 [ $delay_cryptsetup = 0 ] && ok || fail
447 # Start logging console output since we have all /dev stuff setup
448 if [ "$RC_BOOTLOG" ]; then
453 # Remove stale backups
454 rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~ >/dev/null 2>&1
456 # Remove /etc/nologin when starting system
457 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
459 if ! is_no "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
460 show "Enabling Delay Login"; busy
462 nls "System bootup in progress - please wait" >> /etc/nologin
464 chmod 644 /etc/nologin
465 cp -fp /etc/nologin /etc/nologin.boot
469 # The root filesystem is now read-write, so we can now log via
470 # syslog() directly...
471 if [ -n "$IN_INITLOG" ]; then
475 if ! is_yes "$VSERVER"; then
478 [ -f /etc/cryptomtab ] && > /etc/cryptomtab
480 # Enter root, /proc, /sys and other into mtab.
481 mount -f / 2> /dev/null
482 mount -f /proc 2> /dev/null
483 if is_fsmounted devtmpfs /dev; then
484 mount -f -t devtmpfs devtmpfs /dev 2> /dev/null
486 if is_fsmounted tmpfs /run; then
487 mount -f -t tmpfs run /run 2> /dev/null
490 if is_fsmounted usbfs /proc/bus/usb; then
491 mount -f -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb 2> /dev/null
494 if is_fsmounted sysfs /sys; then
495 mount -f -t sysfs sysfs /sys 2> /dev/null
496 if is_fsmounted securityfs /sys/kernel/security ; then
497 mount -f -t securityfs securityfs /sys/kernel/security 2> /dev/null
501 if is_fsmounted selinuxfs /selinux; then
502 mount -f -t selinuxfs selinuxfs /selinux 2> /dev/null
505 emit --no-wait root-filesystem
506 emit --no-wait virtual-filesystems
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 -s usb-storage
555 # Load firewire devices
556 if ! strstr "$cmdline" nofirewire; then
557 aliases=$(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)" modprobe $alias
563 grep -E "SBP2" /proc/bus/ieee1394/devices 2>/dev/null && modprobe -s sbp2
567 # Load sound modules if they need persistent DMA buffers
568 if modprobe_c | grep -q "^options sound dmabuf=1"; then
570 alias=$(modprobe_c | grep -sE "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
571 if [ -n "$alias" -a "$alias" != "off" ] ; then
572 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
575 alias=$(modprobe_c | grep -sE "^alias[[:space:]]+sound-slot-0[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
576 if [ -n "$alias" -a "$alias" != "off" ] ; then
577 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
583 if ! use_upstart; then
584 load_kernel_modules modules
585 for f in /etc/modules-load.d/*.conf; do
586 # already loaded by implicit "modules" load
587 [ "${f##*/}" = "modules.conf" ] && continue
589 [ -r $f ] || continue
590 load_kernel_modules ${f##/etc/}
594 if [ -x /sbin/multipath ] && ! is_no "$DM_MULTIPATH"; then
595 # first make nodes that were discarded due (possible) new /dev mount
597 /sbin/dmsetup mknodes
598 modprobe -s dm-multipath
599 run_cmd "Activating dm-multipath" /sbin/multipath -v 0
600 /sbin/dmsetup ls --target multipath --exec '/sbin/kpartx -a -p p'
603 if [ -x /sbin/dmraid ]; then
604 run_cmd "Activating ATARAID devices" /sbin/dmraid -ay
607 # Find and activate volume groups:
609 if [ -x /sbin/evms_activate ]; then
610 if [ "$(kernelverser)" -lt "002006" ]; then
611 # Linux 2.4 core modules
613 modprobe -s evms_passthru
617 # Linux 2.6 core module
621 is_yes "$EVMS_GUID_PTABLE" && modprobe -s gpt_part
622 is_yes "$EVMS_LVM" && modprobe -s lvm_vge
623 is_yes "$EVMS_AIX" && modprobe -s AIXlvm_vge
624 is_yes "$EVMS_OS2" && modprobe -s os2lvm_vge
625 run_cmd "Discovering EVMS volumes" /sbin/evms_activate
626 if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then
627 # Link nodes for compatibility with LVM
628 if [ "$(echo /dev/evms/lvm/*)" != '/dev/evms/lvm/*' ] ; then
629 ln -s /dev/evms/lvm/* /dev
634 # LVM (keep in sync with LVM starting after RAID run!)
635 if ! is_no "$LVM2" && [ -x /sbin/vgscan -a -x /sbin/vgchange ] || is_yes "$EVMS_LVM"; then
636 if is_no "$LVM2"; then
637 lvmversion=$(LC_ALL=C /sbin/vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}')
641 if [ "$lvmversion" = "1" ] ; then
645 elif [ "$lvmversion" = "2" ] ; then
647 lvmignorelocking="--ignorelockingfailure"
648 lvmsysinit="--sysinit"
651 # device mapper (2.5+ and patched 2.4)
657 run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelocking
658 run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmsysinit
659 if [ "$lvmversion" = "2" ]; then
660 /sbin/vgmknodes $lvmignorelocking
661 # display VG statistics
662 /sbin/vgdisplay -s $lvmignorelocking
666 if [ "$delay_cryptsetup" != 0 ]; then
667 show "Starting disk encryption"
670 [ $delay_cryptsetup = 0 ] && ok || fail
674 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ] || [ -f /etc/raidtab ]; then
676 if [ -f /proc/mdstat ]; then
680 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
681 if grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null; then
682 show "Starting up RAID devices"; busy
683 /sbin/mdadm --assemble --scan --auto=yes
685 if [ "$rc" -eq 0 -o "$rc" -eq 2 ]; then
686 # rc is used later, too so set sane value
698 if [ -f /etc/raidtab -a "$goraidtab" -eq 1 ]; then
699 for i in $(awk '!/^#/ && /raiddev/{print $2}' /etc/raidtab 2>/dev/null); do
701 RAIDDEV=$(basename $i)
702 RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat 2>/dev/null)
703 show "Starting up RAID device %s" $RAIDDEV
705 if [ -z "$RAIDSTAT" ]; then
706 # Try raidstart first...if that fails then
707 # fall back to raid0run and if that fails too
708 # fall back to raidadd, raidrun.
710 if [ -x /sbin/raidstart ]; then
714 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
718 if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
723 if [ $RESULT -gt 0 ]; then
735 # A non-zero return means there were problems
736 if [ $rc -gt 0 ]; then
737 [ -e /proc/splash ] && echo "verbose" > /proc/splash
738 show "Starting up RAID devices"; fail
741 nls "*** An error occurred during the RAID startup."
742 nls "*** Dropping you to a shell; the system will reboot"
743 nls "*** when you leave the shell."
746 PS1="$(nls '(RAID Repair)# ')"; export PS1
747 [ "$SELINUX" = "1" ] && disable_selinux
748 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
754 run_cmd "Unmounting file systems" umount -a
755 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
756 run_cmd "Automatic reboot in progress" reboot
758 # LVM on RAID (keep in sync with LVM setting few lines above)
759 if [ "$golvm" -eq "1" ]; then
760 if [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
761 run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmignorelocking
762 run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmsysinit
763 [ "$lvmversion" = "2" ] && /sbin/vgmknodes
766 show "Starting up RAID devices"; ok
772 if [ -z "$fastboot" ] && ! strstr "$cmdline" nofsck; then
773 rc_splash "fsck start"
774 show "Checking filesystems"; started
775 initlog -c "fsck -C -T -R -A -a -P $fsckoptions"
779 # A return of 2 or higher means there were serious problems
780 if [ $rc -gt 1 ]; then
781 [ -e /proc/splash ] && echo "verbose" > /proc/splash
784 nls "*** An error occurred during the file system check."
785 nls "*** Dropping you to a shell; the system will reboot"
786 nls "*** when you leave the shell."
789 PS1="$(nls '(Repair filesystem)# ')"; export PS1
790 [ "$SELINUX" = "1" ] && disable_selinux
791 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
797 run_cmd "Unmounting file systems" umount -a
798 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
799 run_cmd "Automatic reboot in progress" reboot
800 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
803 rc_splash "fsck stop"
806 # Mount all other filesystems (except for NFS and /proc, which is already
807 # mounted). Contrary to standard usage,
808 # filesystems are NOT unmounted in single user mode.
810 run_cmd "Mounting local filesystems" mount -a -t nonfs,nfs4,smbfs,ncpfs,proc,cifs -O no_netdev
812 # now we have /usr mounted, recheck if we have gettext and tput available.
813 if is_no "$TPUT"; then
819 # Now do some workaround - encrypted filesystems couldn't have been fsck-ed
820 # before mount - that's where the password is entered.
821 # mount is buggy - when remounting loopback filesystem, loop=XXX
822 # option is removed from /etc/mtab
823 if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then
824 show "Checking encrypted filesystems"; started
825 LOOPLIST="$(LC_ALL=C awk '
826 FILENAME=="/proc/mounts" {
829 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ {
830 if ($2 in TAB){print TAB[$2];}
832 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
833 if ($2 in TAB){print TAB[$2];}
834 sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4);
835 cmd="mount " $2 " -o remount," $4;
838 ' /proc/mounts /etc/fstab)"
839 initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST"
842 # A return of 2 or higher means there were serious problems.
843 if [ $rc -gt 1 ]; then
844 [ -e /proc/splash ] && echo "verbose" > /proc/splash
847 nls "*** An error occurred during the file system check."
848 nls "*** Dropping you to a shell; the system will reboot"
849 nls "*** when you leave the shell."
852 PS1="$(nls '(Repair filesystem)# ')"; export PS1
853 [ "$SELINUX" = "1" ] && disable_selinux
854 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
860 run_cmd "Unmounting file systems" umount -a
861 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
862 run_cmd "Automatic reboot in progress" reboot
863 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
867 show "Remounting encrypted filesystems back in rw mode"; busy
869 FILENAME=="/proc/mounts" {
872 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
873 sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4);
874 cmd="mount " $2 " -o remount," $4;
877 ' /proc/mounts /etc/fstab
881 # /var/log should be writable now, so start saving the boot output
882 if [ "$RC_BOOTLOG" ]; then
883 echo > /var/log/boot.log
887 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
888 run_cmd "Checking filesystem quotas" /sbin/quotacheck -vnugRa
892 if [ -x /sbin/quotaon ]; then
893 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug
896 emit --no-wait local-filesystems
898 # FIXME: this should be delayed until remote filesystems are mounted,
899 # especialy when /usr or other standard fs is remote
900 emit --no-wait filesystem
902 # Turn on process accounting
903 if [ -x /etc/rc.d/rc.acct ]; then
904 /etc/rc.d/rc.acct start
907 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
908 if is_yes "$TIME_SETUP_DELAYED" && [ -e /dev/rtc -o -e /dev/rtc0 ]; then
909 if run_cmd "$(nls 'Setting clock')" hwclock --hctosys; then
910 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
914 # Initialize the serial ports
915 if [ -f /etc/rc.d/rc.serial ]; then
916 . /etc/rc.d/rc.serial
919 if [ -f /proc/sys/kernel/panic -a -n "$PANIC_REBOOT_TIME" -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
920 show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy
921 # NOTE: you should use /etc/sysctl.conf instead
922 if sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1; then ok; else fail; fi
925 # ... and here finish configuring parameters
926 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
928 emit --no-wait root-filesystem
929 emit --no-wait virtual-filesystems
930 emit --no-wait local-filesystems
931 emit --no-wait filesystem
933 # /var/log should be writable now, so start saving the boot output
934 if [ "$RC_BOOTLOG" ]; then
935 echo > /var/log/boot.log
943 [ -n "$SELINUX" ] && [ -f /.autorelabel ] && relabel_selinux
946 rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff >/dev/null 2>&1
949 # /usr could be still not mounted if it is on NFS.
950 for afile in /var/lock/* /var/run/*; do
952 if [ -d "$afile" ]; then
957 echo $afile/* | xargs rm -rf
961 [ "$bafile" != "hwprofile" -a "$bafile" != "random-seed" ] && rm -f $afile 2> /dev/null
966 rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \
967 /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.*
968 rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \
969 /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \
970 /tmp/scrollkeeper-* /tmp/ssh-*
974 if ! is_no "$NEED_XFILES"; then
977 chown root:utmp /var/run/utmpx /var/log/wtmpx
978 chmod 0664 /var/run/utmpx /var/log/wtmpx
982 chown root:utmp /var/run/utmp /var/log/wtmp
983 chmod 0664 /var/run/utmp /var/log/wtmp
987 if is_yes "$CLEAN_TMP" && ! is_fsmounted tmpfs /tmp; then
988 LC_ALL=C rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
991 # System protected dirs
992 mkdir -m 1777 -p /tmp/.ICE-unix > /dev/null 2>&1
993 chown root:root /tmp/.ICE-unix
994 [ -n "$SELINUX" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1
996 if ! is_yes "$VSERVER"; then
997 run_cmd "Enabling swap space" true
998 # Right, now turn on swap in case we swap to files
999 swapon -a >/dev/null 2>&1
1000 emit --no-wait all-swaps
1002 # If a SCSI tape has been detected, load the st module unconditionally
1003 # since many SCSI tapes don't deal well with st being loaded and unloaded
1004 if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then
1005 if grep -qv ' 9 st' /proc/devices 2>/dev/null; then
1006 if [ -n "$USEMODULES" ] ; then
1007 # Try to load the module. If it fails, ignore it...
1008 insmod -p st >/dev/null 2>&1 && modprobe -s st
1013 # Now that we have all of our basic modules loaded and the kernel going,
1014 # let's dump the syslog ring somewhere so we can find it later
1015 dmesg --raw > /var/log/dmesg
1017 while [ $i -ge 0 ]; do
1018 if [ -f /var/log/dmesg.$i ]; then
1019 chmod 0600 /var/log/dmesg.$i
1020 mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1))
1024 cp -f /var/log/dmesg /var/log/dmesg.0
1025 chmod 0600 /var/log/dmesg /var/log/dmesg.0
1027 emit --no-wait all-swaps
1030 if ! is_no "$RC_PROMPT"; then
1032 pid=$(/sbin/pidof getkey)
1033 [ -n "$pid" -o -e /var/run/getkey_done ] && break
1036 [ -n "$pid" ] && kill -TERM "$pid" >/dev/null 2>&1
1040 # /proc extra check if the background process we just spawned is still running,
1041 # as in case of vserver bootup it finishes quite instantly.
1042 if ! is_no "$RC_PROMPT" && [ -d /proc/$! ]; then
1043 /sbin/getkey i && touch /var/run/confirm
1044 touch /var/run/getkey_done
1047 if ! is_no "$RC_PROMPT"; then
1048 rm -f /var/run/getkey_done
1052 emit --no-wait pld.sysinit-done