3 # /etc/rc.d/rc.sysinit - run once at boot time
6 # Taken in part from Miquel van Smoorenburg's bcheckrc.
9 # reasonable start values for bootsplash progress.
15 if [ -r /etc/sysconfig/i18n ]; then
17 [ -n "$LANG" ] && export LANG || unset LANG
18 [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
19 [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE
20 [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES
21 [ -n "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC
22 [ -n "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY
23 [ -n "$LC_TIME" ] && export LC_TIME || unset LC_TIME
24 [ -n "$LC_ALL" ] && export LC_ALL || unset LC_ALL
25 [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE
26 [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS
29 # Read network config data
30 if [ -r /etc/sysconfig/network ]; then
31 . /etc/sysconfig/network
40 . /etc/rc.d/init.d/functions
43 typeset _d selinuxfs _t _r
45 while read _d selinuxfs _t _r; do
46 [ "$_t" = "selinuxfs" ] && break
48 echo "*** Warning -- SELinux is active"
49 echo "*** Disabling security enforcement for system recovery."
50 echo "*** Run 'setenforce 1' to reenable."
51 echo "0" > $selinuxfs/enforce
55 typeset _d selinuxfs _t _r
57 while read _d selinuxfs _t _r; do
58 [ "$_t" = "selinuxfs" ] && break
61 *** Warning -- SELinux relabel is required. ***
62 *** Disabling security enforcement. ***
63 *** Relabeling could take a very long time, ***
64 *** depending on file system size. ***
66 echo "0" > $selinuxfs/enforce
67 /sbin/fixfiles -F relabel > /dev/null 2>&1
69 echo "*** Enabling security enforcement. ***"
70 echo $SELINUX > $selinuxfs/enforce
73 # Remove duplicate entries from mtab (for vserver guest use only)
74 clean_vserver_mtab() {
76 while read device mountpoint line; do
77 grep -qs "$mountpoint" /etc/mtab.clean || \
78 echo "$device $mountpoint $line" >> /etc/mtab.clean
80 cat /etc/mtab.clean > /etc/mtab
85 # boot logging to /var/log/boot.msg. install showconsole package to get it.
86 if [ -x /sbin/blogd ] && ! is_no "$RC_BOOTLOG"; then
92 if ! is_yes "$VSERVER" ; then
93 # we need /proc mounted before everything
94 mount -n -o gid=17 -t proc /proc /proc
96 # Only read this once.
97 cmdline=$(cat /proc/cmdline)
99 # sysfs is also needed before any other things (under kernel > 2.5)
100 if grep -q sysfs /proc/filesystems 2>/dev/null ; then
101 mount -n -o gid=17 -t sysfs sysfs /sys
102 if [ "$(kernelver)" -ge "002006014" ] && \
103 grep -q securityfs /proc/filesystems 2>/dev/null ; then
104 mount -n -o gid=17 -t securityfs securityfs /sys/kernel/security
110 if grep -q selinuxfs /proc/filesystems 2>/dev/null && ! grep -q selinuxfs /proc/mounts 2>/dev/null; then
111 mount -n -o gid=17 -t selinuxfs selinuxfs /selinux
114 # PLD Linux LiveCD support
115 if [ -x /etc/rc.d/rc.live ]; then
119 # Choose Hardware profile
120 if [ -f /etc/sysconfig/hwprof ]; then
121 . /etc/sysconfig/hwprof
122 if is_yes "${HWPROFILES}" && [ -x /sbin/hwprofile -a -d /etc/sysconfig/hwprofiles/data ]; then
123 mount -n / -o rw,remount
125 mount -n / -o ro,remount
129 # Disable splash when requested
130 [ -e /proc/splash ] && is_no "$BOOT_SPLASH" && echo "0" > /proc/splash
132 # Check SELinux status
133 selinuxfs=$(awk '/ selinuxfs / { print $2 }' /proc/mounts 2> /dev/null)
135 if [ -n "$selinuxfs" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then
136 if [ -r $selinuxfs/enforce ] ; then
137 SELINUX=$(cat $selinuxfs/enforce)
139 # assume enforcing if you can't read it
144 if [ -x /sbin/restorecon ] && LC_ALL=C fgrep -q " /dev " /proc/mounts 2>/dev/null ; then
145 /sbin/restorecon -R /dev 2>/dev/null
149 [ -z "${CONSOLETYPE}" ] && CONSOLETYPE="$(/sbin/consoletype)"
151 if [ "$CONSOLETYPE" = "vt" -a -x /sbin/setsysfont ]; then
157 # Print welcome message
158 nls "\t\t\t%sPowered by %sPLD Linux Distribution%s" "$(termput setaf $CPOWEREDBY)" "$(termput setaf $CPLD)" "$(termput op)"
159 if ! is_no "$RC_PROMPT"; then
160 nls -n "\t\t Press %sI%s to enter interactive startup" "$(termput setaf $CI)" "$(termput op)"
165 if [ -z "${HOSTNAME}" ]; then
166 show "$(nls 'Host:') $(hostname)" ; ok
168 run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME}
171 # Set the NIS domain name
172 if [ -n "$NISDOMAIN" ]; then
173 run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN
178 if ! is_yes "$VSERVER"; then
179 # Set console loglevel
180 if [ -n "$CONSOLE_LOGLEVEL" ]; then
181 /bin/dmesg -n $CONSOLE_LOGLEVEL
184 [ -x /sbin/start_udev ] && /sbin/start_udev
186 # Unmount the initrd, if necessary
187 if grep -q /initrd /proc/mounts 2>/dev/null && ! grep -q /initrd/loopfs /proc/mounts 2>/dev/null; then
188 if [ -e /initrd/dev/.devfsd ]; then
191 umount /initrd/dev 2>/dev/null
193 /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1
196 # /dev must be also mounted before everything but only if we want use them ;-)
197 if is_yes "$MOUNT_DEVFS"; then
198 run_cmd "Mounting Device Filesystem" mount -n -t devfs /dev /dev
201 if [ -e /dev/.devfsd -a -x /sbin/devfsd ]; then
202 run_cmd "Starting Device Filesystem Daemon" /sbin/devfsd /dev
205 # Start logging console output since we have all /dev stuff setup
206 if [ "$RC_BOOTLOG" ]; then
210 # cpuset support (mounted unconditionally, shouldn't be a problem)
211 if grep -q cpuset /proc/filesystems 2>/dev/null ; then
212 # mkdir for udev (FIXME fix the udev instead)
213 mkdir -p /dev/cpuset 2>/dev/null
214 mount -n -t cpuset none /dev/cpuset
217 # Configure Linux kernel (initial configuration, some required modules still
219 /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
221 # Set the system clock.
226 if [ -f /etc/sysconfig/clock ]; then
227 . /etc/sysconfig/clock
229 # convert old style clock config to new values
230 if [ "${CLOCKMODE}" = "GMT" ]; then
232 elif [ "${CLOCKMODE}" = "ARC" ]; then
237 if grep "system serial" /proc/cpuinfo 2>/dev/null | grep -q MILO 2>/dev/null ; then
242 CLOCKFLAGS="--hctosys"
244 if is_yes "$UTC" ; then
245 CLOCKFLAGS="$CLOCKFLAGS --utc"
246 CLOCKDEF="$CLOCKDEF (utc)"
248 CLOCKFLAGS="$CLOCKFLAGS --localtime"
249 CLOCKDEF="$CLOCKDEF (local)"
252 if is_yes "$ARC" ; then
253 CLOCKFLAGS="$CLOCKFLAGS -A"
254 CLOCKDEF="$CLOCKDEF (arc)"
257 if is_yes "$SRM" ; then
258 CLOCKFLAGS="$CLOCKFLAGS -S"
259 CLOCKDEF="$CLOCKDEF (srm)"
262 # Check if timezone definition is available
263 if [ -e /etc/localtime -a -e /dev/rtc ] ; then
264 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
265 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
268 TIME_SETUP_DELAYED=yes
271 if [ -f /etc/crypttab ]; then
272 # XXX might need modules dep
273 # Device mapper & related initialization
274 if ! fgrep -q device-mapper /proc/devices; then
278 # but should do this before swapon?
279 . /etc/rc.d/init.d/cryptsetup
280 show "Starting disk encryption:"
281 init_crypto 0 && ok || fail
285 run_cmd "Activating swap partitions" swapon -a -e
287 # Initialize USB controllers
289 if ! strstr "$cmdline" "nousb" && ! grep -q "/proc/bus/usb" /proc/mounts 2>/dev/null ; then
290 aliases=$(/sbin/modprobe -c | awk '/^alias[\t ]+usb-controller/ { print $3 }')
291 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
292 /sbin/modprobe -s -k usbcore
293 for alias in $aliases ; do
294 [ "$alias" = "off" ] && continue
295 run_cmd "$(nls 'Initializing USB controller') ($alias)" /sbin/modprobe -s $alias
297 [ $? -eq 0 -a -n "$aliases" ] && usb=1
299 if grep -iq "usb" /proc/devices 2>/dev/null ; then
304 if [ "$usb" = "1" -a ! -f /proc/bus/usb/devices ]; then
305 run_cmd "Mounting USB filesystem" mount -n -t usbfs usbfs /proc/bus/usb
309 if [ "$usb" = "1" ]; then
310 needusbstorage=$(LC_ALL=C cat /proc/bus/usb/devices 2>/dev/null|grep -e "^I.*Cls=08" 2>/dev/null)
311 if [ "$(kernelverser)" -lt "002006" ]; then
312 LC_ALL=C grep -q 'hid' /proc/bus/usb/drivers 2>/dev/null || run_cmd "Initializing USB HID interface" modprobe hid 2> /dev/null
313 mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02" 2>/dev/null)
314 kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01" 2>/dev/null)
315 if [ -n "$kbdoutput" ]; then
316 run_cmd "Initializing USB keyboard" modprobe keybdev
318 if [ -n "$mouseoutput" ]; then
319 run_cmd "Initializing USB mouse" modprobe mousedev
324 # Setup hdparm thing (if exists and is needed)
325 if ! strstr "$cmdline" nohdparm; then
326 [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
329 if [ -f /fastboot ] || strstr "$cmdline" "fastboot"; then
335 if [ -f /fsckoptions ]; then
336 fsckoptions=$(cat /fsckoptions)
341 if [ -f /forcefsck ]; then
342 fsckoptions="-f $fsckoptions"
344 # Obey the fs_passno setting for / (see fstab(5))
346 # - make sure we have at least 6 fields
347 _ROOTFS_PASSNO=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $6}' /etc/fstab)
351 _ROOTFS_TYPE=$(awk '$2 == "/" && $3 != "rootfs" { print $3 }' /proc/mounts 2>/dev/null)
353 if [ -z "$fastboot" -a "$_ROOTFS_TYPE" != "nfs" -a "$_ROOTFS_TYPE" != "romfs" -a "$_ROOTFS_PASSNO" != 0 ]; then
354 show "Checking root filesystem"; started
355 initlog -c "fsck -C -T -a $fsckoptions /"
359 # A return of 4 or higher means there were serious problems.
360 if [ $rc -gt 3 ]; then
361 [ -e /proc/splash ] && echo "verbose" > /proc/splash
362 # don't use '\n' in nls macro !
365 nls "*** An error occurred during the file system check."
366 nls "*** Dropping you to a shell; the system will reboot"
367 nls "*** when you leave the shell."
370 PS1="`nls '(Repair filesystem)# '`"; export PS1
371 [ "$SELINUX" = "1" ] && disable_selinux
372 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
378 run_cmd "Unmounting file systems" umount -a
379 mount -n -o remount,ro /
380 run_cmd "Automatic reboot in progress" reboot
381 # A return of 2 or 3 means that filesystem was repaired but we need
383 elif [ "$rc" = "2" -o "$rc" = "3" ]; then
384 [ -e /proc/splash ] && echo "verbose" > /proc/splash
386 nls "*** Filesystem was repaired but system needs to be"
387 nls "*** rebooted before mounting it."
388 nls "*** REBOOTING ***"
391 run_cmd "Unmounting file systems" umount -a
392 mount -n -o remount,ro /
393 run_cmd "Automatic reboot in progress" reboot
394 elif [ "$rc" = "1" ]; then
399 # Check for arguments
400 if strstr "$cmdline" nopnp; then
406 # set up pnp and kernel pnp
407 if [ -n "$PNP" ]; then
408 if ! is_no "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
409 run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf
411 if ! is_no "$RUN_KERNELPNP"; then
412 /sbin/modprobe -k isa-pnp 2> /dev/null
413 if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then
414 show "Setting up ISA PNP devices (kernelspace pnp)"; busy
415 grep -v "^#" /etc/isapnp/isapnp-kernel.conf 2>/dev/null >/proc/isapnp && (deltext; ok) || (deltext; fail)
420 # Remount the root filesystem read-write
421 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
423 # Update quotas if fsck was run on /
424 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
425 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vnug /
428 # Clean up SELinux labels
429 if [ -n "$SELINUX" ]; then
430 for file in /etc/mtab /etc/cryptomtab /etc/ld.so.cache ; do
431 [ -r $file ] && restorecon $file >/dev/null 2>&1
435 if [ -f /etc/crypttab ]; then
436 # XXX, this must be probably done after random is initialized from /var/run/random-seed
437 show "Starting disk encryption using the RNG:"
438 init_crypto 1 && ok || fail
441 # Start logging console output since we have all /dev stuff setup
442 if [ "$RC_BOOTLOG" ]; then
447 # Remove stale backups
448 rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~
450 # Remove /etc/nologin when starting system
451 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
453 if ! is_no "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
454 show "Enabling Delay Login"; busy
456 nls "System bootup in progress - please wait" >> /etc/nologin
458 chmod 644 /etc/nologin
459 cp -fp /etc/nologin /etc/nologin.boot
463 # The root filesystem is now read-write, so we can now log via
464 # syslog() directly...
465 if [ -n "$IN_INITLOG" ]; then
469 if ! is_yes "$VSERVER"; then
472 [ -f /etc/cryptomtab ] && :>/etc/cryptomtab
474 # Enter root, /proc, /sys, devfs and other into mtab.
477 [ -f /proc/bus/usb/devices ] && mount -f -t usbfs usbfs /proc/bus/usb
478 [ -e /dev/.devfsd ] && mount -f -t devfs devfs /dev
480 if grep -q sysfs /proc/mounts 2>/dev/null; then
481 mount -f -t sysfs sysfs /sys
482 if grep -q securityfs /proc/mounts 2>/dev/null ; then
483 mount -f -t securityfs securityfs /sys/kernel/security
487 if grep -q selinuxfs /proc/mounts 2>/dev/null; then
488 mount -f -t selinuxfs selinuxfs /selinux
491 if grep -q cpuset /proc/mounts 2>/dev/null; then
492 mount -f -t cpuset none /dev/cpuset
495 if [ ! -f /proc/modules ]; then
497 elif ! strstr "$cmdline" nomodules; then
503 # Adjust symlinks as necessary in /boot to keep system services from
504 # spewing messages about mismatched System maps and so on.
505 if ! is_no "$SET_SLINKS"; then
507 if [ -L /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
508 ln -s -f System.map-$uname_r /boot/System.map
510 if [ ! -e /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
511 ln -s -f System.map-$uname_r /boot/System.map
516 # Run depmod if RUN_DEPMOD != "no" and:
517 # a) user requested or RUN_DEPMOD="";
518 # b) modules.dep is missing
519 # c) modules.dep is older than /etc/modules.conf or /lib/modules/`uname -r`
520 if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
521 if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then
522 run_cmd "Finding module dependencies" depmod -a
523 elif [ "$RUN_DEPMOD" = "ifmissing" ]; then
524 run_cmd "Finding module dependencies" depmod -A
528 if [ -f /proc/sys/kernel/modprobe ]; then
529 if [ -n "$USEMODULES" ]; then
530 sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
532 # We used to set this to NULL, but that causes
533 # 'failed to exec' messages"
534 sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
538 # Load usb storage here, to match most other things
539 if [ -n "$needusbstorage" ]; then
540 modprobe -k usb-storage >/dev/null 2>&1
543 # Load firewire devices
544 if ! strstr "$cmdline" nofirewire; then
545 aliases=$(/sbin/modprobe -c | awk '/^alias ieee1394-controller/ { print $3 }')
546 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
547 for alias in $aliases ; do
548 [ "$alias" = "off" ] && continue
549 run_cmd "$(nls 'Initializing firewire controller') ($alias)" /sbin/modprobe $alias
551 LC_ALL=C grep -E "SBP2" /proc/bus/ieee1394/devices 2>/dev/null && /sbin/modprobe -s sbp2 > /dev/null 2>&1
555 # Load sound modules if they need persistent DMA buffers
556 if [ $(kernelverser) = "002006" ]; then
557 MODULES_CONF=/etc/modprobe.conf
558 elif [ -r /etc/modules.conf ]; then
559 MODULES_CONF=/etc/modules.conf
561 MODULES_CONF=/etc/conf.modules
564 if grep -q "^options sound dmabuf=1" "$MODULES_CONF" 2>/dev/null ; then
566 alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
567 if [ -n "$alias" -a "$alias" != "off" ] ; then
568 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
571 alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound-slot-0[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
572 if [ -n "$alias" -a "$alias" != "off" ] ; then
573 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
579 if [ -x /etc/rc.d/rc.modules ]; then
583 if [ -x /sbin/multipath ]; then
584 # first make nodes that were discarded due (possible) new /dev mount
585 /sbin/dmsetup mknodes
586 run_cmd "Activating dm-multipath" /sbin/multipath -v 0
587 /sbin/dmsetup ls --target multipath --exec '/sbin/kpartx -a'
590 if [ -x /sbin/dmraid ]; then
591 run_cmd "Activating ATARAID devices" /sbin/dmraid -ay
594 # Find and activate volume groups:
596 if [ -x /sbin/evms_activate ]; then
597 if [ "$(kernelverser)" -lt "002006" ]; then
598 # Linux 2.4 core modules
599 modprobe -s -k evms > /dev/null 2>&1
600 modprobe -s -k evms_passthru > /dev/null 2>&1
601 modprobe -s -k ldev_mgr > /dev/null 2>&1
602 modprobe -s -k dos_part > /dev/null 2>&1
604 # Linux 2.6 core module
605 modprobe -s -k evmscore > /dev/null 2>&1
608 is_yes "$EVMS_GUID_PTABLE" && modprobe -s -k gpt_part >/dev/null 2>&1
609 is_yes "$EVMS_LVM" && modprobe -s -k lvm_vge >/dev/null 2>&1
610 is_yes "$EVMS_AIX" && modprobe -s -k AIXlvm_vge >/dev/null 2>&1
611 is_yes "$EVMS_OS2" && modprobe -s -k os2lvm_vge >/dev/null 2>&1
612 run_cmd "Discovering EVMS volumes" /sbin/evms_activate
613 if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then
614 # Link nodes for compatibility with LVM
615 if [ "$(echo /dev/evms/lvm/*)" != '/dev/evms/lvm/*' ] ; then
616 ln -s /dev/evms/lvm/* /dev
621 # LVM (keep in sync with LVM starting after RAID run!)
622 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
623 lvmversion=$(/sbin/vgchange --version 2>/dev/null | awk '{gsub("vgchange: Logical Volume Manager ",""); gsub("LVM version: ",""); gsub(/\..*/,"");print $1; exit}')
624 if [ "$lvmversion" = "1" ] ; then
625 modprobe -s -k lvm-mod >/dev/null 2>&1
627 elif [ "$lvmversion" = "2" ] ; then
628 modprobe -s -k dm-mod >/dev/null 2>&1
629 lvmignorelock="--ignorelockingfailure"
631 modprobe -s -k lvm-mod >/dev/null 2>&1
632 # device mapper (2.5+ and patched 2.4)
633 modprobe -s -k dm-mod >/dev/null 2>&1
637 run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelock
638 run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmignorelock
639 [ "$lvmversion" = "2" ] && /sbin/vgmknodes
643 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ] || [ -f /etc/raidtab ]; then
644 modprobe -s md >/dev/null 2>&1
645 if [ -f /proc/mdstat ]; then
649 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
650 if (grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null); then
651 run_cmd "Starting up RAID devices" /sbin/mdadm --assemble --scan --auto=yes
653 [ "$rc" -eq 0 ] && goraidtab=0 && golvm=1
657 if [ -f /etc/raidtab -a "$goraidtab" -eq 1 ]; then
658 for i in $(awk '!/^#/ && /raiddev/{print $2}' /etc/raidtab 2>/dev/null); do
660 RAIDDEV=$(basename $i)
661 RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat 2>/dev/null)
662 show "Starting up RAID device %s" $RAIDDEV
664 if [ -z "$RAIDSTAT" ]; then
665 # Try raidstart first...if that fails then
666 # fall back to raid0run and if that fails too
667 # fall back to raidadd, raidrun.
669 if [ -x /sbin/raidstart ]; then
673 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
677 if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
682 if [ $RESULT -gt 0 ]; then
694 # A non-zero return means there were problems
695 if [ $rc -gt 0 ]; then
696 [ -e /proc/splash ] && echo "verbose" > /proc/splash
697 show "Starting up RAID devices"; fail
700 nls "*** An error occurred during the RAID startup."
701 nls "*** Dropping you to a shell; the system will reboot"
702 nls "*** when you leave the shell."
705 PS1="$(nls '(RAID Repair)# ')"; export PS1
706 [ "$SELINUX" = "1" ] && disable_selinux
707 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
713 run_cmd "Unmounting file systems" umount -a
714 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
715 run_cmd "Automatic reboot in progress" reboot
717 # LVM on RAID (keep in sync with LVM setting few lines above)
718 if [ "$golvm" -eq "1" ]; then
719 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
720 run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmignorelock
721 run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmignorelock
722 [ "$lvmversion" = "2" ] && /sbin/vgmknodes
725 show "Starting up RAID devices"; ok
731 if [ -z "$fastboot" ] && ! strstr "$cmdline" nofsck; then
732 rc_splash "fsck start"
733 show "Checking filesystems"; started
734 initlog -c "fsck -C -T -R -A -a -P $fsckoptions"
738 # A return of 2 or higher means there were serious problems
739 if [ $rc -gt 1 ]; then
740 [ -e /proc/splash ] && echo "verbose" > /proc/splash
743 nls "*** An error occurred during the file system check."
744 nls "*** Dropping you to a shell; the system will reboot"
745 nls "*** when you leave the shell."
748 PS1="$(nls '(Repair filesystem)# ')"; export PS1
749 [ "$SELINUX" = "1" ] && disable_selinux
750 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
756 run_cmd "Unmounting file systems" umount -a
757 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
758 run_cmd "Automatic reboot in progress" reboot
759 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
762 rc_splash "fsck stop"
765 # Mount all other filesystems (except for NFS and /proc, which is already
766 # mounted). Contrary to standard usage,
767 # filesystems are NOT unmounted in single user mode.
769 run_cmd "Mounting local filesystems" mount -a -t nonfs,nfs4,smbfs,ncpfs,proc,cifs -O no_netdev
771 # now we have /usr mounted, recheck if we have gettext and tput available.
772 if is_no "$TPUT"; then
778 # Now do some workaround - encrypted filesystems couldn't have been fsck-ed
779 # before mount - that's where the password is entered.
780 # mount is buggy - when remounting loopback filesystem, loop=XXX
781 # option is removed from /etc/mtab
782 if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then
783 show "Checking encrypted filesystems"; started
784 LOOPLIST="$(LC_ALL=C awk '
785 FILENAME=="/proc/mounts" {
788 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ {
789 if ($2 in TAB){print TAB[$2];}
791 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
792 if ($2 in TAB){print TAB[$2];}
793 sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4);
794 cmd="mount " $2 " -o remount," $4;
797 ' /proc/mounts /etc/fstab)"
798 initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST"
801 # A return of 2 or higher means there were serious problems.
802 if [ $rc -gt 1 ]; then
803 [ -e /proc/splash ] && echo "verbose" > /proc/splash
806 nls "*** An error occurred during the file system check."
807 nls "*** Dropping you to a shell; the system will reboot"
808 nls "*** when you leave the shell."
811 PS1="$(nls '(Repair filesystem)# ')"; export PS1
812 [ "$SELINUX" = "1" ] && disable_selinux
813 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
819 run_cmd "Unmounting file systems" umount -a
820 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
821 run_cmd "Automatic reboot in progress" reboot
822 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
826 show "Remounting encrypted filesystems back in rw mode"; busy
828 FILENAME=="/proc/mounts" {
831 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
832 sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4);
833 cmd="mount " $2 " -o remount," $4;
836 ' /proc/mounts /etc/fstab
840 # /var/log should be writable now, so start saving the boot output
841 if [ "$RC_BOOTLOG" ]; then
842 echo > /var/log/boot.msg
846 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
847 run_cmd "Checking filesystem quotas" /sbin/quotacheck -vnugRa
851 if [ -x /sbin/quotaon ]; then
852 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug
855 # Turn on process accounting
856 if [ -x /etc/rc.d/rc.acct ]; then
857 /etc/rc.d/rc.acct start
860 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
861 if is_yes "$TIME_SETUP_DELAYED" && [ -e /dev/rtc ]; then
862 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
863 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
867 # Initialize the serial ports
868 if [ -f /etc/rc.d/rc.serial ]; then
869 . /etc/rc.d/rc.serial
872 if [ -f /proc/sys/kernel/panic -a -n "$PANIC_REBOOT_TIME" -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
873 show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy
874 if (sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1); then ok; else fail; fi
877 # ... and here finish configuring parameters
878 /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
880 # /var/log should be writable now, so start saving the boot output
881 if [ "$RC_BOOTLOG" ]; then
882 echo > /var/log/boot.msg
890 [ -n "$SELINUX" ] && [ -f /.autorelabel ] && relabel_selinux
893 rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff
896 for afile in /var/lock/* /var/run/*; do
898 if [ -d "$afile" ]; then
907 [ "$bafile" != "hwprofile" ] && rm -f $afile 2> /dev/null
911 rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \
912 /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.*
913 rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \
914 /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \
915 /tmp/scrollkeeper-* /tmp/ssh-*
919 if ! is_no "$NEED_XFILES"; then
922 chown root:utmp /var/run/utmpx /var/log/wtmpx
923 chmod 0664 /var/run/utmpx /var/log/wtmpx
927 chown root:utmp /var/run/utmp /var/log/wtmp
928 chmod 0664 /var/run/utmp /var/log/wtmp
932 if is_yes "$CLEAN_TMP"; then
933 # XXX LC_ALL needed here
934 rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
937 # System protected dirs
938 mkdir -m 1777 -p /tmp/.ICE-unix > /dev/null 2>&1
939 chown root:root /tmp/.ICE-unix
940 [ -n "$SELINUX" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1
942 if ! is_yes "$VSERVER"; then
943 run_cmd "Enabling swap space" /bin/true
944 # Right, now turn on swap in case we swap to files
945 swapon -a >/dev/null 2>&1
947 # If a SCSI tape has been detected, load the st module unconditionally
948 # since many SCSI tapes don't deal well with st being loaded and unloaded
949 if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then
950 if grep -qv ' 9 st' /proc/devices 2>/dev/null; then
951 if [ -n "$USEMODULES" ] ; then
952 # Try to load the module. If it fails, ignore it...
953 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
958 # Now that we have all of our basic modules loaded and the kernel going,
959 # let's dump the syslog ring somewhere so we can find it later
960 dmesg -s 131072 > /var/log/dmesg
962 while [ $i -ge 0 ]; do
963 if [ -f /var/log/dmesg.$i ]; then
964 chmod 0600 /var/log/dmesg.$i
965 mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1))
969 cp -f /var/log/dmesg /var/log/dmesg.0
970 chmod 0600 /var/log/dmesg /var/log/dmesg.0
973 kill -TERM $(/sbin/pidof getkey) >/dev/null 2>&1
976 # extra check if the background process we just spawned is still running,
977 # as in case of vserver bootup it finishes quite instantly.
978 if ! is_no "$RC_PROMPT" && [ -d /proc/$! ]; then
979 /sbin/getkey -c 5 i && touch /var/run/confirm
984 # This must be last line !