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 local _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 local _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() {
86 local _x _y _z v v1 old_IFS kernel kerneleq
90 # strip _* or -* from versions like: "2.6.25_vanilla-1", "2.6.25-1"
103 # Loop over every line in modules file
105 grep -hvE '^(#|[[:blank:]]*$)' /etc/modules /etc/modules.$kernel /etc/modules.$kerneleq 2>/dev/null
106 echo '' # make sure there is a LF at the end
107 ) | while read module args; do
108 [ -z "$module" ] && continue
111 modprobe -s $module -- $args
116 show "Checking root filesystem"; started
117 initlog -c "fsck -C -T -a $fsckoptions /"
120 # A return of 4 or higher means there were serious problems.
121 if [ $rc -gt 3 ]; then
122 [ -e /proc/splash ] && echo "verbose" > /proc/splash
123 # don't use '\n' in nls macro !
126 nls "*** An error occurred during the file system check."
127 nls "*** Dropping you to a shell; the system will reboot"
128 nls "*** when you leave the shell."
131 PS1="$(nls '(Repair filesystem)# ')"; export PS1
132 [ "$SELINUX" = "1" ] && disable_selinux
133 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
139 run_cmd "Unmounting file systems" umount -a
140 mount -n -o remount,ro /
141 run_cmd "Automatic reboot in progress" reboot
142 # A return of 2 or 3 means that filesystem was repaired but we need
144 elif [ "$rc" = "2" -o "$rc" = "3" ]; then
145 [ -e /proc/splash ] && echo "verbose" > /proc/splash
147 nls "*** Filesystem was repaired but system needs to be"
148 nls "*** rebooted before mounting it."
149 nls "*** REBOOTING ***"
152 run_cmd "Unmounting file systems" umount -a
153 mount -n -o remount,ro /
154 run_cmd "Automatic reboot in progress" reboot
155 elif [ "$rc" = "1" ]; then
160 # boot logging to /var/log/boot.log. install showconsole package to get it.
161 if [ -x /sbin/blogd ] && ! is_no "$RC_BOOTLOG"; then
167 if ! is_yes "$VSERVER" ; then
169 is_fsmounted tmpfs /run || mount -n -t tmpfs run /run
172 # we need /proc mounted before everything
173 is_fsmounted proc /proc || mount -n -o gid=17 -t proc /proc /proc
175 # Only read this once.
176 cmdline=$(cat /proc/cmdline)
177 if strstr "$cmdline" "pld.no-upstart" ; then
181 # sysfs is also needed before any other things (under kernel > 2.5)
182 if grep -q sysfs /proc/filesystems 2>/dev/null ; then
183 is_fsmounted sysfs /sys || mount -n -o gid=17 -t sysfs sysfs /sys
184 if grep -q securityfs /proc/filesystems 2>/dev/null ; then
185 mount -n -o gid=17 -t securityfs securityfs /sys/kernel/security
190 if grep -q selinuxfs /proc/filesystems 2>/dev/null && ! is_fsmounted selinuxfs /selinux; then
191 mount -n -o gid=17 -t selinuxfs selinuxfs /selinux
194 # PLD Linux LiveCD support
195 if [ -x /etc/rc.d/rc.live ]; then
199 # Choose Hardware profile
200 if [ -f /etc/sysconfig/hwprof ]; then
201 . /etc/sysconfig/hwprof
202 if is_yes "${HWPROFILES}" && [ -x /sbin/hwprofile -a -d /etc/sysconfig/hwprofiles/data ]; then
203 mount -n / -o rw,remount
205 mount -n / -o ro,remount
209 # Disable splash when requested
210 is_no "$BOOT_SPLASH" && [ -e /proc/splash ] && echo "0" > /proc/splash
212 # Check SELinux status
213 selinuxfs=$(awk '/ selinuxfs / { print $2 }' /proc/mounts 2> /dev/null)
215 if [ -n "$selinuxfs" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then
216 if [ -r $selinuxfs/enforce ] ; then
217 SELINUX=$(cat $selinuxfs/enforce)
219 # assume enforcing if you can't read it
224 if [ -x /sbin/restorecon ] && is_fsmounted tmpfs /dev; then
225 /sbin/restorecon -R /dev 2>/dev/null
228 [ -z "${CONSOLETYPE}" ] && CONSOLETYPE="$(/sbin/consoletype)"
230 if [ "$CONSOLETYPE" = "vt" -a -x /sbin/setsysfont ]; then
236 # Print welcome message
237 nls "\t\t\t%sPowered by %sPLD Linux Distribution%s" "$(termput setaf $CPOWEREDBY)" "$(termput setaf $CPLD)" "$(termput op)"
238 if ! is_no "$RC_PROMPT"; then
239 nls -n "\t\t Press %sI%s to enter interactive startup" "$(termput setaf $CI)" "$(termput op)"
244 if [ -z "${HOSTNAME}" ]; then
245 show "$(nls 'Host:') $(hostname)" ; ok
247 run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME}
250 # Set the NIS domain name
251 if [ -n "$NISDOMAIN" ]; then
252 run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN
257 if ! is_yes "$VSERVER"; then
258 # Set console loglevel
259 if [ -n "$CONSOLE_LOGLEVEL" ]; then
260 dmesg -n $CONSOLE_LOGLEVEL
263 if ! is_no "$START_UDEV" && [ -x /sbin/start_udev ]; then
265 [ -x /sbin/initctl ] && /sbin/initctl -q start udev
266 elif [ -x /lib/firmware/firmware-loader.sh ]; then
267 /sbin/sysctl -e -w kernel.hotplug=/lib/firmware/firmware-loader.sh > /dev/null 2>&1
270 # Unmount the initrd, if necessary
271 if grep -q /initrd /proc/mounts 2>/dev/null && ! grep -q /initrd/loopfs /proc/mounts 2>/dev/null; then
272 umount /initrd/dev 2>/dev/null
274 /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1
277 # Start logging console output since we have all /dev stuff setup
278 if [ "$RC_BOOTLOG" ]; then
282 # Configure Linux kernel (initial configuration, some required modules still
284 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
286 # Check if timezone definition is available
287 if [ -e /etc/localtime ] && [ -e /dev/rtc -o -e /dev/rtc0 ] ; then
288 if run_cmd "$(nls 'Setting clock')" hwclock --hctosys; then
289 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
292 TIME_SETUP_DELAYED=yes
296 if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then
297 # XXX might need modules dep
298 # Device mapper & related initialization
299 if ! grep -qF device-mapper /proc/devices; then
303 . /etc/rc.d/init.d/cryptsetup
304 show "Starting disk encryption"
307 [ $delay_cryptsetup = 0 ] && ok || fail
311 run_cmd "Activating swap partitions" swapon -a -e
313 # Initialize USB controllers
315 if ! strstr "$cmdline" "nousb" && ! is_fsmounted usbfs /proc/bus/usb ; then
316 aliases=$(/sbin/modprobe -c | awk '/^alias[\t ]+usb-controller/ { print $3 }')
317 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
318 /sbin/modprobe -s usbcore
319 for alias in $aliases ; do
320 [ "$alias" = "off" ] && continue
321 run_cmd "$(nls 'Initializing USB controller') ($alias)" /sbin/modprobe -s $alias
323 [ $? -eq 0 -a -n "$aliases" ] && usb=1
325 if grep -iq "usb" /proc/devices 2>/dev/null ; then
330 if [ "$usb" = "1" ] && ! is_fsmounted usbfs /proc/bus/usb ; then
331 run_cmd "Mounting USB filesystem" mount -n -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb
335 if [ "$usb" = "1" ]; then
336 needusbstorage=$(cat /proc/bus/usb/devices 2>/dev/null | grep -e "^I.*Cls=08" 2>/dev/null)
337 if [ "$(kernelverser)" -lt "002006" ]; then
338 grep -q 'hid' /proc/bus/usb/drivers 2>/dev/null || run_cmd "Initializing USB HID interface" modprobe hid 2> /dev/null
339 mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02" 2>/dev/null)
340 kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01" 2>/dev/null)
341 if [ -n "$kbdoutput" ]; then
342 run_cmd "Initializing USB keyboard" modprobe keybdev
344 if [ -n "$mouseoutput" ]; then
345 run_cmd "Initializing USB mouse" modprobe mousedev
350 # Setup hdparm thing (if exists and is needed)
351 if ! strstr "$cmdline" nohdparm; then
352 [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
355 if [ -f /fastboot ] || strstr "$cmdline" "fastboot"; then
361 if [ -f /fsckoptions ]; then
362 fsckoptions=$(cat /fsckoptions)
367 if [ -f /forcefsck ]; then
368 fsckoptions="-f $fsckoptions"
370 # Obey the fs_passno setting for / (see fstab(5))
372 # - make sure we have at least 6 fields
373 _ROOTFS_PASSNO=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $6}' /etc/fstab)
377 _ROOTFS_DEVICE=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $1}' /etc/fstab)
378 _ROOTFS_TYPE=$(awk '$2 == "/" && $3 != "rootfs" { print $3 }' /proc/mounts 2>/dev/null)
380 if [ -z "$fastboot" -a "$_ROOTFS_TYPE" != "aufs" -a "$_ROOTFS_TYPE" != "nfs" -a "$_ROOTFS_TYPE" != "romfs" -a "$_ROOTFS_TYPE" != "squashfs" -a "$_ROOTFS_PASSNO" != 0 -a -e $_ROOTFS_DEVICE ]; then
384 # Check for arguments
385 if strstr "$cmdline" nopnp; then
391 # set up pnp and kernel pnp
392 if [ -n "$PNP" ]; then
393 if ! is_no "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
394 run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf
396 if ! is_no "$RUN_KERNELPNP"; then
397 /sbin/modprobe isa-pnp 2> /dev/null
398 if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then
399 show "Setting up ISA PNP devices (kernelspace pnp)"; busy
400 grep -v "^#" /etc/isapnp/isapnp-kernel.conf 2>/dev/null >/proc/isapnp && (deltext; ok) || (deltext; fail)
405 _ROOTFS_RO=$(awk '($1 !~ /^#/ && $2 == "/" && ($4 == "ro" || $4 ~ /,ro$/ || $4 ~ /^ro,/ || $4 ~ /,ro,/ ) && NF >= 6) { print "ro" }' /etc/fstab)
406 # Remount the root filesystem read-write
407 if [ -z "$_ROOTFS_RO" ]; then
408 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
411 # Update quotas if fsck was run on /
412 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
413 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vnug /
416 # Clean up SELinux labels
417 if [ -n "$SELINUX" ]; then
418 for file in /etc/mtab /etc/cryptomtab /etc/ld.so.cache ; do
419 [ -r $file ] && restorecon $file >/dev/null 2>&1
423 if [ "$delay_cryptsetup" != 0 ]; then
424 show "Starting disk encryption using the RNG"
427 [ $delay_cryptsetup = 0 ] && ok || fail
430 # Start logging console output since we have all /dev stuff setup
431 if [ "$RC_BOOTLOG" ]; then
436 # Remove stale backups
437 rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~ >/dev/null 2>&1
439 # Remove /etc/nologin when starting system
440 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
442 if ! is_no "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
443 show "Enabling Delay Login"; busy
445 nls "System bootup in progress - please wait" >> /etc/nologin
447 chmod 644 /etc/nologin
448 cp -fp /etc/nologin /etc/nologin.boot
452 # The root filesystem is now read-write, so we can now log via
453 # syslog() directly...
454 if [ -n "$IN_INITLOG" ]; then
458 if ! is_yes "$VSERVER"; then
461 [ -f /etc/cryptomtab ] && :>/etc/cryptomtab
463 # Enter root, /proc, /sys and other into mtab.
466 if is_fsmounted tmpfs /run; then
467 mount -f -t tmpfs run /run
470 if is_fsmounted usbfs /proc/bus/usb; then
471 mount -f -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb
474 if is_fsmounted sysfs /sys; then
475 mount -f -t sysfs sysfs /sys
476 if is_fsmounted securityfs /sys/kernel/security ; then
477 mount -f -t securityfs securityfs /sys/kernel/security
481 if is_fsmounted selinuxfs /selinux; then
482 mount -f -t selinuxfs selinuxfs /selinux
485 emit --no-wait root-filesystem
486 emit --no-wait virtual-filesystems
488 if [ ! -f /proc/modules ]; then
490 elif ! strstr "$cmdline" nomodules; then
497 # Adjust symlinks as necessary in /boot to keep system services from
498 # spewing messages about mismatched System maps and so on.
499 if ! is_no "$SET_SLINKS"; then
500 if [ -L /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
501 ln -s -f System.map-$uname_r /boot/System.map
503 if [ ! -e /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
504 ln -s -f System.map-$uname_r /boot/System.map
508 # Run depmod if RUN_DEPMOD != "no" and:
509 # a) user requested or RUN_DEPMOD="";
510 # b) modules.dep is missing
511 if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
512 if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then
513 run_cmd "Finding module dependencies" depmod -a
514 elif [ "$RUN_DEPMOD" = "ifmissing" ] && [ ! -f /lib/modules/$uname_r/modules.dep ]; then
515 run_cmd "Finding module dependencies" depmod -A
520 if [ -f /proc/sys/kernel/modprobe ]; then
521 if [ -n "$USEMODULES" ]; then
522 sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
524 # We used to set this to NULL, but that causes
525 # 'failed to exec' messages"
526 sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
530 # Load usb storage here, to match most other things
531 if [ -n "$needusbstorage" ]; then
532 modprobe usb-storage >/dev/null 2>&1
535 # Load firewire devices
536 if ! strstr "$cmdline" nofirewire; then
537 aliases=$(/sbin/modprobe -c | awk '/^alias ieee1394-controller/ { print $3 }')
538 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
539 for alias in $aliases ; do
540 [ "$alias" = "off" ] && continue
541 run_cmd "$(nls 'Initializing firewire controller') ($alias)" /sbin/modprobe $alias
543 grep -E "SBP2" /proc/bus/ieee1394/devices 2>/dev/null && /sbin/modprobe -s sbp2 > /dev/null 2>&1
547 # Load sound modules if they need persistent DMA buffers
548 if /sbin/modprobe -c | grep -q "^options sound dmabuf=1"; then
550 alias=$(/sbin/modprobe -c | grep -sE "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
551 if [ -n "$alias" -a "$alias" != "off" ] ; then
552 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
555 alias=$(/sbin/modprobe -c | grep -sE "^alias[[:space:]]+sound-slot-0[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
556 if [ -n "$alias" -a "$alias" != "off" ] ; then
557 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
563 if ! use_upstart; then
567 if [ -x /sbin/multipath ]; then
568 # first make nodes that were discarded due (possible) new /dev mount
570 /sbin/dmsetup mknodes
571 modprobe -s dm-multipath
572 run_cmd "Activating dm-multipath" /sbin/multipath -v 0
573 /sbin/dmsetup ls --target multipath --exec '/sbin/kpartx -a -p p'
576 if [ -x /sbin/dmraid ]; then
577 run_cmd "Activating ATARAID devices" /sbin/dmraid -ay
580 # Find and activate volume groups:
582 if [ -x /sbin/evms_activate ]; then
583 if [ "$(kernelverser)" -lt "002006" ]; then
584 # Linux 2.4 core modules
585 modprobe -s evms > /dev/null 2>&1
586 modprobe -s evms_passthru > /dev/null 2>&1
587 modprobe -s ldev_mgr > /dev/null 2>&1
588 modprobe -s dos_part > /dev/null 2>&1
590 # Linux 2.6 core module
591 modprobe -s evmscore > /dev/null 2>&1
594 is_yes "$EVMS_GUID_PTABLE" && modprobe -s gpt_part >/dev/null 2>&1
595 is_yes "$EVMS_LVM" && modprobe -s lvm_vge >/dev/null 2>&1
596 is_yes "$EVMS_AIX" && modprobe -s AIXlvm_vge >/dev/null 2>&1
597 is_yes "$EVMS_OS2" && modprobe -s os2lvm_vge >/dev/null 2>&1
598 run_cmd "Discovering EVMS volumes" /sbin/evms_activate
599 if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then
600 # Link nodes for compatibility with LVM
601 if [ "$(echo /dev/evms/lvm/*)" != '/dev/evms/lvm/*' ] ; then
602 ln -s /dev/evms/lvm/* /dev
607 # LVM (keep in sync with LVM starting after RAID run!)
608 if is_no "$LVM2" || [ -x /sbin/vgscan -a -x /sbin/vgchange ] || is_yes "$EVMS_LVM"; then
609 if is_no "$LVM2"; then
610 lvmversion=$(LC_ALL=C /sbin/vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}')
614 if [ "$lvmversion" = "1" ] ; then
615 modprobe -s lvm-mod >/dev/null 2>&1
617 elif [ "$lvmversion" = "2" ] ; then
618 modprobe -s dm-mod >/dev/null 2>&1
619 lvmsysinit="--sysinit"
621 modprobe -s lvm-mod >/dev/null 2>&1
622 # device mapper (2.5+ and patched 2.4)
623 modprobe -s dm-mod >/dev/null 2>&1
627 run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmsysinit
628 run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmsysinit
629 if [ "$lvmversion" = "2" ]; then
630 /sbin/vgmknodes $lvmsysinit
631 # display VG statistics
632 /sbin/vgdisplay -s $lvmsysinit
636 if [ "$delay_cryptsetup" != 0 ]; then
637 show "Starting disk encryption"
640 [ $delay_cryptsetup = 0 ] && ok || fail
644 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ] || [ -f /etc/raidtab ]; then
645 modprobe -s md >/dev/null 2>&1
646 if [ -f /proc/mdstat ]; then
650 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
651 if (grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null); then
652 show "Starting up RAID devices"; busy
653 /sbin/mdadm --assemble --scan --auto=yes
655 if [ "$rc" -eq 0 -o "$rc" -eq 2 ]; then
656 # rc is used later, too so set sane value
668 if [ -f /etc/raidtab -a "$goraidtab" -eq 1 ]; then
669 for i in $(awk '!/^#/ && /raiddev/{print $2}' /etc/raidtab 2>/dev/null); do
671 RAIDDEV=$(basename $i)
672 RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat 2>/dev/null)
673 show "Starting up RAID device %s" $RAIDDEV
675 if [ -z "$RAIDSTAT" ]; then
676 # Try raidstart first...if that fails then
677 # fall back to raid0run and if that fails too
678 # fall back to raidadd, raidrun.
680 if [ -x /sbin/raidstart ]; then
684 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
688 if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
693 if [ $RESULT -gt 0 ]; then
705 # A non-zero return means there were problems
706 if [ $rc -gt 0 ]; then
707 [ -e /proc/splash ] && echo "verbose" > /proc/splash
708 show "Starting up RAID devices"; fail
711 nls "*** An error occurred during the RAID startup."
712 nls "*** Dropping you to a shell; the system will reboot"
713 nls "*** when you leave the shell."
716 PS1="$(nls '(RAID Repair)# ')"; export PS1
717 [ "$SELINUX" = "1" ] && disable_selinux
718 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
724 run_cmd "Unmounting file systems" umount -a
725 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
726 run_cmd "Automatic reboot in progress" reboot
728 # LVM on RAID (keep in sync with LVM setting few lines above)
729 if [ "$golvm" -eq "1" ]; then
730 if [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
731 run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmsysinit
732 run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmsysinit
733 [ "$lvmversion" = "2" ] && /sbin/vgmknodes
736 show "Starting up RAID devices"; ok
742 if [ -z "$fastboot" ] && ! strstr "$cmdline" nofsck; then
743 rc_splash "fsck start"
744 show "Checking filesystems"; started
745 initlog -c "fsck -C -T -R -A -a -P $fsckoptions"
749 # A return of 2 or higher means there were serious problems
750 if [ $rc -gt 1 ]; then
751 [ -e /proc/splash ] && echo "verbose" > /proc/splash
754 nls "*** An error occurred during the file system check."
755 nls "*** Dropping you to a shell; the system will reboot"
756 nls "*** when you leave the shell."
759 PS1="$(nls '(Repair filesystem)# ')"; export PS1
760 [ "$SELINUX" = "1" ] && disable_selinux
761 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
767 run_cmd "Unmounting file systems" umount -a
768 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
769 run_cmd "Automatic reboot in progress" reboot
770 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
773 rc_splash "fsck stop"
776 # Mount all other filesystems (except for NFS and /proc, which is already
777 # mounted). Contrary to standard usage,
778 # filesystems are NOT unmounted in single user mode.
780 run_cmd "Mounting local filesystems" mount -a -t nonfs,nfs4,smbfs,ncpfs,proc,cifs -O no_netdev
782 # now we have /usr mounted, recheck if we have gettext and tput available.
783 if is_no "$TPUT"; then
789 # Now do some workaround - encrypted filesystems couldn't have been fsck-ed
790 # before mount - that's where the password is entered.
791 # mount is buggy - when remounting loopback filesystem, loop=XXX
792 # option is removed from /etc/mtab
793 if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then
794 show "Checking encrypted filesystems"; started
796 FILENAME=="/proc/mounts" {
799 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ {
800 if ($2 in TAB){print TAB[$2];}
802 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
803 if ($2 in TAB){print TAB[$2];}
804 sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4);
805 cmd="mount " $2 " -o remount," $4;
808 ' /proc/mounts /etc/fstab)"
809 initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST"
812 # A return of 2 or higher means there were serious problems.
813 if [ $rc -gt 1 ]; then
814 [ -e /proc/splash ] && echo "verbose" > /proc/splash
817 nls "*** An error occurred during the file system check."
818 nls "*** Dropping you to a shell; the system will reboot"
819 nls "*** when you leave the shell."
822 PS1="$(nls '(Repair filesystem)# ')"; export PS1
823 [ "$SELINUX" = "1" ] && disable_selinux
824 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
830 run_cmd "Unmounting file systems" umount -a
831 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
832 run_cmd "Automatic reboot in progress" reboot
833 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
837 show "Remounting encrypted filesystems back in rw mode"; busy
839 FILENAME=="/proc/mounts" {
842 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
843 sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4);
844 cmd="mount " $2 " -o remount," $4;
847 ' /proc/mounts /etc/fstab
851 # /var/log should be writable now, so start saving the boot output
852 if [ "$RC_BOOTLOG" ]; then
853 echo > /var/log/boot.log
857 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
858 run_cmd "Checking filesystem quotas" /sbin/quotacheck -vnugRa
862 if [ -x /sbin/quotaon ]; then
863 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug
866 emit --no-wait local-filesystems
868 # FIXME: this should be delayed until remote filesystems are mounted,
869 # especialy when /usr or other standard fs is remote
870 emit --no-wait filesystem
872 # Turn on process accounting
873 if [ -x /etc/rc.d/rc.acct ]; then
874 /etc/rc.d/rc.acct start
877 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
878 if is_yes "$TIME_SETUP_DELAYED" && [ -e /dev/rtc -o -e /dev/rtc0 ]; then
879 if run_cmd "$(nls 'Setting clock')" hwclock --hctosys; then
880 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
884 # Initialize the serial ports
885 if [ -f /etc/rc.d/rc.serial ]; then
886 . /etc/rc.d/rc.serial
889 if [ -f /proc/sys/kernel/panic -a -n "$PANIC_REBOOT_TIME" -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
890 show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy
891 # NOTE: you should use /etc/sysctl.conf instead
892 if sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1; then ok; else fail; fi
895 # ... and here finish configuring parameters
896 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
898 emit --no-wait root-filesystem
899 emit --no-wait virtual-filesystems
900 emit --no-wait local-filesystems
901 emit --no-wait filesystem
903 # /var/log should be writable now, so start saving the boot output
904 if [ "$RC_BOOTLOG" ]; then
905 echo > /var/log/boot.log
913 [ -n "$SELINUX" ] && [ -f /.autorelabel ] && relabel_selinux
916 rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff >/dev/null 2>&1
919 # /usr could be still not mounted if it is on NFS.
920 for afile in /var/lock/* /var/run/*; do
922 if [ -d "$afile" ]; then
927 echo $afile/* | xargs rm -rf
931 [ "$bafile" != "hwprofile" -a "$bafile" != "random-seed" ] && rm -f $afile 2> /dev/null
936 rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \
937 /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.*
938 rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \
939 /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \
940 /tmp/scrollkeeper-* /tmp/ssh-*
944 if ! is_no "$NEED_XFILES"; then
947 chown root:utmp /var/run/utmpx /var/log/wtmpx
948 chmod 0664 /var/run/utmpx /var/log/wtmpx
952 chown root:utmp /var/run/utmp /var/log/wtmp
953 chmod 0664 /var/run/utmp /var/log/wtmp
957 if is_yes "$CLEAN_TMP"; then
958 # XXX LC_ALL needed here
959 rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
962 # System protected dirs
963 mkdir -m 1777 -p /tmp/.ICE-unix > /dev/null 2>&1
964 chown root:root /tmp/.ICE-unix
965 [ -n "$SELINUX" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1
967 if ! is_yes "$VSERVER"; then
968 run_cmd "Enabling swap space" true
969 # Right, now turn on swap in case we swap to files
970 swapon -a >/dev/null 2>&1
971 emit --no-wait all-swaps
973 # If a SCSI tape has been detected, load the st module unconditionally
974 # since many SCSI tapes don't deal well with st being loaded and unloaded
975 if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then
976 if grep -qv ' 9 st' /proc/devices 2>/dev/null; then
977 if [ -n "$USEMODULES" ] ; then
978 # Try to load the module. If it fails, ignore it...
979 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
984 # Now that we have all of our basic modules loaded and the kernel going,
985 # let's dump the syslog ring somewhere so we can find it later
986 dmesg > /var/log/dmesg
988 while [ $i -ge 0 ]; do
989 if [ -f /var/log/dmesg.$i ]; then
990 chmod 0600 /var/log/dmesg.$i
991 mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1))
995 cp -f /var/log/dmesg /var/log/dmesg.0
996 chmod 0600 /var/log/dmesg /var/log/dmesg.0
998 emit --no-wait all-swaps
1001 if ! is_no "$RC_PROMPT"; then
1003 pid=$(/sbin/pidof getkey)
1004 [ -n "$pid" -o -e /var/run/getkey_done ] && break
1007 [ -n "$pid" ] && kill -TERM "$pid" >/dev/null 2>&1
1011 # /proc extra check if the background process we just spawned is still running,
1012 # as in case of vserver bootup it finishes quite instantly.
1013 if ! is_no "$RC_PROMPT" && [ -d /proc/$! ]; then
1014 /sbin/getkey i && touch /var/run/confirm
1015 touch /var/run/getkey_done
1018 if ! is_no "$RC_PROMPT"; then
1019 rm -f /var/run/getkey_done
1023 emit --no-wait pld.sysinit-done