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() {
98 # Loop over every line in modules file
100 grep -hvE '^(#|[[: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
106 modprobe -s $module -- $args
111 show "Checking root filesystem"; started
112 initlog -c "fsck -C -T -a $fsckoptions /"
115 # A return of 4 or higher means there were serious problems.
116 if [ $rc -gt 3 ]; then
117 [ -e /proc/splash ] && echo "verbose" > /proc/splash
118 # don't use '\n' in nls macro !
121 nls "*** An error occurred during the file system check."
122 nls "*** Dropping you to a shell; the system will reboot"
123 nls "*** when you leave the shell."
126 PS1="$(nls '(Repair filesystem)# ')"; export PS1
127 [ "$SELINUX" = "1" ] && disable_selinux
128 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
134 run_cmd "Unmounting file systems" umount -a
135 mount -n -o remount,ro /
136 run_cmd "Automatic reboot in progress" reboot
137 # A return of 2 or 3 means that filesystem was repaired but we need
139 elif [ "$rc" = "2" -o "$rc" = "3" ]; then
140 [ -e /proc/splash ] && echo "verbose" > /proc/splash
142 nls "*** Filesystem was repaired but system needs to be"
143 nls "*** rebooted before mounting it."
144 nls "*** REBOOTING ***"
147 run_cmd "Unmounting file systems" umount -a
148 mount -n -o remount,ro /
149 run_cmd "Automatic reboot in progress" reboot
150 elif [ "$rc" = "1" ]; then
155 # boot logging to /var/log/boot.log. install showconsole package to get it.
156 if [ -x /sbin/blogd ] && ! is_no "$RC_BOOTLOG"; then
162 if ! is_yes "$VSERVER" ; then
163 # we need /proc mounted before everything
164 is_fsmounted proc /proc || mount -n -o gid=17 -t proc /proc /proc
166 # Only read this once.
167 cmdline=$(cat /proc/cmdline)
168 if strstr "$cmdline" "pld.no-upstart" ; then
172 # sysfs is also needed before any other things (under kernel > 2.5)
173 if grep -q sysfs /proc/filesystems 2>/dev/null ; then
174 is_fsmounted sysfs /sys || mount -n -o gid=17 -t sysfs sysfs /sys
175 if [ "$(kernelver)" -ge "002006014" ] && \
176 grep -q securityfs /proc/filesystems 2>/dev/null ; then
177 mount -n -o gid=17 -t securityfs securityfs /sys/kernel/security
182 if grep -q selinuxfs /proc/filesystems 2>/dev/null && ! is_fsmounted selinuxfs /selinux; then
183 mount -n -o gid=17 -t selinuxfs selinuxfs /selinux
186 # PLD Linux LiveCD support
187 if [ -x /etc/rc.d/rc.live ]; then
191 # Choose Hardware profile
192 if [ -f /etc/sysconfig/hwprof ]; then
193 . /etc/sysconfig/hwprof
194 if is_yes "${HWPROFILES}" && [ -x /sbin/hwprofile -a -d /etc/sysconfig/hwprofiles/data ]; then
195 mount -n / -o rw,remount
197 mount -n / -o ro,remount
201 # Disable splash when requested
202 [ -e /proc/splash ] && is_no "$BOOT_SPLASH" && echo "0" > /proc/splash
204 # Check SELinux status
205 selinuxfs=$(awk '/ selinuxfs / { print $2 }' /proc/mounts 2> /dev/null)
207 if [ -n "$selinuxfs" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then
208 if [ -r $selinuxfs/enforce ] ; then
209 SELINUX=$(cat $selinuxfs/enforce)
211 # assume enforcing if you can't read it
216 if [ -x /sbin/restorecon ] && is_fsmounted tmpfs /dev; then
217 /sbin/restorecon -R /dev 2>/dev/null
220 [ -z "${CONSOLETYPE}" ] && CONSOLETYPE="$(/sbin/consoletype)"
222 if [ "$CONSOLETYPE" = "vt" -a -x /sbin/setsysfont ]; then
228 # Print welcome message
229 nls "\t\t\t%sPowered by %sPLD Linux Distribution%s" "$(termput setaf $CPOWEREDBY)" "$(termput setaf $CPLD)" "$(termput op)"
230 if ! is_no "$RC_PROMPT"; then
231 nls -n "\t\t Press %sI%s to enter interactive startup" "$(termput setaf $CI)" "$(termput op)"
236 if [ -z "${HOSTNAME}" ]; then
237 show "$(nls 'Host:') $(hostname)" ; ok
239 run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME}
242 # Set the NIS domain name
243 if [ -n "$NISDOMAIN" ]; then
244 run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN
249 if ! is_yes "$VSERVER"; then
250 # Set console loglevel
251 if [ -n "$CONSOLE_LOGLEVEL" ]; then
252 dmesg -n $CONSOLE_LOGLEVEL
255 if ! is_no "$START_UDEV" && [ -x /sbin/start_udev ]; then
257 elif [ -x /lib/firmware/firmware-loader.sh ]; then
258 /sbin/sysctl -e -w kernel.hotplug=/lib/firmware/firmware-loader.sh > /dev/null 2>&1
261 # Unmount the initrd, if necessary
262 if grep -q /initrd /proc/mounts 2>/dev/null && ! grep -q /initrd/loopfs /proc/mounts 2>/dev/null; then
263 umount /initrd/dev 2>/dev/null
265 /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1
268 # Start logging console output since we have all /dev stuff setup
269 if [ "$RC_BOOTLOG" ]; then
273 # cgroup/cpuset support
274 if grep -q cgroup /proc/filesystems 2>/dev/null ; then
275 if ! grep -q cgroup /etc/fstab 2>/dev/null ; then
276 # creating is more convenient than artificial conflict with older udev
278 # mount w/o options enables all available cgroup subsystems
279 modprobe -s blk-cgroup 2> /dev/null
280 mount -n -t cgroup none /dev/cgroup
282 elif grep -q cpuset /proc/filesystems 2>/dev/null ; then
283 if ! grep -q cpuset /etc/fstab 2>/dev/null ; then
284 mount -n -t cpuset none /dev/cpuset
288 # Configure Linux kernel (initial configuration, some required modules still
290 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
292 # Set the system clock.
297 if [ -f /etc/sysconfig/clock ]; then
298 . /etc/sysconfig/clock
300 # convert old style clock config to new values
301 if [ "${CLOCKMODE}" = "GMT" ]; then
303 elif [ "${CLOCKMODE}" = "ARC" ]; then
308 if grep "system serial" /proc/cpuinfo 2>/dev/null | grep -q MILO 2>/dev/null ; then
313 CLOCKFLAGS="--hctosys"
315 if is_yes "$UTC" ; then
316 CLOCKFLAGS="$CLOCKFLAGS --utc"
317 CLOCKDEF="$CLOCKDEF (utc)"
319 CLOCKFLAGS="$CLOCKFLAGS --localtime"
320 CLOCKDEF="$CLOCKDEF (local)"
323 if is_yes "$ARC" ; then
324 CLOCKFLAGS="$CLOCKFLAGS -A"
325 CLOCKDEF="$CLOCKDEF (arc)"
328 if is_yes "$SRM" ; then
329 CLOCKFLAGS="$CLOCKFLAGS -S"
330 CLOCKDEF="$CLOCKDEF (srm)"
333 # Check if timezone definition is available
334 if [ -e /etc/localtime -a -e /dev/rtc ] ; then
335 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" hwclock $CLOCKFLAGS; then
336 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
339 TIME_SETUP_DELAYED=yes
342 if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then
343 # XXX might need modules dep
344 # Device mapper & related initialization
345 if ! grep -qF device-mapper /proc/devices; then
349 . /etc/rc.d/init.d/cryptsetup
350 show "Starting disk encryption"
353 [ $delay_cryptsetup = 0 ] && ok || fail
357 run_cmd "Activating swap partitions" swapon -a -e
359 # Initialize USB controllers
361 if ! strstr "$cmdline" "nousb" && ! is_fsmounted usbfs /proc/bus/usb ; then
362 aliases=$(/sbin/modprobe -c | awk '/^alias[\t ]+usb-controller/ { print $3 }')
363 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
364 /sbin/modprobe -s usbcore
365 for alias in $aliases ; do
366 [ "$alias" = "off" ] && continue
367 run_cmd "$(nls 'Initializing USB controller') ($alias)" /sbin/modprobe -s $alias
369 [ $? -eq 0 -a -n "$aliases" ] && usb=1
371 if grep -iq "usb" /proc/devices 2>/dev/null ; then
376 if [ "$usb" = "1" ] && ! is_fsmounted usbfs /proc/bus/usb ; then
377 run_cmd "Mounting USB filesystem" mount -n -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb
381 if [ "$usb" = "1" ]; then
382 needusbstorage=$(cat /proc/bus/usb/devices 2>/dev/null | grep -e "^I.*Cls=08" 2>/dev/null)
383 if [ "$(kernelverser)" -lt "002006" ]; then
384 grep -q 'hid' /proc/bus/usb/drivers 2>/dev/null || run_cmd "Initializing USB HID interface" modprobe hid 2> /dev/null
385 mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02" 2>/dev/null)
386 kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01" 2>/dev/null)
387 if [ -n "$kbdoutput" ]; then
388 run_cmd "Initializing USB keyboard" modprobe keybdev
390 if [ -n "$mouseoutput" ]; then
391 run_cmd "Initializing USB mouse" modprobe mousedev
396 # Setup hdparm thing (if exists and is needed)
397 if ! strstr "$cmdline" nohdparm; then
398 [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
401 if [ -f /fastboot ] || strstr "$cmdline" "fastboot"; then
407 if [ -f /fsckoptions ]; then
408 fsckoptions=$(cat /fsckoptions)
413 if [ -f /forcefsck ]; then
414 fsckoptions="-f $fsckoptions"
416 # Obey the fs_passno setting for / (see fstab(5))
418 # - make sure we have at least 6 fields
419 _ROOTFS_PASSNO=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $6}' /etc/fstab)
423 _ROOTFS_DEVICE=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $1}' /etc/fstab)
424 _ROOTFS_TYPE=$(awk '$2 == "/" && $3 != "rootfs" { print $3 }' /proc/mounts 2>/dev/null)
426 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
430 # Check for arguments
431 if strstr "$cmdline" nopnp; then
437 # set up pnp and kernel pnp
438 if [ -n "$PNP" ]; then
439 if ! is_no "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
440 run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf
442 if ! is_no "$RUN_KERNELPNP"; then
443 /sbin/modprobe isa-pnp 2> /dev/null
444 if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then
445 show "Setting up ISA PNP devices (kernelspace pnp)"; busy
446 grep -v "^#" /etc/isapnp/isapnp-kernel.conf 2>/dev/null >/proc/isapnp && (deltext; ok) || (deltext; fail)
451 _ROOTFS_RO=$(awk '($1 !~ /^#/ && $2 == "/" && ($4 == "ro" || $4 ~ /,ro$/ || $4 ~ /^ro,/ || $4 ~ /,ro,/ ) && NF >= 6) { print "ro" }' /etc/fstab)
452 # Remount the root filesystem read-write
453 if [ -z "$_ROOTFS_RO" ]; then
454 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
457 # Update quotas if fsck was run on /
458 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
459 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vnug /
462 # Clean up SELinux labels
463 if [ -n "$SELINUX" ]; then
464 for file in /etc/mtab /etc/cryptomtab /etc/ld.so.cache ; do
465 [ -r $file ] && restorecon $file >/dev/null 2>&1
469 if [ "$delay_cryptsetup" != 0 ]; then
470 show "Starting disk encryption using the RNG"
473 [ $delay_cryptsetup = 0 ] && ok || fail
476 # Start logging console output since we have all /dev stuff setup
477 if [ "$RC_BOOTLOG" ]; then
482 # Remove stale backups
483 rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~ >/dev/null 2>&1
485 # Remove /etc/nologin when starting system
486 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
488 if ! is_no "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
489 show "Enabling Delay Login"; busy
491 nls "System bootup in progress - please wait" >> /etc/nologin
493 chmod 644 /etc/nologin
494 cp -fp /etc/nologin /etc/nologin.boot
498 # The root filesystem is now read-write, so we can now log via
499 # syslog() directly...
500 if [ -n "$IN_INITLOG" ]; then
504 if ! is_yes "$VSERVER"; then
507 [ -f /etc/cryptomtab ] && :>/etc/cryptomtab
509 # Enter root, /proc, /sys and other into mtab.
512 if is_fsmounted usbfs /proc/bus/usb; then
513 mount -f -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb
516 if is_fsmounted sysfs /sys; then
517 mount -f -t sysfs sysfs /sys
518 if is_fsmounted securityfs /sys/kernel/security ; then
519 mount -f -t securityfs securityfs /sys/kernel/security
523 if is_fsmounted selinuxfs /selinux; then
524 mount -f -t selinuxfs selinuxfs /selinux
527 if is_fsmounted cgroup /dev/cgroup; then
528 mount -f -t cgroup none /dev/cgroup
529 elif is_fsmounted cpuset /dev/cpuset; then
530 mount -f -t cpuset none /dev/cpuset
533 emit --no-wait root-filesystem
534 emit --no-wait virtual-filesystems
536 if [ ! -f /proc/modules ]; then
538 elif ! strstr "$cmdline" nomodules; then
545 # Adjust symlinks as necessary in /boot to keep system services from
546 # spewing messages about mismatched System maps and so on.
547 if ! is_no "$SET_SLINKS"; then
548 if [ -L /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
549 ln -s -f System.map-$uname_r /boot/System.map
551 if [ ! -e /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
552 ln -s -f System.map-$uname_r /boot/System.map
556 # Run depmod if RUN_DEPMOD != "no" and:
557 # a) user requested or RUN_DEPMOD="";
558 # b) modules.dep is missing
559 if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
560 if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then
561 run_cmd "Finding module dependencies" depmod -a
562 elif [ "$RUN_DEPMOD" = "ifmissing" ] && [ ! -f /lib/modules/$uname_r/modules.dep ]; then
563 run_cmd "Finding module dependencies" depmod -A
568 if [ -f /proc/sys/kernel/modprobe ]; then
569 if [ -n "$USEMODULES" ]; then
570 sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
572 # We used to set this to NULL, but that causes
573 # 'failed to exec' messages"
574 sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
578 # Load usb storage here, to match most other things
579 if [ -n "$needusbstorage" ]; then
580 modprobe usb-storage >/dev/null 2>&1
583 # Load firewire devices
584 if ! strstr "$cmdline" nofirewire; then
585 aliases=$(/sbin/modprobe -c | awk '/^alias ieee1394-controller/ { print $3 }')
586 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
587 for alias in $aliases ; do
588 [ "$alias" = "off" ] && continue
589 run_cmd "$(nls 'Initializing firewire controller') ($alias)" /sbin/modprobe $alias
591 grep -E "SBP2" /proc/bus/ieee1394/devices 2>/dev/null && /sbin/modprobe -s sbp2 > /dev/null 2>&1
595 # Load sound modules if they need persistent DMA buffers
596 if /sbin/modprobe -c | grep -q "^options sound dmabuf=1"; then
598 alias=$(/sbin/modprobe -c | grep -sE "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
599 if [ -n "$alias" -a "$alias" != "off" ] ; then
600 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
603 alias=$(/sbin/modprobe -c | grep -sE "^alias[[:space:]]+sound-slot-0[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
604 if [ -n "$alias" -a "$alias" != "off" ] ; then
605 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
613 if [ -x /sbin/multipath ]; then
614 # first make nodes that were discarded due (possible) new /dev mount
616 /sbin/dmsetup mknodes
617 modprobe -s dm-multipath
618 run_cmd "Activating dm-multipath" /sbin/multipath -v 0
619 /sbin/dmsetup ls --target multipath --exec '/sbin/kpartx -a -p p'
622 if [ -x /sbin/dmraid ]; then
623 run_cmd "Activating ATARAID devices" /sbin/dmraid -ay
626 # Find and activate volume groups:
628 if [ -x /sbin/evms_activate ]; then
629 if [ "$(kernelverser)" -lt "002006" ]; then
630 # Linux 2.4 core modules
631 modprobe -s evms > /dev/null 2>&1
632 modprobe -s evms_passthru > /dev/null 2>&1
633 modprobe -s ldev_mgr > /dev/null 2>&1
634 modprobe -s dos_part > /dev/null 2>&1
636 # Linux 2.6 core module
637 modprobe -s evmscore > /dev/null 2>&1
640 is_yes "$EVMS_GUID_PTABLE" && modprobe -s gpt_part >/dev/null 2>&1
641 is_yes "$EVMS_LVM" && modprobe -s lvm_vge >/dev/null 2>&1
642 is_yes "$EVMS_AIX" && modprobe -s AIXlvm_vge >/dev/null 2>&1
643 is_yes "$EVMS_OS2" && modprobe -s os2lvm_vge >/dev/null 2>&1
644 run_cmd "Discovering EVMS volumes" /sbin/evms_activate
645 if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then
646 # Link nodes for compatibility with LVM
647 if [ "$(echo /dev/evms/lvm/*)" != '/dev/evms/lvm/*' ] ; then
648 ln -s /dev/evms/lvm/* /dev
653 # LVM (keep in sync with LVM starting after RAID run!)
654 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
655 lvmversion=$(LC_ALL=C /sbin/vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}')
656 if [ "$lvmversion" = "1" ] ; then
657 modprobe -s lvm-mod >/dev/null 2>&1
659 elif [ "$lvmversion" = "2" ] ; then
660 modprobe -s dm-mod >/dev/null 2>&1
661 lvmignorelock="--ignorelockingfailure"
663 modprobe -s lvm-mod >/dev/null 2>&1
664 # device mapper (2.5+ and patched 2.4)
665 modprobe -s dm-mod >/dev/null 2>&1
669 run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelock
670 run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmignorelock
671 if [ "$lvmversion" = "2" ]; then
672 /sbin/vgmknodes $lvmignorelock
673 # display VG statistics
674 /sbin/vgdisplay -s $lvmignorelock
678 if [ "$delay_cryptsetup" != 0 ]; then
679 show "Starting disk encryption"
682 [ $delay_cryptsetup = 0 ] && ok || fail
686 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ] || [ -f /etc/raidtab ]; then
687 modprobe -s md >/dev/null 2>&1
688 if [ -f /proc/mdstat ]; then
692 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
693 if (grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null); then
694 show "Starting up RAID devices"; busy
695 /sbin/mdadm --assemble --scan --auto=yes
697 if [ "$rc" -eq 0 -o "$rc" -eq 2 ]; then
698 # rc is used later, too so set sane value
710 if [ -f /etc/raidtab -a "$goraidtab" -eq 1 ]; then
711 for i in $(awk '!/^#/ && /raiddev/{print $2}' /etc/raidtab 2>/dev/null); do
713 RAIDDEV=$(basename $i)
714 RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat 2>/dev/null)
715 show "Starting up RAID device %s" $RAIDDEV
717 if [ -z "$RAIDSTAT" ]; then
718 # Try raidstart first...if that fails then
719 # fall back to raid0run and if that fails too
720 # fall back to raidadd, raidrun.
722 if [ -x /sbin/raidstart ]; then
726 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
730 if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
735 if [ $RESULT -gt 0 ]; then
747 # A non-zero return means there were problems
748 if [ $rc -gt 0 ]; then
749 [ -e /proc/splash ] && echo "verbose" > /proc/splash
750 show "Starting up RAID devices"; fail
753 nls "*** An error occurred during the RAID startup."
754 nls "*** Dropping you to a shell; the system will reboot"
755 nls "*** when you leave the shell."
758 PS1="$(nls '(RAID Repair)# ')"; export PS1
759 [ "$SELINUX" = "1" ] && disable_selinux
760 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
766 run_cmd "Unmounting file systems" umount -a
767 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
768 run_cmd "Automatic reboot in progress" reboot
770 # LVM on RAID (keep in sync with LVM setting few lines above)
771 if [ "$golvm" -eq "1" ]; then
772 if [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
773 run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmignorelock
774 run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmignorelock
775 [ "$lvmversion" = "2" ] && /sbin/vgmknodes
778 show "Starting up RAID devices"; ok
784 if [ -z "$fastboot" ] && ! strstr "$cmdline" nofsck; then
785 rc_splash "fsck start"
786 show "Checking filesystems"; started
787 initlog -c "fsck -C -T -R -A -a -P $fsckoptions"
791 # A return of 2 or higher means there were serious problems
792 if [ $rc -gt 1 ]; then
793 [ -e /proc/splash ] && echo "verbose" > /proc/splash
796 nls "*** An error occurred during the file system check."
797 nls "*** Dropping you to a shell; the system will reboot"
798 nls "*** when you leave the shell."
801 PS1="$(nls '(Repair filesystem)# ')"; export PS1
802 [ "$SELINUX" = "1" ] && disable_selinux
803 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
809 run_cmd "Unmounting file systems" umount -a
810 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
811 run_cmd "Automatic reboot in progress" reboot
812 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
815 rc_splash "fsck stop"
818 # Mount all other filesystems (except for NFS and /proc, which is already
819 # mounted). Contrary to standard usage,
820 # filesystems are NOT unmounted in single user mode.
822 run_cmd "Mounting local filesystems" mount -a -t nonfs,nfs4,smbfs,ncpfs,proc,cifs -O no_netdev
824 # now we have /usr mounted, recheck if we have gettext and tput available.
825 if is_no "$TPUT"; then
831 # Now do some workaround - encrypted filesystems couldn't have been fsck-ed
832 # before mount - that's where the password is entered.
833 # mount is buggy - when remounting loopback filesystem, loop=XXX
834 # option is removed from /etc/mtab
835 if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then
836 show "Checking encrypted filesystems"; started
838 FILENAME=="/proc/mounts" {
841 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ {
842 if ($2 in TAB){print TAB[$2];}
844 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
845 if ($2 in TAB){print TAB[$2];}
846 sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4);
847 cmd="mount " $2 " -o remount," $4;
850 ' /proc/mounts /etc/fstab)"
851 initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST"
854 # A return of 2 or higher means there were serious problems.
855 if [ $rc -gt 1 ]; then
856 [ -e /proc/splash ] && echo "verbose" > /proc/splash
859 nls "*** An error occurred during the file system check."
860 nls "*** Dropping you to a shell; the system will reboot"
861 nls "*** when you leave the shell."
864 PS1="$(nls '(Repair filesystem)# ')"; export PS1
865 [ "$SELINUX" = "1" ] && disable_selinux
866 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
872 run_cmd "Unmounting file systems" umount -a
873 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
874 run_cmd "Automatic reboot in progress" reboot
875 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
879 show "Remounting encrypted filesystems back in rw mode"; busy
881 FILENAME=="/proc/mounts" {
884 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
885 sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4);
886 cmd="mount " $2 " -o remount," $4;
889 ' /proc/mounts /etc/fstab
893 # /var/log should be writable now, so start saving the boot output
894 if [ "$RC_BOOTLOG" ]; then
895 echo > /var/log/boot.log
899 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
900 run_cmd "Checking filesystem quotas" /sbin/quotacheck -vnugRa
904 if [ -x /sbin/quotaon ]; then
905 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug
908 emit --no-wait local-filesystems
910 # FIXME: this should be delayed until remote filesystems are mounted,
911 # especialy when /usr or other standard fs is remote
912 emit --no-wait filesystem
914 # Turn on process accounting
915 if [ -x /etc/rc.d/rc.acct ]; then
916 /etc/rc.d/rc.acct start
919 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
920 if is_yes "$TIME_SETUP_DELAYED" && [ -e /dev/rtc ]; then
921 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" hwclock $CLOCKFLAGS; then
922 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
926 # Initialize the serial ports
927 if [ -f /etc/rc.d/rc.serial ]; then
928 . /etc/rc.d/rc.serial
931 if [ -f /proc/sys/kernel/panic -a -n "$PANIC_REBOOT_TIME" -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
932 show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy
933 # NOTE: you should use /etc/sysctl.conf instead
934 if sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1; then ok; else fail; fi
937 # ... and here finish configuring parameters
938 sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
940 emit --no-wait root-filesystem
941 emit --no-wait virtual-filesystems
942 emit --no-wait local-filesystems
943 emit --no-wait filesystem
945 # /var/log should be writable now, so start saving the boot output
946 if [ "$RC_BOOTLOG" ]; then
947 echo > /var/log/boot.log
955 [ -n "$SELINUX" ] && [ -f /.autorelabel ] && relabel_selinux
958 rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff >/dev/null 2>&1
961 # /usr could be still not mounted if it is on NFS.
962 for afile in /var/lock/* /var/run/*; do
964 if [ -d "$afile" ]; then
969 echo $afile/* | xargs rm -rf
973 [ "$bafile" != "hwprofile" -a "$bafile" != "random-seed" ] && rm -f $afile 2> /dev/null
978 rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \
979 /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.*
980 rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \
981 /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \
982 /tmp/scrollkeeper-* /tmp/ssh-*
986 if ! is_no "$NEED_XFILES"; then
989 chown root:utmp /var/run/utmpx /var/log/wtmpx
990 chmod 0664 /var/run/utmpx /var/log/wtmpx
994 chown root:utmp /var/run/utmp /var/log/wtmp
995 chmod 0664 /var/run/utmp /var/log/wtmp
999 if is_yes "$CLEAN_TMP"; then
1000 # XXX LC_ALL needed here
1001 rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
1004 # System protected dirs
1005 mkdir -m 1777 -p /tmp/.ICE-unix > /dev/null 2>&1
1006 chown root:root /tmp/.ICE-unix
1007 [ -n "$SELINUX" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1
1009 if ! is_yes "$VSERVER"; then
1010 run_cmd "Enabling swap space" true
1011 # Right, now turn on swap in case we swap to files
1012 swapon -a >/dev/null 2>&1
1013 emit --no-wait all-swaps
1015 # If a SCSI tape has been detected, load the st module unconditionally
1016 # since many SCSI tapes don't deal well with st being loaded and unloaded
1017 if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then
1018 if grep -qv ' 9 st' /proc/devices 2>/dev/null; then
1019 if [ -n "$USEMODULES" ] ; then
1020 # Try to load the module. If it fails, ignore it...
1021 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
1026 # Now that we have all of our basic modules loaded and the kernel going,
1027 # let's dump the syslog ring somewhere so we can find it later
1028 dmesg > /var/log/dmesg
1030 while [ $i -ge 0 ]; do
1031 if [ -f /var/log/dmesg.$i ]; then
1032 chmod 0600 /var/log/dmesg.$i
1033 mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1))
1037 cp -f /var/log/dmesg /var/log/dmesg.0
1038 chmod 0600 /var/log/dmesg /var/log/dmesg.0
1040 emit --no-wait all-swaps
1043 if ! is_no "$RC_PROMPT"; then
1045 pid=$(/sbin/pidof getkey)
1046 [ -n "$pid" -o -e /var/run/getkey_done ] && break
1049 [ -n "$pid" ] && kill -TERM "$pid" >/dev/null 2>&1
1053 # /proc extra check if the background process we just spawned is still running,
1054 # as in case of vserver bootup it finishes quite instantly.
1055 if ! is_no "$RC_PROMPT" && [ -d /proc/$! ]; then
1056 /sbin/getkey i && touch /var/run/confirm
1057 touch /var/run/getkey_done
1060 if ! is_no "$RC_PROMPT"; then
1061 rm -f /var/run/getkey_done
1065 emit --no-wait pld.sysinit-done