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
42 # Read system config data
43 if [ -r /etc/sysconfig/system ]; then
44 . /etc/sysconfig/system
46 RUN_SULOGIN_ON_ERR=yes
58 . /etc/rc.d/init.d/functions
60 if ! is_yes "$VSERVER" ; then
61 # we need /proc mounted before everything
62 mount -n -o gid=17 -t proc /proc /proc
64 # sysfs is also needed before any other things (under kernel > 2.5)
65 if grep -q sysfs /proc/filesystems 2>/dev/null ; then
66 mount -n -o gid=17 -t sysfs sysfs /sys
67 if [ "$(kernelver)" -ge "002006014" ] && \
68 grep -q securityfs /proc/filesystems 2>/dev/null ; then
69 mount -n -o gid=17 -t securityfs securityfs /sys/kernel/security
75 if grep -q selinuxfs /proc/filesystems 2>/dev/null && ! grep -q selinuxfs /proc/mounts 2>/dev/null; then
76 mount -n -o gid=17 -t selinuxfs selinuxfs /selinux
79 if [ $(kernelverser) = "002006" ]; then
80 MODULES_CONF=/etc/modprobe.conf
81 elif [ -r /etc/modules.conf ]; then
82 MODULES_CONF=/etc/modules.conf
84 MODULES_CONF=/etc/conf.modules
88 if [ -x /etc/rc.d/rc.live ]; then
92 # Choose Hardware profile
93 if [ -f /etc/sysconfig/hwprof ]; then
94 . /etc/sysconfig/hwprof
95 if is_yes "${HWPROFILES}" && [ -x /sbin/hwprofile -a -d /etc/sysconfig/hwprofiles/data ]; then
96 mount -n / -o rw,remount
98 mount -n / -o ro,remount
102 # Disable splash when requested
103 [ -e /proc/splash ] && is_no "$BOOT_SPLASH" && echo "0" > /proc/splash
105 # Check SELinux status
106 selinuxfs=$(awk '/ selinuxfs / { print $2 }' /proc/mounts 2> /dev/null)
108 if [ -n "$selinuxfs" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then
109 if [ -r $selinuxfs/enforce ] ; then
110 SELINUX=$(cat $selinuxfs/enforce)
112 # assume enforcing if you can't read it
117 if [ -x /sbin/restorecon ] && LC_ALL=C fgrep -q " /dev " /proc/mounts 2>/dev/null ; then
118 /sbin/restorecon -R /dev 2>/dev/null
122 if [ "$CONSOLETYPE" = "vt" -a -x /sbin/setsysfont ]; then
127 # Print welcome message
128 nls "\t\t\t%sPowered by %sPLD Linux Distribution%s" "$(termput setaf $CPOWEREDBY)" "$(termput setaf $CPLD)" "$(termput op)"
129 if ! is_no "$RC_PROMPT"; then
130 nls -n "\t\t Press %sI%s to enter interactive startup" "$(termput setaf $CI)" "$(termput op)"
136 run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME}
138 # Set the NIS domain name
139 if [ -n "$NISDOMAIN" ]; then
140 run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN
145 if ! is_yes "$VSERVER"; then
146 # Set console loglevel
147 if [ -n "$CONSOLE_LOGLEVEL" ]; then
148 /bin/dmesg -n $CONSOLE_LOGLEVEL
151 if [ -f /etc/udev/udev.conf ];then
152 . /etc/udev/udev.conf
155 [ -x /sbin/start_udev ] && /sbin/start_udev
157 # /dev must be also mounted before everything but only if we want use them ;-)
158 if is_yes "$MOUNT_DEVFS"; then
159 run_cmd "Mounting Device Filesystem" mount -n -t devfs /dev /dev
163 if [ -e /dev/.devfsd -a -x /sbin/devfsd ]; then
164 run_cmd "Starting Device Filesystem Daemon" /sbin/devfsd /dev
167 # cpuset support (mounted unconditionally, shouldn't be a problem)
168 if grep -q cpuset /proc/filesystems 2>/dev/null ; then
169 mount -n -t cpuset none /dev/cpuset
172 # Configure Linux kernel (initial configuration, some required modules still
174 /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
176 # Set the system clock.
181 if [ -f /etc/sysconfig/clock ]; then
182 . /etc/sysconfig/clock
184 # convert old style clock config to new values
185 if [ "${CLOCKMODE}" = "GMT" ]; then
187 elif [ "${CLOCKMODE}" = "ARC" ]; then
192 if grep "system serial" /proc/cpuinfo 2>/dev/null | grep -q MILO 2>/dev/null ; then
197 CLOCKFLAGS="--hctosys"
199 if is_yes "$UTC" ; then
200 CLOCKFLAGS="$CLOCKFLAGS --utc"
201 CLOCKDEF="$CLOCKDEF (utc)"
203 CLOCKFLAGS="$CLOCKFLAGS --localtime"
204 CLOCKDEF="$CLOCKDEF (local)"
207 if is_yes "$ARC" ; then
208 CLOCKFLAGS="$CLOCKFLAGS -A"
209 CLOCKDEF="$CLOCKDEF (arc)"
212 if is_yes "$SRM" ; then
213 CLOCKFLAGS="$CLOCKFLAGS -S"
214 CLOCKDEF="$CLOCKDEF (srm)"
217 # Check if timezone definition is available
218 if [ -e /etc/localtime ] ; then
219 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
220 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
223 TIME_SETUP_DELAYED=yes
227 run_cmd "Activating swap partitions" swapon -a -e
229 # Initialize USB controllers
231 if ! grep -iq "nousb" /proc/cmdline 2>/dev/null && ! grep -q "/proc/bus/usb" /proc/mounts 2>/dev/null ; then
232 aliases=$(/sbin/modprobe -c | awk '/^alias usb-controller/ { print $3 }')
233 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
234 /sbin/modprobe -s -k usbcore
235 for alias in $aliases ; do
236 [ "$alias" = "off" ] && continue
237 run_cmd "$(nls 'Initializing USB controller') ($alias)" /sbin/modprobe -s $alias
239 [ $? -eq 0 -a -n "$aliases" ] && usb=1
241 if grep -iq "usb" /proc/devices 2>/dev/null ; then
246 if [ "$usb" = "1" -a ! -f /proc/bus/usb/devices ]; then
247 run_cmd "Mounting USB filesystem" mount -t usbfs usbfs /proc/bus/usb
251 if [ "$usb" = "1" ]; then
252 needusbstorage=$(LC_ALL=C cat /proc/bus/usb/devices 2>/dev/null|grep -e "^I.*Cls=08" 2>/dev/null)
253 if [ "$(kernelverser)" -lt "002006" ]; then
254 LC_ALL=C grep -q 'hid' /proc/bus/usb/drivers 2>/dev/null || run_cmd "Initializing USB HID interface" modprobe hid 2> /dev/null
255 mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02" 2>/dev/null)
256 kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01" 2>/dev/null)
257 if [ -n "$kbdoutput" ]; then
258 run_cmd "Initializing USB keyboard" modprobe keybdev
260 if [ -n "$mouseoutput" ]; then
261 run_cmd "Initializing USB mouse" modprobe mousedev
266 # Setup hdparm thing (if exists and is needed)
267 if ! grep -iq nohdparm /proc/cmdline 2>/dev/null; then
268 [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
271 if [ -f /fastboot ] || grep -iq "fastboot" /proc/cmdline 2>/dev/null ; then
277 if [ -f /fsckoptions ]; then
278 fsckoptions=$(cat /fsckoptions)
283 if [ -f /forcefsck ]; then
284 fsckoptions="-f $fsckoptions"
288 _ROOTFS_TYPE=$(grep " / " /proc/mounts 2>/dev/null | awk '{ print $3 }')
290 if [ -z "$fastboot" -a "$_ROOTFS_TYPE" != "nfs" -a "$_ROOTFS_TYPE" != "romfs" ]; then
291 show "Checking root filesystem"; started
292 initlog -c "fsck -C -T -a $fsckoptions /"
296 # A return of 4 or higher means there were serious problems.
297 if [ $rc -gt 3 ]; then
298 [ -e /proc/splash ] && echo "verbose" > /proc/splash
299 # don't use '\n' in nls macro !
302 nls "*** An error occurred during the file system check."
303 nls "*** Dropping you to a shell; the system will reboot"
304 nls "*** when you leave the shell."
307 PS1="$(nls '(Repair filesystem)# ')"; export PS1
308 [ "$SELINUX" = "1" ] && disable_selinux
309 if is_yes "$RUN_SULOGIN_ON_ERR"; then
315 run_cmd "Unmounting file systems" umount -a
316 mount -n -o remount,ro /
317 run_cmd "Automatic reboot in progress" reboot
318 # A return of 2 or 3 means that filesystem was repaired but we need
320 elif [ "$rc" = "2" -o "$rc" = "3" ]; then
321 [ -e /proc/splash ] && echo "verbose" > /proc/splash
323 nls "*** Filesystem was repaired but system needs to be"
324 nls "*** rebooted before mounting it."
325 nls "*** REBOOTING ***"
328 run_cmd "Unmounting file systems" umount -a
329 mount -n -o remount,ro /
330 run_cmd "Automatic reboot in progress" reboot
331 elif [ "$rc" = "1" ]; then
336 # Unmount the initrd, if necessary
337 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
338 if [ -e /initrd/dev/.devfsd ]; then
342 /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1
345 # Check for arguments
346 if grep -iq nopnp /proc/cmdline 2>/dev/null; then
352 # set up pnp and kernel pnp
353 if [ -n "$PNP" ]; then
354 if is_yes "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
355 run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf
357 if is_yes "$RUN_KERNELPNP"; then
358 /sbin/modprobe -k isa-pnp 2> /dev/null
359 if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then
360 show "Setting up ISA PNP devices (kernelspace pnp)"; busy
361 grep -v "^#" /etc/isapnp/isapnp-kernel.conf 2>/dev/null >/proc/isapnp && (deltext; ok) || (deltext; fail)
366 # Remount the root filesystem read-write
367 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
369 # Update quotas if fsck was run on /
370 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
371 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vnug /
375 # Clean up SELinux labels
376 if [ -n "$SELINUX" ]; then
377 for file in /etc/mtab /etc/cryptomtab /etc/ld.so.cache ; do
378 [ -r $file ] && restorecon $file >/dev/null 2>&1
382 # Remove stale backups
383 rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~
385 # Remove /etc/nologin when starting system
386 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
388 if is_yes "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
389 show "Enabling Delay Login"; busy
391 nls "System bootup in progress - please wait" >> /etc/nologin
393 chmod 644 /etc/nologin
394 cp -fp /etc/nologin /etc/nologin.boot
398 # The root filesystem is now read-write, so we can now log via
399 # syslog() directly...
400 if [ -n "$IN_INITLOG" ]; then
404 if ! is_yes "$VSERVER"; then
407 [ -f /etc/cryptomtab ] && :>/etc/cryptomtab
409 # Enter root, /proc, /sys, devfs and other into mtab.
412 [ -f /proc/bus/usb/devices ] && mount -f -t usbfs usbfs /proc/bus/usb
413 [ -e /dev/.devfsd ] && mount -f -t devfs devfs /dev
415 if grep -q sysfs /proc/filesystems 2>/dev/null ; then
416 mount -f -t sysfs sysfs /sys
417 if [ "$(kernelver)" -ge "002006014" ] && \
418 grep -q securityfs /proc/filesystems 2>/dev/null ; then
419 mount -f -t securityfs securityfs /sys/kernel/security
423 if grep -q selinuxfs /proc/filesystems 2>/dev/null ; then
424 mount -f -t selinuxfs selinuxfs /selinux
427 if grep -q cpuset /proc/filesystems 2>/dev/null ; then
428 mount -f -t cpuset none /dev/cpuset
431 if [ ! -f /proc/modules ]; then
433 elif ! grep -iq nomodules /proc/cmdline 2>/dev/null; then
439 # Adjust symlinks as necessary in /boot to keep system services from
440 # spewing messages about mismatched System maps and so on.
441 if is_yes "$SET_SLINKS"; then
442 if [ -L /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
443 ln -s -f System.map-`uname -r` /boot/System.map
445 if [ ! -e /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
446 ln -s -f System.map-`uname -r` /boot/System.map
450 # Run depmod if RUN_DEPMOD != "no" and:
451 # a) user requested or RUN_DEPMOD="";
452 # b) modules.dep is missing
453 # c) modules.dep is older than /etc/modules.conf or /lib/modules/`uname -r`
454 if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
455 if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then
456 run_cmd "Finding module dependencies" depmod -a
457 elif [ "$RUN_DEPMOD" = "ifmissing" ]; then
458 run_cmd "Finding module dependencies" depmod -A
462 if [ -f /proc/sys/kernel/modprobe ]; then
463 if [ -n "$USEMODULES" ]; then
464 sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
466 # We used to set this to NULL, but that causes
467 # 'failed to exec' messages"
468 sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
472 # Load usb storage here, to match most other things
473 if [ -n "$needusbstorage" ]; then
474 modprobe -k usb-storage >/dev/null 2>&1
477 # Load firewire devices
478 if ! grep -iq "nofirewire" /proc/cmdline 2>/dev/null ; then
479 aliases=$(/sbin/modprobe -c | awk '/^alias ieee1394-controller/ { print $3 }')
480 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
481 for alias in $aliases ; do
482 [ "$alias" = "off" ] && continue
483 run_cmd "$(nls 'Initializing firewire controller') ($alias)" /sbin/modprobe $alias
485 LC_ALL=C grep -E "SBP2" /proc/bus/ieee1394/devices 2>/dev/null && /sbin/modprobe -s sbp2 > /dev/null 2>&1
489 # Load sound modules if they need persistent DMA buffers
490 if grep -q "^options sound dmabuf=1" "$MODULES_CONF" 2>/dev/null ; then
492 alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
493 if [ -n "$alias" -a "$alias" != "off" ] ; then
494 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
497 alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound-slot-0[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
498 if [ -n "$alias" -a "$alias" != "off" ] ; then
499 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
505 if [ -x /etc/rc.d/rc.modules ]; then
509 # Find and activate volume groups:
511 if [ -x /sbin/evms_activate ]; then
512 if [ "$(kernelverser)" -lt "002006" ]; then
513 # Linux 2.4 core modules
514 modprobe -s -k evms > /dev/null 2>&1
515 modprobe -s -k evms_passthru > /dev/null 2>&1
516 modprobe -s -k ldev_mgr > /dev/null 2>&1
517 modprobe -s -k dos_part > /dev/null 2>&1
519 # Linux 2.6 core module
520 modprobe -s -k evmscore > /dev/null 2>&1
523 is_yes "$EVMS_GUID_PTABLE" && modprobe -s -k gpt_part >/dev/null 2>&1
524 is_yes "$EVMS_LVM" && modprobe -s -k lvm_vge >/dev/null 2>&1
525 is_yes "$EVMS_AIX" && modprobe -s -k AIXlvm_vge >/dev/null 2>&1
526 is_yes "$EVMS_OS2" && modprobe -s -k os2lvm_vge >/dev/null 2>&1
527 run_cmd "Discovering EVMS volumes" /sbin/evms_activate
528 if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then
529 # Link nodes for compatibility with LVM
530 if [ "echo /dev/evms/lvm/*" != '/dev/evms/lvm/*' ] ; then
531 ln -s /dev/evms/lvm/* /dev/
535 # LVM (keep in sync with LVM starting after RAID run!)
536 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
537 lvmversion=$(/sbin/vgchange --version 2>/dev/null | awk '{gsub("vgchange: Logical Volume Manager ",""); gsub("LVM version: ",""); gsub(/\..*/,"");print $1; exit}')
538 if [ "$lvmversion" = "1" ] ; then
539 modprobe -s -k lvm-mod >/dev/null 2>&1
541 elif [ "$lvmversion" = "2" ] ; then
542 modprobe -s -k dm-mod >/dev/null 2>&1
543 lvmignorelock="--ignorelockingfailure"
545 modprobe -s -k lvm-mod >/dev/null 2>&1
546 # device mapper (2.5+ and patched 2.4)
547 modprobe -s -k dm-mod >/dev/null 2>&1
551 run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelock && \
552 run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmignorelock
553 [ "$lvmversion" = "2" ] && /sbin/vgscan --mknodes $lvmignorelock > /dev/null 2>&1
558 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ] || [ -f /etc/raidtab ]; then
559 modprobe -s md >/dev/null 2>&1
560 if [ -f /proc/mdstat ]; then
564 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
565 if (grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null); then
566 run_cmd "Starting up RAID devices" /sbin/mdadm --assemble --scan --auto=yes
568 [ "$rc" -eq 0 ] && goraidtab=0 && golvm=1
572 if [ -f /etc/raidtab -a "$goraidtab" -eq 1 ]; then
573 for i in $(grep -v "^#" /etc/raidtab 2>/dev/null | grep "raiddev" 2>/dev/null | awk '{print $2}') ; do
575 RAIDDEV=$(basename $i)
576 RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat 2>/dev/null)
577 show "Starting up RAID device %s" $RAIDDEV
579 if [ -z "$RAIDSTAT" ]; then
580 # Try raidstart first...if that fails then
581 # fall back to raid0run and if that fails too
582 # fall back to raidadd, raidrun.
584 if [ -x /sbin/raidstart ]; then
588 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
592 if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
597 if [ $RESULT -gt 0 ]; then
609 # A non-zero return means there were problems
610 if [ $rc -gt 0 ]; then
611 [ -e /proc/splash ] && echo "verbose" > /proc/splash
612 show "Starting up RAID devices"; fail
615 nls "*** An error occurred during the RAID startup."
616 nls "*** Dropping you to a shell; the system will reboot"
617 nls "*** when you leave the shell."
620 PS1="$(nls '(RAID Repair)# ')"; export PS1
621 [ "$SELINUX" = "1" ] && disable_selinux
622 if is_yes "$RUN_SULOGIN_ON_ERR"; then
628 run_cmd "Unmounting file systems" umount -a
629 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
630 run_cmd "Automatic reboot in progress" reboot
632 # LVM on RAID (keep in sync with LVM setting few lines above)
633 if [ "$golvm" -eq "1" ]; then
634 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
635 run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmignorelock && \
636 run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmignorelock
637 [ "$lvmversion" = "2" ] && /sbin/vgscan --mknodes $lvmignorelock > /dev/null 2>&1
640 show "Starting up RAID devices"; ok
646 if [ -z "$fastboot" ] && ! grep -q nofsck /proc/cmdline 2>/dev/null; then
647 rc_splash "fsck start"
648 show "Checking filesystems"; started
649 initlog -c "fsck -C -T -R -A -a $fsckoptions"
653 # A return of 2 or higher means there were serious problems
654 if [ $rc -gt 1 ]; then
655 [ -e /proc/splash ] && echo "verbose" > /proc/splash
658 nls "*** An error occurred during the file system check."
659 nls "*** Dropping you to a shell; the system will reboot"
660 nls "*** when you leave the shell."
663 PS1="$(nls '(Repair filesystem)# ')"; export PS1
664 [ "$SELINUX" = "1" ] && disable_selinux
665 if is_yes "$RUN_SULOGIN_ON_ERR"; then
671 run_cmd "Unmounting file systems" umount -a
672 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
673 run_cmd "Automatic reboot in progress" reboot
674 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
677 rc_splash "fsck stop"
680 # Mount all other filesystems (except for NFS and /proc, which is already
681 # mounted). Contrary to standard usage,
682 # filesystems are NOT unmounted in single user mode.
684 run_cmd "Mounting local filesystems" mount -a -t nonfs,smbfs,ncpfs,proc,cifs -O no_netdev
686 # Now do some workaround - encrypted filesystems couldn't have been fsck-ed
687 # before mount - that's where the password is entered.
688 # mount is buggy - when remounting loopback filesystem, loop=XXX
689 # option is removed from /etc/mtab
690 if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then
691 show "Checking encrypted filesystems"; started
693 FILENAME=="/proc/mounts" {
696 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ {
697 if ($2 in TAB){print TAB[$2];}
699 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
700 if ($2 in TAB){print TAB[$2];}
701 sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4);
702 cmd="mount " $2 " -o remount," $4;
705 ' /proc/mounts /etc/fstab)"
706 initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST"
709 # A return of 2 or higher means there were serious problems.
710 if [ $rc -gt 1 ]; then
711 [ -e /proc/splash ] && echo "verbose" > /proc/splash
714 nls "*** An error occurred during the file system check."
715 nls "*** Dropping you to a shell; the system will reboot"
716 nls "*** when you leave the shell."
719 PS1="`nls '(Repair filesystem)# '`"; export PS1
720 [ "$SELINUX" = "1" ] && disable_selinux
721 if is_yes "$RUN_SULOGIN_ON_ERR"; then
727 run_cmd "Unmounting file systems" umount -a
728 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
729 run_cmd "Automatic reboot in progress" reboot
730 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
734 show "Remounting encrypted filesystems back in rw mode"; busy
736 FILENAME=="/proc/mounts" {
739 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
740 sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4);
741 cmd="mount " $2 " -o remount," $4;
744 ' /proc/mounts /etc/fstab
749 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
750 run_cmd "Checking filesystem quotas" /sbin/quotacheck -vnugRa
754 if [ -x /sbin/quotaon ]; then
755 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug
758 # Turn on process accounting
759 if [ -x /etc/rc.d/rc.acct ]; then
760 /etc/rc.d/rc.acct start
763 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
764 if is_yes "$TIME_SETUP_DELAYED"; then
765 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
766 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
770 # Initialize the serial ports
771 if [ -f /etc/rc.d/rc.serial ]; then
772 . /etc/rc.d/rc.serial
775 if [ -f /proc/sys/kernel/panic -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
776 show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy
777 if (sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1); then ok; else fail; fi
780 # ... and here finish configuring parameters
781 /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
786 [ -n "$SELINUX" ] && [ -f /.autorelabel ] && relabel_selinux
789 rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff
792 # I'd use find, but /usr may not be mounted.
793 for afile in /var/lock/* /var/run/*; do
794 bafile=$(basename $afile)
795 if [ -d "$afile" ]; then
796 [ "$bafile" != "news" -a "$bafile" != "sudo" -a "$bafile" != "mon" ] && rm -rf $afile/*
798 [ "$bafile" != "hwprofile" ] && rm -f $afile 2> /dev/null
802 rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \
803 /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.*
804 rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \
805 /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \
806 /tmp/scrollkeeper-* /tmp/ssh-*
810 if ! is_no "$NEED_XFILES" ; then
813 chown root:utmp /var/run/utmpx /var/log/wtmpx
814 chmod 0664 /var/run/utmpx /var/log/wtmpx
818 chown root:utmp /var/run/utmp /var/log/wtmp
819 chmod 0664 /var/run/utmp /var/log/wtmp
823 if is_yes "$CLEAN_TMP"; then
824 rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
827 # System protected dirs
828 mkdir -m 1777 -p /tmp/.ICE-unix > /dev/null 2>&1
829 chown root:root /tmp/.ICE-unix
830 [ -n "$SELINUX" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1
832 if ! is_yes "$VSERVER"; then
833 # Right, now turn on swap in case we swap to files
834 swapon -a >/dev/null 2>&1
835 run_cmd "Enabling swap space" /bin/true
837 # If a SCSI tape has been detected, load the st module unconditionally
838 # since many SCSI tapes don't deal well with st being loaded and unloaded
839 if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then
840 if grep -qv ' 9 st' /proc/devices 2>/dev/null; then
841 if [ -n "$USEMODULES" ] ; then
842 # Try to load the module. If it fails, ignore it...
843 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
848 # Now that we have all of our basic modules loaded and the kernel going,
849 # let's dump the syslog ring somewhere so we can find it later
850 dmesg -s 131072 > /var/log/dmesg
852 while [ $i -ge 0 ]; do
853 if [ -f /var/log/dmesg.$i ]; then
854 chmod 0600 /var/log/dmesg.$i
855 mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1))
859 cp -f /var/log/dmesg /var/log/dmesg.0
860 chmod 0600 /var/log/dmesg /var/log/dmesg.0
863 kill -TERM $(/sbin/pidof getkey) >/dev/null 2>&1
865 if ! is_no "$RC_PROMPT"; then
866 /sbin/getkey -c 5 i && touch /var/run/confirm
871 # This must be last line !