3 # /etc/rc.d/rc.sysinit - run once at boot time
6 # Taken in part from Miquel van Smoorenburg's bcheckrc.
7 # Changes: Arkadiusz Mi¶kiewicz <misiek@pld-linux.org>
11 PATH=/bin:/sbin:/usr/bin:/usr/sbin
14 # reasonable start values for bootsplash progress.
20 if [ -r /etc/sysconfig/i18n ]; then
22 [ -n "$LANG" ] && export LANG || unset LANG
23 [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
24 [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE
25 [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES
26 [ -n "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC
27 [ -n "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY
28 [ -n "$LC_TIME" ] && export LC_TIME || unset LC_TIME
29 [ -n "$LC_ALL" ] && export LC_ALL || unset LC_ALL
30 [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE
31 [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS
34 # Read network config data
35 if [ -r /etc/sysconfig/network ]; then
36 . /etc/sysconfig/network
45 . /etc/rc.d/init.d/functions
47 # boot logging to /var/log/boot.msg. install showconsole package to get it.
48 if [ -x /sbin/blogd ] && ! is_no "$RC_BOOTLOG"; then
54 if ! is_yes "$VSERVER" ; then
55 # we need /proc mounted before everything
56 mount -n -o gid=17 -t proc /proc /proc
58 # sysfs is also needed before any other things (under kernel > 2.5)
59 if grep -q sysfs /proc/filesystems 2>/dev/null ; then
60 mount -n -o gid=17 -t sysfs sysfs /sys
61 if [ "$(kernelver)" -ge "002006014" ] && \
62 grep -q securityfs /proc/filesystems 2>/dev/null ; then
63 mount -n -o gid=17 -t securityfs securityfs /sys/kernel/security
69 if grep -q selinuxfs /proc/filesystems 2>/dev/null && ! grep -q selinuxfs /proc/mounts 2>/dev/null; then
70 mount -n -o gid=17 -t selinuxfs selinuxfs /selinux
73 if [ $(kernelverser) = "002006" ]; then
74 MODULES_CONF=/etc/modprobe.conf
75 elif [ -r /etc/modules.conf ]; then
76 MODULES_CONF=/etc/modules.conf
78 MODULES_CONF=/etc/conf.modules
81 # PLD Linux LiveCD support
82 if [ -x /etc/rc.d/rc.live ]; then
86 # Choose Hardware profile
87 if [ -f /etc/sysconfig/hwprof ]; then
88 . /etc/sysconfig/hwprof
89 if is_yes "${HWPROFILES}" && [ -x /sbin/hwprofile -a -d /etc/sysconfig/hwprofiles/data ]; then
90 mount -n / -o rw,remount
92 mount -n / -o ro,remount
96 # Disable splash when requested
97 [ -e /proc/splash ] && is_no "$BOOT_SPLASH" && echo "0" > /proc/splash
99 # Check SELinux status
100 selinuxfs=$(awk '/ selinuxfs / { print $2 }' /proc/mounts 2> /dev/null)
102 if [ -n "$selinuxfs" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then
103 if [ -r $selinuxfs/enforce ] ; then
104 SELINUX=$(cat $selinuxfs/enforce)
106 # assume enforcing if you can't read it
111 if [ -x /sbin/restorecon ] && LC_ALL=C fgrep -q " /dev " /proc/mounts 2>/dev/null ; then
112 /sbin/restorecon -R /dev 2>/dev/null
116 if [ "$CONSOLETYPE" = "vt" -a -x /sbin/setsysfont ]; then
122 # Print welcome message
123 nls "\t\t\t%sPowered by %sPLD Linux Distribution%s" "$(termput setaf $CPOWEREDBY)" "$(termput setaf $CPLD)" "$(termput op)"
124 if ! is_no "$RC_PROMPT"; then
125 nls -n "\t\t Press %sI%s to enter interactive startup" "$(termput setaf $CI)" "$(termput op)"
130 run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME}
132 # Set the NIS domain name
133 if [ -n "$NISDOMAIN" ]; then
134 run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN
139 if ! is_yes "$VSERVER"; then
140 # Set console loglevel
141 if [ -n "$CONSOLE_LOGLEVEL" ]; then
142 /bin/dmesg -n $CONSOLE_LOGLEVEL
145 if [ -f /etc/udev/udev.conf ];then
146 . /etc/udev/udev.conf
149 [ -x /sbin/start_udev ] && /sbin/start_udev
151 # /dev must be also mounted before everything but only if we want use them ;-)
152 if is_yes "$MOUNT_DEVFS"; then
153 run_cmd "Mounting Device Filesystem" mount -n -t devfs /dev /dev
157 if [ -e /dev/.devfsd -a -x /sbin/devfsd ]; then
158 run_cmd "Starting Device Filesystem Daemon" /sbin/devfsd /dev
161 # cpuset support (mounted unconditionally, shouldn't be a problem)
162 if grep -q cpuset /proc/filesystems 2>/dev/null ; then
163 # mkdir for udev (FIXME fix the udev instead)
164 mkdir -p /dev/cpuset 2>/dev/null
165 mount -n -t cpuset none /dev/cpuset
168 # Start logging console output since we have all /dev stuff setup
169 if [ "$RC_BOOTLOG" ]; then
173 # Configure Linux kernel (initial configuration, some required modules still
175 /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
177 # Set the system clock.
182 if [ -f /etc/sysconfig/clock ]; then
183 . /etc/sysconfig/clock
185 # convert old style clock config to new values
186 if [ "${CLOCKMODE}" = "GMT" ]; then
188 elif [ "${CLOCKMODE}" = "ARC" ]; then
193 if grep "system serial" /proc/cpuinfo 2>/dev/null | grep -q MILO 2>/dev/null ; then
198 CLOCKFLAGS="--hctosys"
200 if is_yes "$UTC" ; then
201 CLOCKFLAGS="$CLOCKFLAGS --utc"
202 CLOCKDEF="$CLOCKDEF (utc)"
204 CLOCKFLAGS="$CLOCKFLAGS --localtime"
205 CLOCKDEF="$CLOCKDEF (local)"
208 if is_yes "$ARC" ; then
209 CLOCKFLAGS="$CLOCKFLAGS -A"
210 CLOCKDEF="$CLOCKDEF (arc)"
213 if is_yes "$SRM" ; then
214 CLOCKFLAGS="$CLOCKFLAGS -S"
215 CLOCKDEF="$CLOCKDEF (srm)"
218 # Check if timezone definition is available
219 if [ -e /etc/localtime ] ; then
220 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
221 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
224 TIME_SETUP_DELAYED=yes
228 run_cmd "Activating swap partitions" swapon -a -e
230 # Initialize USB controllers
232 if ! grep -iq "nousb" /proc/cmdline 2>/dev/null && ! grep -q "/proc/bus/usb" /proc/mounts 2>/dev/null ; then
233 aliases=$(/sbin/modprobe -c | awk '/^alias[\t ]+usb-controller/ { print $3 }')
234 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
235 /sbin/modprobe -s -k usbcore
236 for alias in $aliases ; do
237 [ "$alias" = "off" ] && continue
238 run_cmd "$(nls 'Initializing USB controller') ($alias)" /sbin/modprobe -s $alias
240 [ $? -eq 0 -a -n "$aliases" ] && usb=1
242 if grep -iq "usb" /proc/devices 2>/dev/null ; then
247 if [ "$usb" = "1" -a ! -f /proc/bus/usb/devices ]; then
248 run_cmd "Mounting USB filesystem" mount -t usbfs usbfs /proc/bus/usb
252 if [ "$usb" = "1" ]; then
253 needusbstorage=$(LC_ALL=C cat /proc/bus/usb/devices 2>/dev/null|grep -e "^I.*Cls=08" 2>/dev/null)
254 if [ "$(kernelverser)" -lt "002006" ]; then
255 LC_ALL=C grep -q 'hid' /proc/bus/usb/drivers 2>/dev/null || run_cmd "Initializing USB HID interface" modprobe hid 2> /dev/null
256 mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02" 2>/dev/null)
257 kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01" 2>/dev/null)
258 if [ -n "$kbdoutput" ]; then
259 run_cmd "Initializing USB keyboard" modprobe keybdev
261 if [ -n "$mouseoutput" ]; then
262 run_cmd "Initializing USB mouse" modprobe mousedev
267 # Setup hdparm thing (if exists and is needed)
268 if ! grep -iq nohdparm /proc/cmdline 2>/dev/null; then
269 [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
272 if [ -f /fastboot ] || grep -iq "fastboot" /proc/cmdline 2>/dev/null ; then
278 if [ -f /fsckoptions ]; then
279 fsckoptions=$(cat /fsckoptions)
284 if [ -f /forcefsck ]; then
285 fsckoptions="-f $fsckoptions"
287 # Obey the fs_passno setting for / (see fstab(5))
289 # - make sure we have 6 fields
290 _ROOTFS_PASSNO=$(awk '($1 ~ /^(\/|UUID|LABEL)/ && $2 == "/" && NF == 6) { print $6}' /etc/fstab)
294 _ROOTFS_TYPE=$(awk '$2 == "/" && $3 != "rootfs" { print $3 }' /proc/mounts 2>/dev/null)
296 if [ -z "$fastboot" -a "$_ROOTFS_TYPE" != "nfs" -a "$_ROOTFS_TYPE" != "romfs" -a "$_ROOTFS_PASSNO" != 0 ]; then
297 show "Checking root filesystem"; started
298 initlog -c "fsck -C -T -a $fsckoptions /"
302 # A return of 4 or higher means there were serious problems.
303 if [ $rc -gt 3 ]; then
304 [ -e /proc/splash ] && echo "verbose" > /proc/splash
305 # don't use '\n' in nls macro !
308 nls "*** An error occurred during the file system check."
309 nls "*** Dropping you to a shell; the system will reboot"
310 nls "*** when you leave the shell."
313 PS1="$(nls '(Repair filesystem)# ')"; export PS1
314 [ "$SELINUX" = "1" ] && disable_selinux
315 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
321 run_cmd "Unmounting file systems" umount -a
322 mount -n -o remount,ro /
323 run_cmd "Automatic reboot in progress" reboot
324 # A return of 2 or 3 means that filesystem was repaired but we need
326 elif [ "$rc" = "2" -o "$rc" = "3" ]; then
327 [ -e /proc/splash ] && echo "verbose" > /proc/splash
329 nls "*** Filesystem was repaired but system needs to be"
330 nls "*** rebooted before mounting it."
331 nls "*** REBOOTING ***"
334 run_cmd "Unmounting file systems" umount -a
335 mount -n -o remount,ro /
336 run_cmd "Automatic reboot in progress" reboot
337 elif [ "$rc" = "1" ]; then
342 # Unmount the initrd, if necessary
343 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
344 if [ -e /initrd/dev/.devfsd ]; then
348 /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1
351 # Check for arguments
352 if grep -iq nopnp /proc/cmdline 2>/dev/null; then
358 # set up pnp and kernel pnp
359 if [ -n "$PNP" ]; then
360 if ! is_no "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
361 run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf
363 if ! is_no "$RUN_KERNELPNP"; then
364 /sbin/modprobe -k isa-pnp 2> /dev/null
365 if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then
366 show "Setting up ISA PNP devices (kernelspace pnp)"; busy
367 grep -v "^#" /etc/isapnp/isapnp-kernel.conf 2>/dev/null >/proc/isapnp && (deltext; ok) || (deltext; fail)
372 # Remount the root filesystem read-write
373 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
375 # Update quotas if fsck was run on /
376 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
377 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vnug /
380 # Clean up SELinux labels
381 if [ -n "$SELINUX" ]; then
382 for file in /etc/mtab /etc/cryptomtab /etc/ld.so.cache ; do
383 [ -r $file ] && restorecon $file >/dev/null 2>&1
388 # Start logging console output since we have all /dev stuff setup
389 if [ "$RC_BOOTLOG" ]; then
394 # Remove stale backups
395 rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~
397 # Remove /etc/nologin when starting system
398 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
400 if ! is_no "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
401 show "Enabling Delay Login"; busy
403 nls "System bootup in progress - please wait" >> /etc/nologin
405 chmod 644 /etc/nologin
406 cp -fp /etc/nologin /etc/nologin.boot
410 # The root filesystem is now read-write, so we can now log via
411 # syslog() directly...
412 if [ -n "$IN_INITLOG" ]; then
416 if ! is_yes "$VSERVER"; then
419 [ -f /etc/cryptomtab ] && :>/etc/cryptomtab
421 # Enter root, /proc, /sys, devfs and other into mtab.
424 [ -f /proc/bus/usb/devices ] && mount -f -t usbfs usbfs /proc/bus/usb
425 [ -e /dev/.devfsd ] && mount -f -t devfs devfs /dev
427 if grep -q sysfs /proc/mounts 2>/dev/null; then
428 mount -f -t sysfs sysfs /sys
429 if grep -q securityfs /proc/mounts 2>/dev/null ; then
430 mount -f -t securityfs securityfs /sys/kernel/security
434 if grep -q selinuxfs /proc/mounts 2>/dev/null; then
435 mount -f -t selinuxfs selinuxfs /selinux
438 if grep -q cpuset /proc/mounts 2>/dev/null; then
439 mount -f -t cpuset none /dev/cpuset
442 if [ ! -f /proc/modules ]; then
444 elif ! grep -iq nomodules /proc/cmdline 2>/dev/null; then
450 # Adjust symlinks as necessary in /boot to keep system services from
451 # spewing messages about mismatched System maps and so on.
452 if ! is_no "$SET_SLINKS"; then
453 if [ -L /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
454 ln -s -f System.map-`uname -r` /boot/System.map
456 if [ ! -e /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
457 ln -s -f System.map-`uname -r` /boot/System.map
461 # Run depmod if RUN_DEPMOD != "no" and:
462 # a) user requested or RUN_DEPMOD="";
463 # b) modules.dep is missing
464 # c) modules.dep is older than /etc/modules.conf or /lib/modules/`uname -r`
465 if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
466 if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then
467 run_cmd "Finding module dependencies" depmod -a
468 elif [ "$RUN_DEPMOD" = "ifmissing" ]; then
469 run_cmd "Finding module dependencies" depmod -A
473 if [ -f /proc/sys/kernel/modprobe ]; then
474 if [ -n "$USEMODULES" ]; then
475 sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
477 # We used to set this to NULL, but that causes
478 # 'failed to exec' messages"
479 sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
483 # Load usb storage here, to match most other things
484 if [ -n "$needusbstorage" ]; then
485 modprobe -k usb-storage >/dev/null 2>&1
488 # Load firewire devices
489 if ! grep -iq "nofirewire" /proc/cmdline 2>/dev/null ; then
490 aliases=$(/sbin/modprobe -c | awk '/^alias ieee1394-controller/ { print $3 }')
491 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
492 for alias in $aliases ; do
493 [ "$alias" = "off" ] && continue
494 run_cmd "$(nls 'Initializing firewire controller') ($alias)" /sbin/modprobe $alias
496 LC_ALL=C grep -E "SBP2" /proc/bus/ieee1394/devices 2>/dev/null && /sbin/modprobe -s sbp2 > /dev/null 2>&1
500 # Load sound modules if they need persistent DMA buffers
501 if grep -q "^options sound dmabuf=1" "$MODULES_CONF" 2>/dev/null ; then
503 alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
504 if [ -n "$alias" -a "$alias" != "off" ] ; then
505 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
508 alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound-slot-0[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
509 if [ -n "$alias" -a "$alias" != "off" ] ; then
510 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
516 if [ -x /etc/rc.d/rc.modules ]; then
520 # Find and activate volume groups:
522 if [ -x /sbin/evms_activate ]; then
523 if [ "$(kernelverser)" -lt "002006" ]; then
524 # Linux 2.4 core modules
525 modprobe -s -k evms > /dev/null 2>&1
526 modprobe -s -k evms_passthru > /dev/null 2>&1
527 modprobe -s -k ldev_mgr > /dev/null 2>&1
528 modprobe -s -k dos_part > /dev/null 2>&1
530 # Linux 2.6 core module
531 modprobe -s -k evmscore > /dev/null 2>&1
534 is_yes "$EVMS_GUID_PTABLE" && modprobe -s -k gpt_part >/dev/null 2>&1
535 is_yes "$EVMS_LVM" && modprobe -s -k lvm_vge >/dev/null 2>&1
536 is_yes "$EVMS_AIX" && modprobe -s -k AIXlvm_vge >/dev/null 2>&1
537 is_yes "$EVMS_OS2" && modprobe -s -k os2lvm_vge >/dev/null 2>&1
538 run_cmd "Discovering EVMS volumes" /sbin/evms_activate
539 if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then
540 # Link nodes for compatibility with LVM
541 if [ "echo /dev/evms/lvm/*" != '/dev/evms/lvm/*' ] ; then
542 ln -s /dev/evms/lvm/* /dev/
546 # LVM (keep in sync with LVM starting after RAID run!)
547 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
548 lvmversion=$(/sbin/vgchange --version 2>/dev/null | awk '{gsub("vgchange: Logical Volume Manager ",""); gsub("LVM version: ",""); gsub(/\..*/,"");print $1; exit}')
549 if [ "$lvmversion" = "1" ] ; then
550 modprobe -s -k lvm-mod >/dev/null 2>&1
552 elif [ "$lvmversion" = "2" ] ; then
553 modprobe -s -k dm-mod >/dev/null 2>&1
554 lvmignorelock="--ignorelockingfailure"
556 modprobe -s -k lvm-mod >/dev/null 2>&1
557 # device mapper (2.5+ and patched 2.4)
558 modprobe -s -k dm-mod >/dev/null 2>&1
562 run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelock && \
563 run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmignorelock
564 [ "$lvmversion" = "2" ] && /sbin/vgscan --mknodes $lvmignorelock > /dev/null 2>&1
569 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ] || [ -f /etc/raidtab ]; then
570 modprobe -s md >/dev/null 2>&1
571 if [ -f /proc/mdstat ]; then
575 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
576 if (grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null); then
577 run_cmd "Starting up RAID devices" /sbin/mdadm --assemble --scan --auto=yes
579 [ "$rc" -eq 0 ] && goraidtab=0 && golvm=1
583 if [ -f /etc/raidtab -a "$goraidtab" -eq 1 ]; then
584 for i in $(grep -v "^#" /etc/raidtab 2>/dev/null | grep "raiddev" 2>/dev/null | awk '{print $2}') ; do
586 RAIDDEV=$(basename $i)
587 RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat 2>/dev/null)
588 show "Starting up RAID device %s" $RAIDDEV
590 if [ -z "$RAIDSTAT" ]; then
591 # Try raidstart first...if that fails then
592 # fall back to raid0run and if that fails too
593 # fall back to raidadd, raidrun.
595 if [ -x /sbin/raidstart ]; then
599 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
603 if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
608 if [ $RESULT -gt 0 ]; then
620 # A non-zero return means there were problems
621 if [ $rc -gt 0 ]; then
622 [ -e /proc/splash ] && echo "verbose" > /proc/splash
623 show "Starting up RAID devices"; fail
626 nls "*** An error occurred during the RAID startup."
627 nls "*** Dropping you to a shell; the system will reboot"
628 nls "*** when you leave the shell."
631 PS1="$(nls '(RAID Repair)# ')"; export PS1
632 [ "$SELINUX" = "1" ] && disable_selinux
633 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
639 run_cmd "Unmounting file systems" umount -a
640 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
641 run_cmd "Automatic reboot in progress" reboot
643 # LVM on RAID (keep in sync with LVM setting few lines above)
644 if [ "$golvm" -eq "1" ]; then
645 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
646 run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmignorelock && \
647 run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmignorelock
648 [ "$lvmversion" = "2" ] && /sbin/vgscan --mknodes $lvmignorelock > /dev/null 2>&1
651 show "Starting up RAID devices"; ok
657 if [ -z "$fastboot" ] && ! grep -q nofsck /proc/cmdline 2>/dev/null; then
658 rc_splash "fsck start"
659 show "Checking filesystems"; started
660 initlog -c "fsck -C -T -R -A -a -P $fsckoptions"
664 # A return of 2 or higher means there were serious problems
665 if [ $rc -gt 1 ]; then
666 [ -e /proc/splash ] && echo "verbose" > /proc/splash
669 nls "*** An error occurred during the file system check."
670 nls "*** Dropping you to a shell; the system will reboot"
671 nls "*** when you leave the shell."
674 PS1="$(nls '(Repair filesystem)# ')"; export PS1
675 [ "$SELINUX" = "1" ] && disable_selinux
676 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
682 run_cmd "Unmounting file systems" umount -a
683 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
684 run_cmd "Automatic reboot in progress" reboot
685 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
688 rc_splash "fsck stop"
691 # Mount all other filesystems (except for NFS and /proc, which is already
692 # mounted). Contrary to standard usage,
693 # filesystems are NOT unmounted in single user mode.
695 run_cmd "Mounting local filesystems" mount -a -t nonfs,smbfs,ncpfs,proc,cifs -O no_netdev
697 # now we have /usr mounted, recheck if we have gettext and tput available.
698 if is_no "$TPUT"; then
704 # Now do some workaround - encrypted filesystems couldn't have been fsck-ed
705 # before mount - that's where the password is entered.
706 # mount is buggy - when remounting loopback filesystem, loop=XXX
707 # option is removed from /etc/mtab
708 if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then
709 show "Checking encrypted filesystems"; started
711 FILENAME=="/proc/mounts" {
714 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ {
715 if ($2 in TAB){print TAB[$2];}
717 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
718 if ($2 in TAB){print TAB[$2];}
719 sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4);
720 cmd="mount " $2 " -o remount," $4;
723 ' /proc/mounts /etc/fstab)"
724 initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST"
727 # A return of 2 or higher means there were serious problems.
728 if [ $rc -gt 1 ]; then
729 [ -e /proc/splash ] && echo "verbose" > /proc/splash
732 nls "*** An error occurred during the file system check."
733 nls "*** Dropping you to a shell; the system will reboot"
734 nls "*** when you leave the shell."
737 PS1="`nls '(Repair filesystem)# '`"; export PS1
738 [ "$SELINUX" = "1" ] && disable_selinux
739 if ! is_no "$RUN_SULOGIN_ON_ERR"; then
745 run_cmd "Unmounting file systems" umount -a
746 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
747 run_cmd "Automatic reboot in progress" reboot
748 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
752 show "Remounting encrypted filesystems back in rw mode"; busy
754 FILENAME=="/proc/mounts" {
757 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
758 sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4);
759 cmd="mount " $2 " -o remount," $4;
762 ' /proc/mounts /etc/fstab
766 # /var/log should be writable now, so start saving the boot output
767 if [ "$RC_BOOTLOG" ]; then
768 echo > /var/log/boot.msg
772 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
773 run_cmd "Checking filesystem quotas" /sbin/quotacheck -vnugRa
777 if [ -x /sbin/quotaon ]; then
778 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug
781 # Turn on process accounting
782 if [ -x /etc/rc.d/rc.acct ]; then
783 /etc/rc.d/rc.acct start
786 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
787 if is_yes "$TIME_SETUP_DELAYED"; then
788 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
789 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
793 # Initialize the serial ports
794 if [ -f /etc/rc.d/rc.serial ]; then
795 . /etc/rc.d/rc.serial
798 if [ -f /proc/sys/kernel/panic -a -n "$PANIC_REBOOT_TIME" -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
799 show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy
800 if (sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1); then ok; else fail; fi
803 # ... and here finish configuring parameters
804 /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
806 # /var/log should be writable now, so star saving the boot output
807 if [ "$RC_BOOTLOG" ]; then
808 echo > /var/log/boot.msg
816 [ -n "$SELINUX" ] && [ -f /.autorelabel ] && relabel_selinux
819 rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff
822 # I'd use find, but /usr may not be mounted.
823 for afile in /var/lock/* /var/run/*; do
824 bafile=$(basename $afile)
825 if [ -d "$afile" ]; then
834 [ "$bafile" != "hwprofile" ] && rm -f $afile 2> /dev/null
838 rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \
839 /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.*
840 rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \
841 /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \
842 /tmp/scrollkeeper-* /tmp/ssh-*
846 if ! is_no "$NEED_XFILES" ; then
849 chown root:utmp /var/run/utmpx /var/log/wtmpx
850 chmod 0664 /var/run/utmpx /var/log/wtmpx
854 chown root:utmp /var/run/utmp /var/log/wtmp
855 chmod 0664 /var/run/utmp /var/log/wtmp
859 if is_yes "$CLEAN_TMP"; then
860 rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
863 # System protected dirs
864 mkdir -m 1777 -p /tmp/.ICE-unix > /dev/null 2>&1
865 chown root:root /tmp/.ICE-unix
866 [ -n "$SELINUX" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1
868 if ! is_yes "$VSERVER"; then
869 # Right, now turn on swap in case we swap to files
870 swapon -a >/dev/null 2>&1
871 run_cmd "Enabling swap space" /bin/true
873 # If a SCSI tape has been detected, load the st module unconditionally
874 # since many SCSI tapes don't deal well with st being loaded and unloaded
875 if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then
876 if grep -qv ' 9 st' /proc/devices 2>/dev/null; then
877 if [ -n "$USEMODULES" ] ; then
878 # Try to load the module. If it fails, ignore it...
879 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
884 # Now that we have all of our basic modules loaded and the kernel going,
885 # let's dump the syslog ring somewhere so we can find it later
886 dmesg -s 131072 > /var/log/dmesg
888 while [ $i -ge 0 ]; do
889 if [ -f /var/log/dmesg.$i ]; then
890 chmod 0600 /var/log/dmesg.$i
891 mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1))
895 cp -f /var/log/dmesg /var/log/dmesg.0
896 chmod 0600 /var/log/dmesg /var/log/dmesg.0
899 kill -TERM $(/sbin/pidof getkey) >/dev/null 2>&1
902 # extra check if the background process we just spawned is still running,
903 # as in case of vserver bootup it finishes quite instantly.
904 if ! is_no "$RC_PROMPT" && [ -d /proc/$! ]; then
905 /sbin/getkey -c 5 i && touch /var/run/confirm
910 # This must be last line !