3 # /etc/rc.d/rc.sysinit - run once at boot time
6 # Taken in part from Miquel van Smoorenburg's bcheckrc.
10 PATH=/bin:/sbin:/usr/bin:/usr/sbin
13 # reasonable start values for bootsplash progress.
19 if [ -r /etc/sysconfig/i18n ]; then
21 [ -n "$LANG" ] && export LANG || unset LANG
22 [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
23 [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE
24 [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES
25 [ -n "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC
26 [ -n "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY
27 [ -n "$LC_TIME" ] && export LC_TIME || unset LC_TIME
28 [ -n "$LC_ALL" ] && export LC_ALL || unset LC_ALL
29 [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE
30 [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS
33 # Read network config data
34 if [ -r /etc/sysconfig/network ]; then
35 . /etc/sysconfig/network
43 # Only read this once.
44 cmdline=$(cat /proc/cmdline)
47 . /etc/rc.d/init.d/functions
50 typeset _d selinuxfs _t _r
52 while read _d selinuxfs _t _r; do
53 [ "$_t" = "selinuxfs" ] && break
55 echo "*** Warning -- SELinux is active"
56 echo "*** Disabling security enforcement for system recovery."
57 echo "*** Run 'setenforce 1' to reenable."
58 echo "0" > $selinuxfs/enforce
62 typeset _d selinuxfs _t _r
64 while read _d selinuxfs _t _r; do
65 [ "$_t" = "selinuxfs" ] && break
68 *** Warning -- SELinux relabel is required. ***
69 *** Disabling security enforcement. ***
70 *** Relabeling could take a very long time, ***
71 *** depending on file system size. ***
73 echo "0" > $selinuxfs/enforce
74 /sbin/fixfiles -F relabel > /dev/null 2>&1
76 echo "*** Enabling security enforcement. ***"
77 echo $SELINUX > $selinuxfs/enforce
80 # Remove duplicate entries from mtab (for vserver guest use only)
81 clean_vserver_mtab() {
83 while read device mountpoint line; do
84 grep -qs "$mountpoint" /etc/mtab.clean || \
85 echo "$device $mountpoint $line" >> /etc/mtab.clean
87 cat /etc/mtab.clean > /etc/mtab
92 # boot logging to /var/log/boot.msg. install showconsole package to get it.
93 if [ -x /sbin/blogd ] && ! is_no "$RC_BOOTLOG"; then
99 if ! is_yes "$VSERVER" ; then
100 # we need /proc mounted before everything
101 mount -n -o gid=17 -t proc /proc /proc
103 # sysfs is also needed before any other things (under kernel > 2.5)
104 if grep -q sysfs /proc/filesystems 2>/dev/null ; then
105 mount -n -o gid=17 -t sysfs sysfs /sys
106 if [ "$(kernelver)" -ge "002006014" ] && \
107 grep -q securityfs /proc/filesystems 2>/dev/null ; then
108 mount -n -o gid=17 -t securityfs securityfs /sys/kernel/security
114 if grep -q selinuxfs /proc/filesystems 2>/dev/null && ! grep -q selinuxfs /proc/mounts 2>/dev/null; then
115 mount -n -o gid=17 -t selinuxfs selinuxfs /selinux
118 # PLD Linux LiveCD support
119 if [ -x /etc/rc.d/rc.live ]; then
123 # Choose Hardware profile
124 if [ -f /etc/sysconfig/hwprof ]; then
125 . /etc/sysconfig/hwprof
126 if is_yes "${HWPROFILES}" && [ -x /sbin/hwprofile -a -d /etc/sysconfig/hwprofiles/data ]; then
127 mount -n / -o rw,remount
129 mount -n / -o ro,remount
133 # Disable splash when requested
134 [ -e /proc/splash ] && is_no "$BOOT_SPLASH" && echo "0" > /proc/splash
136 # Check SELinux status
137 selinuxfs=$(awk '/ selinuxfs / { print $2 }' /proc/mounts 2> /dev/null)
139 if [ -n "$selinuxfs" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then
140 if [ -r $selinuxfs/enforce ] ; then
141 SELINUX=$(cat $selinuxfs/enforce)
143 # assume enforcing if you can't read it
148 if [ -x /sbin/restorecon ] && LC_ALL=C fgrep -q " /dev " /proc/mounts 2>/dev/null ; then
149 /sbin/restorecon -R /dev 2>/dev/null
153 [ -z "${CONSOLETYPE}" ] && CONSOLETYPE="$(/sbin/consoletype)"
155 if [ "$CONSOLETYPE" = "vt" -a -x /sbin/setsysfont ]; then
161 # Print welcome message
162 nls "\t\t\t%sPowered by %sPLD Linux Distribution%s" "$(termput setaf $CPOWEREDBY)" "$(termput setaf $CPLD)" "$(termput op)"
163 if ! is_no "$RC_PROMPT"; then
164 nls -n "\t\t Press %sI%s to enter interactive startup" "$(termput setaf $CI)" "$(termput op)"
169 if [ -z "${HOSTNAME}" ]; then
170 show "$(nls 'Host:') $(hostname)" ; ok
172 run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME}
175 # Set the NIS domain name
176 if [ -n "$NISDOMAIN" ]; then
177 run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN
182 if ! is_yes "$VSERVER"; then
183 # Set console loglevel
184 if [ -n "$CONSOLE_LOGLEVEL" ]; then
185 /bin/dmesg -n $CONSOLE_LOGLEVEL
188 if [ -f /etc/udev/udev.conf ];then
189 . /etc/udev/udev.conf
192 [ -x /sbin/start_udev ] && /sbin/start_udev
194 # /dev must be also mounted before everything but only if we want use them ;-)
195 if is_yes "$MOUNT_DEVFS"; then
196 run_cmd "Mounting Device Filesystem" mount -n -t devfs /dev /dev
200 if [ -e /dev/.devfsd -a -x /sbin/devfsd ]; then
201 run_cmd "Starting Device Filesystem Daemon" /sbin/devfsd /dev
204 # Start logging console output since we have all /dev stuff setup
205 if [ "$RC_BOOTLOG" ]; then
209 # cpuset support (mounted unconditionally, shouldn't be a problem)
210 if grep -q cpuset /proc/filesystems 2>/dev/null ; then
211 # mkdir for udev (FIXME fix the udev instead)
212 mkdir -p /dev/cpuset 2>/dev/null
213 mount -n -t cpuset none /dev/cpuset
216 # Configure Linux kernel (initial configuration, some required modules still
218 /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
220 # Set the system clock.
225 if [ -f /etc/sysconfig/clock ]; then
226 . /etc/sysconfig/clock
228 # convert old style clock config to new values
229 if [ "${CLOCKMODE}" = "GMT" ]; then
231 elif [ "${CLOCKMODE}" = "ARC" ]; then
236 if grep "system serial" /proc/cpuinfo 2>/dev/null | grep -q MILO 2>/dev/null ; then
241 CLOCKFLAGS="--hctosys"
243 if is_yes "$UTC" ; then
244 CLOCKFLAGS="$CLOCKFLAGS --utc"
245 CLOCKDEF="$CLOCKDEF (utc)"
247 CLOCKFLAGS="$CLOCKFLAGS --localtime"
248 CLOCKDEF="$CLOCKDEF (local)"
251 if is_yes "$ARC" ; then
252 CLOCKFLAGS="$CLOCKFLAGS -A"
253 CLOCKDEF="$CLOCKDEF (arc)"
256 if is_yes "$SRM" ; then
257 CLOCKFLAGS="$CLOCKFLAGS -S"
258 CLOCKDEF="$CLOCKDEF (srm)"
261 # Check if timezone definition is available
262 if [ -e /etc/localtime -a -e /dev/rtc ] ; then
263 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
264 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
267 TIME_SETUP_DELAYED=yes
271 run_cmd "Activating swap partitions" swapon -a -e
273 # Initialize USB controllers
275 if ! strstr "$cmdline" "nousb" && ! grep -q "/proc/bus/usb" /proc/mounts 2>/dev/null ; then
276 aliases=$(/sbin/modprobe -c | awk '/^alias[\t ]+usb-controller/ { print $3 }')
277 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
278 /sbin/modprobe -s -k usbcore
279 for alias in $aliases ; do
280 [ "$alias" = "off" ] && continue
281 run_cmd "$(nls 'Initializing USB controller') ($alias)" /sbin/modprobe -s $alias
283 [ $? -eq 0 -a -n "$aliases" ] && usb=1
285 if grep -iq "usb" /proc/devices 2>/dev/null ; then
290 if [ "$usb" = "1" -a ! -f /proc/bus/usb/devices ]; then
291 run_cmd "Mounting USB filesystem" mount -n -t usbfs usbfs /proc/bus/usb
295 if [ "$usb" = "1" ]; then
296 needusbstorage=$(LC_ALL=C cat /proc/bus/usb/devices 2>/dev/null|grep -e "^I.*Cls=08" 2>/dev/null)
297 if [ "$(kernelverser)" -lt "002006" ]; then
298 LC_ALL=C grep -q 'hid' /proc/bus/usb/drivers 2>/dev/null || run_cmd "Initializing USB HID interface" modprobe hid 2> /dev/null
299 mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02" 2>/dev/null)
300 kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01" 2>/dev/null)
301 if [ -n "$kbdoutput" ]; then
302 run_cmd "Initializing USB keyboard" modprobe keybdev
304 if [ -n "$mouseoutput" ]; then
305 run_cmd "Initializing USB mouse" modprobe mousedev
310 # Setup hdparm thing (if exists and is needed)
311 if ! strstr "$cmdline" nohdparm; then
312 [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
315 if [ -f /fastboot ] || strstr "$cmdline" "fastboot"; then
321 if [ -f /fsckoptions ]; then
322 fsckoptions=$(cat /fsckoptions)
327 if [ -f /forcefsck ]; then
328 fsckoptions="-f $fsckoptions"
330 # Obey the fs_passno setting for / (see fstab(5))
332 # - make sure we have at least 6 fields
333 _ROOTFS_PASSNO=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $6}' /etc/fstab)
337 _ROOTFS_TYPE=$(awk '$2 == "/" && $3 != "rootfs" { print $3 }' /proc/mounts 2>/dev/null)
339 if [ -z "$fastboot" -a "$_ROOTFS_TYPE" != "nfs" -a "$_ROOTFS_TYPE" != "romfs" -a "$_ROOTFS_PASSNO" != 0 ]; then
340 show "Checking root filesystem"; started
341 initlog -c "fsck -C -T -a $fsckoptions /"
345 # A return of 4 or higher means there were serious problems.
346 if [ $rc -gt 3 ]; then
347 [ -e /proc/splash ] && echo "verbose" > /proc/splash
348 # don't use '\n' in nls macro !
351 nls "*** An error occurred during the file system check."
352 nls "*** Dropping you to a shell; the system will reboot"
353 nls "*** when you leave the shell."
356 PS1="`nls '(Repair filesystem)# '`"; export PS1
357 [ "$SELINUX" = "1" ] && disable_selinux
358 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
364 run_cmd "Unmounting file systems" umount -a
365 mount -n -o remount,ro /
366 run_cmd "Automatic reboot in progress" reboot
367 # A return of 2 or 3 means that filesystem was repaired but we need
369 elif [ "$rc" = "2" -o "$rc" = "3" ]; then
370 [ -e /proc/splash ] && echo "verbose" > /proc/splash
372 nls "*** Filesystem was repaired but system needs to be"
373 nls "*** rebooted before mounting it."
374 nls "*** REBOOTING ***"
377 run_cmd "Unmounting file systems" umount -a
378 mount -n -o remount,ro /
379 run_cmd "Automatic reboot in progress" reboot
380 elif [ "$rc" = "1" ]; then
385 # Unmount the initrd, if necessary
386 if LC_ALL=C grep -q /initrd /proc/mounts 2>/dev/null && ! LC_ALL=C grep -q /initrd/loopfs /proc/mounts 2>/dev/null ; then
387 if [ -e /initrd/dev/.devfsd ]; then
391 /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1
394 # Check for arguments
395 if strstr "$cmdline" nopnp; then
401 # set up pnp and kernel pnp
402 if [ -n "$PNP" ]; then
403 if ! is_no "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
404 run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf
406 if ! is_no "$RUN_KERNELPNP"; then
407 /sbin/modprobe -k isa-pnp 2> /dev/null
408 if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then
409 show "Setting up ISA PNP devices (kernelspace pnp)"; busy
410 grep -v "^#" /etc/isapnp/isapnp-kernel.conf 2>/dev/null >/proc/isapnp && (deltext; ok) || (deltext; fail)
415 # Remount the root filesystem read-write
416 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
418 # Update quotas if fsck was run on /
419 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
420 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vnug /
423 # Clean up SELinux labels
424 if [ -n "$SELINUX" ]; then
425 for file in /etc/mtab /etc/cryptomtab /etc/ld.so.cache ; do
426 [ -r $file ] && restorecon $file >/dev/null 2>&1
431 # Start logging console output since we have all /dev stuff setup
432 if [ "$RC_BOOTLOG" ]; then
437 # Remove stale backups
438 rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~
440 # Remove /etc/nologin when starting system
441 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
443 if ! is_no "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
444 show "Enabling Delay Login"; busy
446 nls "System bootup in progress - please wait" >> /etc/nologin
448 chmod 644 /etc/nologin
449 cp -fp /etc/nologin /etc/nologin.boot
453 # The root filesystem is now read-write, so we can now log via
454 # syslog() directly...
455 if [ -n "$IN_INITLOG" ]; then
459 if ! is_yes "$VSERVER"; then
462 [ -f /etc/cryptomtab ] && :>/etc/cryptomtab
464 # Enter root, /proc, /sys, devfs and other into mtab.
467 [ -f /proc/bus/usb/devices ] && mount -f -t usbfs usbfs /proc/bus/usb
468 [ -e /dev/.devfsd ] && mount -f -t devfs devfs /dev
470 if grep -q sysfs /proc/mounts 2>/dev/null; then
471 mount -f -t sysfs sysfs /sys
472 if grep -q securityfs /proc/mounts 2>/dev/null ; then
473 mount -f -t securityfs securityfs /sys/kernel/security
477 if grep -q selinuxfs /proc/mounts 2>/dev/null; then
478 mount -f -t selinuxfs selinuxfs /selinux
481 if grep -q cpuset /proc/mounts 2>/dev/null; then
482 mount -f -t cpuset none /dev/cpuset
485 if [ ! -f /proc/modules ]; then
487 elif ! strstr "$cmdline" nomodules; then
493 # Adjust symlinks as necessary in /boot to keep system services from
494 # spewing messages about mismatched System maps and so on.
495 if ! is_no "$SET_SLINKS"; then
497 if [ -L /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
498 ln -s -f System.map-$uname_r /boot/System.map
500 if [ ! -e /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
501 ln -s -f System.map-$uname_r /boot/System.map
506 # Run depmod if RUN_DEPMOD != "no" and:
507 # a) user requested or RUN_DEPMOD="";
508 # b) modules.dep is missing
509 # c) modules.dep is older than /etc/modules.conf or /lib/modules/`uname -r`
510 if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
511 if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then
512 run_cmd "Finding module dependencies" depmod -a
513 elif [ "$RUN_DEPMOD" = "ifmissing" ]; then
514 run_cmd "Finding module dependencies" depmod -A
518 if [ -f /proc/sys/kernel/modprobe ]; then
519 if [ -n "$USEMODULES" ]; then
520 sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
522 # We used to set this to NULL, but that causes
523 # 'failed to exec' messages"
524 sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
528 # Load usb storage here, to match most other things
529 if [ -n "$needusbstorage" ]; then
530 modprobe -k usb-storage >/dev/null 2>&1
533 # Load firewire devices
534 if ! strstr "$cmdline" nofirewire; then
535 aliases=$(/sbin/modprobe -c | awk '/^alias ieee1394-controller/ { print $3 }')
536 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
537 for alias in $aliases ; do
538 [ "$alias" = "off" ] && continue
539 run_cmd "$(nls 'Initializing firewire controller') ($alias)" /sbin/modprobe $alias
541 LC_ALL=C grep -E "SBP2" /proc/bus/ieee1394/devices 2>/dev/null && /sbin/modprobe -s sbp2 > /dev/null 2>&1
545 # Load sound modules if they need persistent DMA buffers
546 if [ $(kernelverser) = "002006" ]; then
547 MODULES_CONF=/etc/modprobe.conf
548 elif [ -r /etc/modules.conf ]; then
549 MODULES_CONF=/etc/modules.conf
551 MODULES_CONF=/etc/conf.modules
554 if grep -q "^options sound dmabuf=1" "$MODULES_CONF" 2>/dev/null ; then
556 alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
557 if [ -n "$alias" -a "$alias" != "off" ] ; then
558 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
561 alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound-slot-0[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
562 if [ -n "$alias" -a "$alias" != "off" ] ; then
563 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
569 if [ -x /etc/rc.d/rc.modules ]; then
573 # Activate dm-multipath
574 if [ -x /sbin/multipath ]; then
575 run_cmd "Activating dm-multipath" /sbin/multipath -v 0
576 for a in /dev/mapper/*; do
577 [ $a = /dev/mapper/control ] && continue
582 if [ -x /sbin/dmraid ]; then
583 run_cmd "Activating ATARAID devices" /sbin/dmraid -ay
586 # Find and activate volume groups:
588 if [ -x /sbin/evms_activate ]; then
589 if [ "$(kernelverser)" -lt "002006" ]; then
590 # Linux 2.4 core modules
591 modprobe -s -k evms > /dev/null 2>&1
592 modprobe -s -k evms_passthru > /dev/null 2>&1
593 modprobe -s -k ldev_mgr > /dev/null 2>&1
594 modprobe -s -k dos_part > /dev/null 2>&1
596 # Linux 2.6 core module
597 modprobe -s -k evmscore > /dev/null 2>&1
600 is_yes "$EVMS_GUID_PTABLE" && modprobe -s -k gpt_part >/dev/null 2>&1
601 is_yes "$EVMS_LVM" && modprobe -s -k lvm_vge >/dev/null 2>&1
602 is_yes "$EVMS_AIX" && modprobe -s -k AIXlvm_vge >/dev/null 2>&1
603 is_yes "$EVMS_OS2" && modprobe -s -k os2lvm_vge >/dev/null 2>&1
604 run_cmd "Discovering EVMS volumes" /sbin/evms_activate
605 if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then
606 # Link nodes for compatibility with LVM
607 if [ "$(echo /dev/evms/lvm/*)" != '/dev/evms/lvm/*' ] ; then
608 ln -s /dev/evms/lvm/* /dev
613 # LVM (keep in sync with LVM starting after RAID run!)
614 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
615 lvmversion=$(/sbin/vgchange --version 2>/dev/null | awk '{gsub("vgchange: Logical Volume Manager ",""); gsub("LVM version: ",""); gsub(/\..*/,"");print $1; exit}')
616 if [ "$lvmversion" = "1" ] ; then
617 modprobe -s -k lvm-mod >/dev/null 2>&1
619 elif [ "$lvmversion" = "2" ] ; then
620 modprobe -s -k dm-mod >/dev/null 2>&1
621 lvmignorelock="--ignorelockingfailure"
623 modprobe -s -k lvm-mod >/dev/null 2>&1
624 # device mapper (2.5+ and patched 2.4)
625 modprobe -s -k dm-mod >/dev/null 2>&1
629 run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelock && \
630 run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmignorelock
631 [ "$lvmversion" = "2" ] && /sbin/vgscan --mknodes $lvmignorelock > /dev/null 2>&1
636 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ] || [ -f /etc/raidtab ]; then
637 modprobe -s md >/dev/null 2>&1
638 if [ -f /proc/mdstat ]; then
642 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
643 if (grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null); then
644 run_cmd "Starting up RAID devices" /sbin/mdadm --assemble --scan --auto=yes
646 [ "$rc" -eq 0 ] && goraidtab=0 && golvm=1
650 if [ -f /etc/raidtab -a "$goraidtab" -eq 1 ]; then
651 for i in $(awk '!/^#/ && /raiddev/{print $2}' /etc/raidtab 2>/dev/null); do
653 RAIDDEV=$(basename $i)
654 RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat 2>/dev/null)
655 show "Starting up RAID device %s" $RAIDDEV
657 if [ -z "$RAIDSTAT" ]; then
658 # Try raidstart first...if that fails then
659 # fall back to raid0run and if that fails too
660 # fall back to raidadd, raidrun.
662 if [ -x /sbin/raidstart ]; then
666 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
670 if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
675 if [ $RESULT -gt 0 ]; then
687 # A non-zero return means there were problems
688 if [ $rc -gt 0 ]; then
689 [ -e /proc/splash ] && echo "verbose" > /proc/splash
690 show "Starting up RAID devices"; fail
693 nls "*** An error occurred during the RAID startup."
694 nls "*** Dropping you to a shell; the system will reboot"
695 nls "*** when you leave the shell."
698 PS1="$(nls '(RAID Repair)# ')"; export PS1
699 [ "$SELINUX" = "1" ] && disable_selinux
700 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
706 run_cmd "Unmounting file systems" umount -a
707 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
708 run_cmd "Automatic reboot in progress" reboot
710 # LVM on RAID (keep in sync with LVM setting few lines above)
711 if [ "$golvm" -eq "1" ]; then
712 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
713 run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmignorelock && \
714 run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmignorelock
715 [ "$lvmversion" = "2" ] && /sbin/vgscan --mknodes $lvmignorelock > /dev/null 2>&1
718 show "Starting up RAID devices"; ok
724 if [ -z "$fastboot" ] && ! strstr "$cmdline" nofsck; then
725 rc_splash "fsck start"
726 show "Checking filesystems"; started
727 initlog -c "fsck -C -T -R -A -a -P $fsckoptions"
731 # A return of 2 or higher means there were serious problems
732 if [ $rc -gt 1 ]; then
733 [ -e /proc/splash ] && echo "verbose" > /proc/splash
736 nls "*** An error occurred during the file system check."
737 nls "*** Dropping you to a shell; the system will reboot"
738 nls "*** when you leave the shell."
741 PS1="$(nls '(Repair filesystem)# ')"; export PS1
742 [ "$SELINUX" = "1" ] && disable_selinux
743 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
749 run_cmd "Unmounting file systems" umount -a
750 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
751 run_cmd "Automatic reboot in progress" reboot
752 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
755 rc_splash "fsck stop"
758 # Mount all other filesystems (except for NFS and /proc, which is already
759 # mounted). Contrary to standard usage,
760 # filesystems are NOT unmounted in single user mode.
762 run_cmd "Mounting local filesystems" mount -a -t nonfs,nfs4,smbfs,ncpfs,proc,cifs -O no_netdev
764 # now we have /usr mounted, recheck if we have gettext and tput available.
765 if is_no "$TPUT"; then
771 # Now do some workaround - encrypted filesystems couldn't have been fsck-ed
772 # before mount - that's where the password is entered.
773 # mount is buggy - when remounting loopback filesystem, loop=XXX
774 # option is removed from /etc/mtab
775 if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then
776 show "Checking encrypted filesystems"; started
777 LOOPLIST="$(LC_ALL=C awk '
778 FILENAME=="/proc/mounts" {
781 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ {
782 if ($2 in TAB){print TAB[$2];}
784 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
785 if ($2 in TAB){print TAB[$2];}
786 sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4);
787 cmd="mount " $2 " -o remount," $4;
790 ' /proc/mounts /etc/fstab)"
791 initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST"
794 # A return of 2 or higher means there were serious problems.
795 if [ $rc -gt 1 ]; then
796 [ -e /proc/splash ] && echo "verbose" > /proc/splash
799 nls "*** An error occurred during the file system check."
800 nls "*** Dropping you to a shell; the system will reboot"
801 nls "*** when you leave the shell."
804 PS1="$(nls '(Repair filesystem)# ')"; export PS1
805 [ "$SELINUX" = "1" ] && disable_selinux
806 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
812 run_cmd "Unmounting file systems" umount -a
813 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
814 run_cmd "Automatic reboot in progress" reboot
815 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
819 show "Remounting encrypted filesystems back in rw mode"; busy
821 FILENAME=="/proc/mounts" {
824 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
825 sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4);
826 cmd="mount " $2 " -o remount," $4;
829 ' /proc/mounts /etc/fstab
833 # /var/log should be writable now, so start saving the boot output
834 if [ "$RC_BOOTLOG" ]; then
835 echo > /var/log/boot.msg
839 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
840 run_cmd "Checking filesystem quotas" /sbin/quotacheck -vnugRa
844 if [ -x /sbin/quotaon ]; then
845 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug
848 # Turn on process accounting
849 if [ -x /etc/rc.d/rc.acct ]; then
850 /etc/rc.d/rc.acct start
853 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
854 if is_yes "$TIME_SETUP_DELAYED" && [ -e /dev/rtc ]; then
855 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
856 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
860 # Initialize the serial ports
861 if [ -f /etc/rc.d/rc.serial ]; then
862 . /etc/rc.d/rc.serial
865 if [ -f /proc/sys/kernel/panic -a -n "$PANIC_REBOOT_TIME" -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
866 show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy
867 if (sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1); then ok; else fail; fi
870 # ... and here finish configuring parameters
871 /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
873 # /var/log should be writable now, so start saving the boot output
874 if [ "$RC_BOOTLOG" ]; then
875 echo > /var/log/boot.msg
883 [ -n "$SELINUX" ] && [ -f /.autorelabel ] && relabel_selinux
886 rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff
889 for afile in /var/lock/* /var/run/*; do
891 if [ -d "$afile" ]; then
900 [ "$bafile" != "hwprofile" ] && rm -f $afile 2> /dev/null
904 rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \
905 /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.*
906 rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \
907 /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \
908 /tmp/scrollkeeper-* /tmp/ssh-*
912 if ! is_no "$NEED_XFILES"; then
915 chown root:utmp /var/run/utmpx /var/log/wtmpx
916 chmod 0664 /var/run/utmpx /var/log/wtmpx
920 chown root:utmp /var/run/utmp /var/log/wtmp
921 chmod 0664 /var/run/utmp /var/log/wtmp
925 if is_yes "$CLEAN_TMP"; then
926 # XXX LC_ALL needed here
927 rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
930 # System protected dirs
931 mkdir -m 1777 -p /tmp/.ICE-unix > /dev/null 2>&1
932 chown root:root /tmp/.ICE-unix
933 [ -n "$SELINUX" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1
935 if ! is_yes "$VSERVER"; then
936 run_cmd "Enabling swap space" /bin/true
937 # Right, now turn on swap in case we swap to files
938 swapon -a >/dev/null 2>&1
940 # If a SCSI tape has been detected, load the st module unconditionally
941 # since many SCSI tapes don't deal well with st being loaded and unloaded
942 if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then
943 if grep -qv ' 9 st' /proc/devices 2>/dev/null; then
944 if [ -n "$USEMODULES" ] ; then
945 # Try to load the module. If it fails, ignore it...
946 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
951 # Now that we have all of our basic modules loaded and the kernel going,
952 # let's dump the syslog ring somewhere so we can find it later
953 dmesg -s 131072 > /var/log/dmesg
955 while [ $i -ge 0 ]; do
956 if [ -f /var/log/dmesg.$i ]; then
957 chmod 0600 /var/log/dmesg.$i
958 mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1))
962 cp -f /var/log/dmesg /var/log/dmesg.0
963 chmod 0600 /var/log/dmesg /var/log/dmesg.0
966 kill -TERM $(/sbin/pidof getkey) >/dev/null 2>&1
969 # extra check if the background process we just spawned is still running,
970 # as in case of vserver bootup it finishes quite instantly.
971 if ! is_no "$RC_PROMPT" && [ -d /proc/$! ]; then
972 /sbin/getkey -c 5 i && touch /var/run/confirm
977 # This must be last line !