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.
19 # we need /proc mounted before everything
20 mount -n -o gid=17 -t proc /proc /proc
23 if [ -r /etc/sysconfig/i18n ]; then
25 [ -n "$LANG" ] && export LANG || unset LANG
26 [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
27 [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE
28 [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES
29 [ -n "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC
30 [ -n "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY
31 [ -n "$LC_TIME" ] && export LC_TIME || unset LC_TIME
32 [ -n "$LC_ALL" ] && export LC_ALL || unset LC_ALL
33 [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE
34 [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS
37 # Read network config data
38 if [ -r /etc/sysconfig/network ]; then
39 . /etc/sysconfig/network
45 # Read system config data
46 if [ -r /etc/sysconfig/system ]; then
47 . /etc/sysconfig/system
49 RUN_SULOGIN_ON_ERR=yes
61 . /etc/rc.d/init.d/functions
63 # sysfs is also needed before any other things (under kernel > 2.5)
64 if ! is_yes "$VSERVER" && grep -q sysfs /proc/filesystems 2>/dev/null ; then
65 mount -n -o gid=17 -t sysfs sysfs /sys
66 if [ "$(kernelver)" -ge "002006014" ] && \
67 grep -q securityfs /proc/filesystems 2>/dev/null ; then
68 mount -n -o gid=17 -t securityfs securityfs /sys/kernel/security
74 if ! is_yes "$VSERVER" && grep -q selinuxfs /proc/filesystems 2>/dev/null && ! grep -q selinuxfs /proc/mounts 2>/dev/null; then
75 mount -n -o gid=17 -t selinuxfs selinuxfs /selinux
78 if [ $(kernelverser) = "002006" ]; then
79 MODULES_CONF=/etc/modprobe.conf
80 elif [ -r /etc/modules.conf ]; then
81 MODULES_CONF=/etc/modules.conf
83 MODULES_CONF=/etc/conf.modules
87 if [ -x /etc/rc.d/rc.live ]; then
91 # Choose Hardware profile
92 if [ -f /etc/sysconfig/hwprof ]; then
93 . /etc/sysconfig/hwprof
94 if is_yes "${HWPROFILES}" && [ -x /sbin/hwprofile -a -d /etc/sysconfig/hwprofiles/data ]; then
95 mount -n / -o rw,remount
97 mount -n / -o ro,remount
101 # Disable splash when requested
102 [ -e /proc/splash ] && is_no "$BOOT_SPLASH" && echo "0" > /proc/splash
104 # Check SELinux status
105 selinuxfs=$(awk '/ selinuxfs / { print $2 }' /proc/mounts)
107 if [ -n "$selinuxfs" ] && [ "$(cat /proc/self/attr/current)" != "kernel" ]; then
108 if [ -r $selinuxfs/enforce ] ; then
109 SELINUX=$(cat $selinuxfs/enforce)
111 # assume enforcing if you can't read it
116 if [ -x /sbin/restorecon ] && LC_ALL=C fgrep -q " /dev " /proc/mounts 2>/dev/null ; then
117 /sbin/restorecon -R /dev 2>/dev/null
121 if [ "$CONSOLETYPE" = "vt" -a -x /sbin/setsysfont ]; then
122 run_cmd "Setting default font" /sbin/setsysfont
125 # Print welcome message
126 nls "\t\t\t%sPowered by %sPLD Linux Distribution%s" "$(termput setaf $CPOWEREDBY)" "$(termput setaf $CPLD)" "$(termput op)"
127 if is_yes "$PROMPT"; then
128 nls -n "\t\t Press %sI%s to enter interactive startup" "$(termput setaf $CI)" "$(termput op)"
134 run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME}
136 # Set the NIS domain name
137 if [ -n "$NISDOMAIN" ]; then
138 run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN
143 if ! is_yes "$VSERVER"; then
144 # Set console loglevel
145 if [ -n "$CONSOLE_LOGLEVEL" ]; then
146 /bin/dmesg -n $CONSOLE_LOGLEVEL
149 if [ -f /etc/udev/udev.conf ];then
150 . /etc/udev/udev.conf
153 [ -x /sbin/start_udev ] && run_cmd "Starting udev" /sbin/start_udev
155 # /dev must be also mounted before everything but only if we want use them ;-)
156 if is_yes "$MOUNT_DEVFS"; then
157 run_cmd "Mounting Device Filesystem" mount -n -t devfs /dev /dev
161 if [ -e /dev/.devfsd -a -x /sbin/devfsd ]; then
162 run_cmd "Starting Device Filesystem Daemon" /sbin/devfsd /dev
165 # cpuset support (mounted unconditionally, shouldn't be a problem)
166 if grep -q cpuset /proc/filesystems 2>/dev/null ; then
167 mount -n -t cpuset none /dev/cpuset
170 # Configure Linux kernel (initial configuration, some required modules still
172 /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
174 # Set the system clock.
179 if [ -f /etc/sysconfig/clock ]; then
180 . /etc/sysconfig/clock
182 # convert old style clock config to new values
183 if [ "${CLOCKMODE}" = "GMT" ]; then
185 elif [ "${CLOCKMODE}" = "ARC" ]; then
190 if grep "system serial" /proc/cpuinfo 2>/dev/null | grep -q MILO 2>/dev/null ; then
195 CLOCKFLAGS="--hctosys"
197 if is_yes "$UTC" ; then
198 CLOCKFLAGS="$CLOCKFLAGS --utc"
199 CLOCKDEF="$CLOCKDEF (utc)"
201 CLOCKFLAGS="$CLOCKFLAGS --localtime"
202 CLOCKDEF="$CLOCKDEF (local)"
205 if is_yes "$ARC" ; then
206 CLOCKFLAGS="$CLOCKFLAGS -A"
207 CLOCKDEF="$CLOCKDEF (arc)"
210 if is_yes "$SRM" ; then
211 CLOCKFLAGS="$CLOCKFLAGS -S"
212 CLOCKDEF="$CLOCKDEF (srm)"
215 # Check if timezone definition is available
216 if [ -e /etc/localtime ] ; then
217 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
218 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
221 TIME_SETUP_DELAYED=yes
225 run_cmd "Activating swap partitions" swapon -a -e
227 # Initialize USB controllers
229 if ! grep -iq "nousb" /proc/cmdline 2>/dev/null && ! grep -q "usb" /proc/devices 2>/dev/null ; then
230 aliases=$(/sbin/modprobe -c | awk '/^alias usb-controller/ { print $3 }')
231 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
232 /sbin/modprobe -k usbcore
233 for alias in $aliases ; do
234 [ "$alias" = "off" ] && continue
235 run_cmd "$(nls 'Initializing USB controller') ($alias)" /sbin/modprobe $alias
237 [ $? -eq 0 -a -n "$aliases" ] && usb=1
239 if grep -iq "usb" /proc/devices 2>/dev/null ; then
244 if [ "$usb" = "1" -a ! -f /proc/bus/usb/devices ]; then
245 run_cmd "Mounting USB filesystem" mount -t usbfs usbfs /proc/bus/usb
249 if [ "$usb" = "1" ]; then
250 needusbstorage=$(LC_ALL=C cat /proc/bus/usb/devices 2>/dev/null|grep -e "^I.*Cls=08" 2>/dev/null)
251 if [ "$(kernelverser)" -lt "002006" ]; then
252 LC_ALL=C grep -q 'hid' /proc/bus/usb/drivers 2>/dev/null || run_cmd "Initializing USB HID interface" modprobe hid 2> /dev/null
253 mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02" 2>/dev/null)
254 kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01" 2>/dev/null)
255 if [ -n "$kbdoutput" ]; then
256 run_cmd "Initializing USB keyboard" modprobe keybdev
258 if [ -n "$mouseoutput" ]; then
259 run_cmd "Initializing USB mouse" modprobe mousedev
264 # Setup hdparm thing (if exists and is needed)
265 if ! grep -iq nohdparm /proc/cmdline 2>/dev/null; then
266 [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
269 if [ -f /fastboot ] || grep -iq "fastboot" /proc/cmdline 2>/dev/null ; then
275 if [ -f /fsckoptions ]; then
276 fsckoptions=$(cat /fsckoptions)
281 if [ -f /forcefsck ]; then
282 fsckoptions="-f $fsckoptions"
286 _ROOTFS_TYPE=$(grep " / " /proc/mounts 2>/dev/null | awk '{ print $3 }')
288 if [ -z "$fastboot" -a "$_ROOTFS_TYPE" != "nfs" -a "$_ROOTFS_TYPE" != "romfs" ]; then
289 show "Checking root filesystem"; started
290 initlog -c "fsck -C -T -a $fsckoptions /"
294 # A return of 4 or higher means there were serious problems.
295 if [ $rc -gt 3 ]; then
296 [ -e /proc/splash ] && echo "verbose" > /proc/splash
297 # don't use '\n' in nls macro !
300 nls "*** An error occurred during the file system check."
301 nls "*** Dropping you to a shell; the system will reboot"
302 nls "*** when you leave the shell."
305 PS1="$(nls '(Repair filesystem)# ')"; export PS1
306 [ "$SELINUX" = "1" ] && disable_selinux
307 if is_yes "$RUN_SULOGIN_ON_ERR"; then
313 run_cmd "Unmounting file systems" umount -a
314 mount -n -o remount,ro /
315 run_cmd "Automatic reboot in progress" reboot
316 # A return of 2 or 3 means that filesystem was repaired but we need
318 elif [ "$rc" = "2" -o "$rc" = "3" ]; then
319 [ -e /proc/splash ] && echo "verbose" > /proc/splash
321 nls "*** Filesystem was repaired but system needs to be"
322 nls "*** rebooted before mounting it."
323 nls "*** REBOOTING ***"
326 run_cmd "Unmounting file systems" umount -a
327 mount -n -o remount,ro /
328 run_cmd "Automatic reboot in progress" reboot
329 elif [ "$rc" = "1" ]; then
334 # Unmount the initrd, if necessary
335 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
336 if [ -e /initrd/dev/.devfsd ]; then
340 /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1
343 # Check for arguments
344 if grep -iq nopnp /proc/cmdline 2>/dev/null; then
350 # set up pnp and kernel pnp
351 if [ -n "$PNP" ]; then
352 if is_yes "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
353 run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf
355 if is_yes "$RUN_KERNELPNP"; then
356 /sbin/modprobe -k isa-pnp 2> /dev/null
357 if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then
358 show "Setting up ISA PNP devices (kernelspace pnp)"; busy
359 grep -v "^#" /etc/isapnp/isapnp-kernel.conf 2>/dev/null >/proc/isapnp && (deltext; ok) || (deltext; fail)
364 # Remount the root filesystem read-write
365 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
367 # Update quotas if fsck was run on /
368 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
369 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -vnug /
373 # Clean up SELinux labels
374 if [ -n "$SELINUX" ]; then
375 for file in /etc/mtab /etc/cryptomtab /etc/ld.so.cache ; do
376 [ -r $file ] && restorecon $file >/dev/null 2>&1
380 # Remove stale backups
381 rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~
383 if ! is_yes "$VSERVER"; then
386 [ -f /etc/cryptomtab ] && :>/etc/cryptomtab
388 # Enter root, /proc, /sys, devfs and other into mtab.
391 [ -f /proc/bus/usb/devices ] && mount -f -t usbfs usbfs /proc/bus/usb
392 [ -e /dev/.devfsd ] && mount -f -t devfs devfs /dev
394 if grep -q sysfs /proc/filesystems 2>/dev/null ; then
395 mount -f -t sysfs sysfs /sys
396 if [ "$(kernelver)" -ge "002006014" ] && \
397 grep -q securityfs /proc/filesystems 2>/dev/null ; then
398 mount -f -t securityfs securityfs /sys/kernel/security
402 if grep -q selinuxfs /proc/filesystems 2>/dev/null ; then
403 mount -f -t selinuxfs selinuxfs /selinux
406 if grep -q cpuset /proc/filesystems 2>/dev/null ; then
407 mount -n -t cpuset none /dev/cpuset
413 # Remove /etc/nologin when starting system
414 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
416 if is_yes "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
417 show "Enabling Delay Login"; busy
419 nls "System bootup in progress - please wait" >> /etc/nologin
421 chmod 644 /etc/nologin
422 cp -fp /etc/nologin /etc/nologin.boot
426 # The root filesystem is now read-write, so we can now log via
427 # syslog() directly...
428 if [ -n "$IN_INITLOG" ]; then
432 if ! is_yes "$VSERVER"; then
433 if [ ! -f /proc/modules ]; then
435 elif ! grep -iq nomodules /proc/cmdline 2>/dev/null; then
441 # Adjust symlinks as necessary in /boot to keep system services from
442 # spewing messages about mismatched System maps and so on.
443 if is_yes "$SET_SLINKS"; then
444 if [ -L /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
445 ln -s -f System.map-`uname -r` /boot/System.map
447 if [ ! -e /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
448 ln -s -f System.map-`uname -r` /boot/System.map
452 # Run depmod if RUN_DEPMOD != "no" and:
453 # a) user requested or RUN_DEPMOD="";
454 # b) modules.dep is missing
455 # c) modules.dep is older than /etc/modules.conf or /lib/modules/`uname -r`
456 if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
457 if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then
458 run_cmd "Finding module dependencies" depmod -a
459 elif [ "$RUN_DEPMOD" = "ifmissing" ]; then
460 run_cmd "Finding module dependencies" depmod -A
464 if [ -f /proc/sys/kernel/modprobe ]; then
465 if [ -n "$USEMODULES" ]; then
466 sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
467 sysctl -w kernel.hotplug="/sbin/hotplug" >/dev/null 2>&1
469 # We used to set this to NULL, but that causes
470 # 'failed to exec' messages"
471 sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
472 sysctl -w kernel.hotplug="/bin/true" >/dev/null 2>&1
476 # Load usb storage here, to match most other things
477 if [ -n "$needusbstorage" ]; then
478 modprobe -k usb-storage >/dev/null 2>&1
481 # Load firewire devices
482 if ! grep -iq "nofirewire" /proc/cmdline 2>/dev/null ; then
483 aliases=$(/sbin/modprobe -c | awk '/^alias ieee1394-controller/ { print $3 }')
484 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
485 for alias in $aliases ; do
486 [ "$alias" = "off" ] && continue
487 run_cmd "$(nls 'Initializing firewire controller') ($alias)" /sbin/modprobe $alias
489 LC_ALL=C grep -E "SBP2" /proc/bus/ieee1394/devices 2>/dev/null && /sbin/modprobe -s sbp2 > /dev/null 2>&1
493 # Load sound modules if they need persistent DMA buffers
494 if grep -q "^options sound dmabuf=1" "$MODULES_CONF" 2>/dev/null ; then
496 alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
497 if [ -n "$alias" -a "$alias" != "off" ] ; then
498 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
501 alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound-slot-0[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
502 if [ -n "$alias" -a "$alias" != "off" ] ; then
503 run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
509 if [ -x /etc/rc.d/rc.modules ]; then
513 # Find and activate volume groups:
515 if [ -x /sbin/evms_activate ]; then
516 if [ "$(kernelverser)" -lt "002006" ]; then
517 # Linux 2.4 core modules
518 modprobe -s -k evms > /dev/null 2>&1
519 modprobe -s -k evms_passthru > /dev/null 2>&1
520 modprobe -s -k ldev_mgr > /dev/null 2>&1
521 modprobe -s -k dos_part > /dev/null 2>&1
523 # Linux 2.6 core module
524 modprobe -s -k evmscore > /dev/null 2>&1
527 is_yes "$EVMS_GUID_PTABLE" && modprobe -s -k gpt_part >/dev/null 2>&1
528 is_yes "$EVMS_LVM" && modprobe -s -k lvm_vge >/dev/null 2>&1
529 is_yes "$EVMS_AIX" && modprobe -s -k AIXlvm_vge >/dev/null 2>&1
530 is_yes "$EVMS_OS2" && modprobe -s -k os2lvm_vge >/dev/null 2>&1
531 run_cmd "Discovering EVMS volumes" /sbin/evms_activate
532 if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then
533 # Link nodes for compatibility with LVM
534 if [ "echo /dev/evms/lvm/*" != '/dev/evms/lvm/*' ] ; then
535 ln -s /dev/evms/lvm/* /dev/
539 # LVM (keep in sync with LVM starting after RAID run!)
540 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
541 lvmversion=$(/sbin/vgchange --version 2>/dev/null | awk '{gsub("vgchange: Logical Volume Manager ",""); gsub("LVM version: ",""); gsub(/\..*/,"");print $1; exit}')
542 if [ "$lvmversion" = "1" ] ; then
543 modprobe -s -k lvm-mod >/dev/null 2>&1
545 elif [ "$lvmversion" = "2" ] ; then
546 modprobe -s -k dm-mod >/dev/null 2>&1
547 lvmignorelock="--ignorelockingfailure"
549 modprobe -s -k lvm-mod >/dev/null 2>&1
550 # device mapper (2.5+ and patched 2.4)
551 modprobe -s -k dm-mod >/dev/null 2>&1
555 run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelock && \
556 run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmignorelock
557 [ "$lvmversion" = "2" ] && /sbin/vgscan --mknodes $lvmignorelock > /dev/null 2>&1
562 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ] || [ -f /etc/raidtab ]; then
563 modprobe -s md >/dev/null 2>&1
564 if [ -f /proc/mdstat ]; then
568 if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
569 if (grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null); then
570 run_cmd "Starting up RAID devices" /sbin/mdadm --assemble --scan
572 [ "$rc" -eq 0 ] && goraidtab=0 && golvm=1
576 if [ -f /etc/raidtab -a "$goraidtab" -eq 1 ]; then
577 for i in $(grep -v "^#" /etc/raidtab 2>/dev/null | grep "raiddev" 2>/dev/null | awk '{print $2}') ; do
579 RAIDDEV=$(basename $i)
580 RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat 2>/dev/null)
581 show "Starting up RAID device %s" $RAIDDEV
583 if [ -z "$RAIDSTAT" ]; then
584 # Try raidstart first...if that fails then
585 # fall back to raid0run and if that fails too
586 # fall back to raidadd, raidrun.
588 if [ -x /sbin/raidstart ]; then
592 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
596 if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
601 if [ $RESULT -gt 0 ]; then
613 # A non-zero return means there were problems
614 if [ $rc -gt 0 ]; then
615 [ -e /proc/splash ] && echo "verbose" > /proc/splash
616 show "Starting up RAID devices"; fail
619 nls "*** An error occurred during the RAID startup."
620 nls "*** Dropping you to a shell; the system will reboot"
621 nls "*** when you leave the shell."
624 PS1="$(nls '(RAID Repair)# ')"; export PS1
625 [ "$SELINUX" = "1" ] && disable_selinux
626 if is_yes "$RUN_SULOGIN_ON_ERR"; then
632 run_cmd "Unmounting file systems" umount -a
633 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
634 run_cmd "Automatic reboot in progress" reboot
636 # LVM on RAID (keep in sync with LVM setting few lines above)
637 if [ "$golvm" -eq "1" ]; then
638 if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
639 run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmignorelock && \
640 run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmignorelock
641 [ "$lvmversion" = "2" ] && /sbin/vgscan --mknodes $lvmignorelock > /dev/null 2>&1
644 show "Starting up RAID devices"; ok
650 if [ -z "$fastboot" ] && ! grep -q nofsck /proc/cmdline 2>/dev/null; then
651 rc_splash "fsck start"
652 show "Checking filesystems"; started
653 initlog -c "fsck -C -T -R -A -a $fsckoptions"
657 # A return of 2 or higher means there were serious problems
658 if [ $rc -gt 1 ]; then
659 [ -e /proc/splash ] && echo "verbose" > /proc/splash
662 nls "*** An error occurred during the file system check."
663 nls "*** Dropping you to a shell; the system will reboot"
664 nls "*** when you leave the shell."
667 PS1="$(nls '(Repair filesystem)# ')"; export PS1
668 [ "$SELINUX" = "1" ] && disable_selinux
669 if is_yes "$RUN_SULOGIN_ON_ERR"; then
675 run_cmd "Unmounting file systems" umount -a
676 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
677 run_cmd "Automatic reboot in progress" reboot
678 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
681 rc_splash "fsck stop"
684 # Mount all other filesystems (except for NFS and /proc, which is already
685 # mounted). Contrary to standard usage,
686 # filesystems are NOT unmounted in single user mode.
688 run_cmd "Mounting local filesystems" mount -a -t nonfs,smbfs,ncpfs,proc,cifs -O no_netdev
690 # Now do some workaround - encrypted filesystems couldn't have been fsck-ed
691 # before mount - that's where the password is entered.
692 # mount is buggy - when remounting loopback filesystem, loop=XXX
693 # option is removed from /etc/mtab
694 if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then
695 show "Checking encrypted filesystems"; started
697 FILENAME=="/proc/mounts" {
700 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && /[^a-zA-Z_]ro[^a-zA-Z_]/ {
701 if ($2 in TAB){print TAB[$2];}
703 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
704 if ($2 in TAB){print TAB[$2];}
705 sub("loop(=[^,]*)?","loop=" TAB[$2] ",ro",$4);
706 cmd="mount " $2 " -o remount," $4;
709 ' /proc/mounts /etc/fstab)"
710 initlog -c "fsck -T -C -a $fsckoptions $LOOPLIST"
713 # A return of 2 or higher means there were serious problems.
714 if [ $rc -gt 1 ]; then
715 [ -e /proc/splash ] && echo "verbose" > /proc/splash
718 nls "*** An error occurred during the file system check."
719 nls "*** Dropping you to a shell; the system will reboot"
720 nls "*** when you leave the shell."
723 PS1="`nls '(Repair filesystem)# '`"; export PS1
724 [ "$SELINUX" = "1" ] && disable_selinux
725 if is_yes "$RUN_SULOGIN_ON_ERR"; then
731 run_cmd "Unmounting file systems" umount -a
732 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
733 run_cmd "Automatic reboot in progress" reboot
734 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
738 show "Remounting encrypted filesystems back in rw mode"; busy
740 FILENAME=="/proc/mounts" {
743 FILENAME=="/etc/fstab" && /encryption=/ && ! /noauto/ && ! /[^a-zA-Z_]ro[^a-zA-Z_]/ {
744 sub("loop(=[^,]*)?","loop=" TAB[$2] ",rw",$4);
745 cmd="mount " $2 " -o remount," $4;
748 ' /proc/mounts /etc/fstab
753 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
754 run_cmd "Checking filesystem quotas" /sbin/quotacheck -vnugRa
758 if [ -x /sbin/quotaon ]; then
759 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug
762 [ -n "$SELINUX" ] && [ -f /.autorelabel ] && relabel_selinux
764 # Turn on process accounting
765 if [ -x /etc/rc.d/rc.acct ]; then
766 /etc/rc.d/rc.acct start
769 if ! is_yes "$VSERVER"; then
770 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
771 if is_yes "$TIME_SETUP_DELAYED"; then
772 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
773 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
777 # Initialize the serial ports
778 if [ -f /etc/rc.d/rc.serial ]; then
779 . /etc/rc.d/rc.serial
782 if [ -f /proc/sys/kernel/panic -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
783 show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy
784 if (sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1); then ok; else fail; fi
787 # ... and here finish configuring parameters
788 /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
792 rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff
795 # I'd use find, but /usr may not be mounted.
796 for afile in /var/lock/* /var/run/*; do
797 bafile=$(basename $afile)
798 if [ -d "$afile" ]; then
799 [ "$bafile" != "news" -a "$bafile" != "sudo" -a "$bafile" != "mon" ] && rm -rf $afile/*
801 [ "$bafile" != "hwprofile" ] && rm -f $afile 2> /dev/null
805 rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \
806 /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.*
807 rm -rf /tmp/.X*-unix /tmp/.ICE-unix /tmp/.font-unix /tmp/hsperfdata_* \
808 /tmp/kde-* /tmp/ksocket-* /tmp/mc-* /tmp/mcop-* /tmp/orbit-* \
809 /tmp/scrollkeeper-* /tmp/ssh-*
813 if ! is_no "$NEED_XFILES" ; then
816 chown root.utmp /var/run/utmpx /var/log/wtmpx
817 chmod 0664 /var/run/utmpx /var/log/wtmpx
821 chown root.utmp /var/run/utmp /var/log/wtmp
822 chmod 0664 /var/run/utmp /var/log/wtmp
826 if is_yes "$CLEAN_TMP"; then
827 rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
830 # System protected dirs
831 mkdir -m 1777 -p /tmp/.ICE-unix > /dev/null 2>&1
832 chown root:root /tmp/.ICE-unix
833 [ -n "$SELINUX" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1
835 # Right, now turn on swap in case we swap to files
836 swapon -a >/dev/null 2>&1
837 run_cmd "Enabling swap space" /bin/true
839 # If a SCSI tape has been detected, load the st module unconditionally
840 # since many SCSI tapes don't deal well with st being loaded and unloaded
841 if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then
842 if grep -qv ' 9 st' /proc/devices 2>/dev/null; then
843 if [ -n "$USEMODULES" ] ; then
844 # Try to load the module. If it fails, ignore it...
845 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
850 # There could be a new kernel version. Remove old psdevtab database
853 if ! is_yes "$VSERVER"; then
854 # Now that we have all of our basic modules loaded and the kernel going,
855 # let's dump the syslog ring somewhere so we can find it later
856 dmesg -s 131072 > /var/log/dmesg
858 while [ $i -ge 0 ]; do
859 if [ -f /var/log/dmesg.$i ]; then
860 chmod 0600 /var/log/dmesg.$i
861 mv -f /var/log/dmesg.$i /var/log/dmesg.$(($i+1))
865 cp -f /var/log/dmesg /var/log/dmesg.0
866 chmod 0600 /var/log/dmesg /var/log/dmesg.0
869 kill -TERM $(/sbin/pidof getkey) >/dev/null 2>&1
871 if is_yes "$PROMPT"; then
872 /sbin/getkey i && touch /var/run/confirm
877 # This must be last line !