]> git.pld-linux.org Git - projects/rc-scripts.git/blobdiff - rc.d/rc.sysinit
avoid loading /etc/modules contents twice (modules-load.d/modules.conf is symlink...
[projects/rc-scripts.git] / rc.d / rc.sysinit
index 88293cb2dae8b20a65e3cdaa5ed8759f5abdf217..d486c8e797bb5ab269b6cc345a49f044d2ad2e12 100755 (executable)
@@ -37,7 +37,7 @@ fi
 CONSOLE_LOGLEVEL=1
 
 # Read functions
-. /etc/rc.d/init.d/functions
+. /lib/rc-scripts/functions
 
 disable_selinux() {
        local _d selinuxfs _t _r
@@ -83,29 +83,84 @@ clean_vserver_mtab() {
 
 # Loads modules from /etc/modules, /etc/modules.X.Y and /etc/modules.X.Y.Z
 load_kernel_modules() {
+       local modules_file=$1
+       local _x _y _z v v1 old_IFS kernel kerneleq
        {
-               local _x _y v _z
-               read  _x _y v _z
+               read _x _y v _z
                old_IFS=$IFS
-               IFS='.'
+               # strip _* or -* from versions like: "2.6.25_vanilla-1", "2.6.25-1"
+               IFS='_-'
                set -- $v
+               v1=${1}
+               IFS='.'
+               set -- $v1
                IFS=$old_IFS
+
                kernel="$1.$2"
                kerneleq="$1.$2.$3"
        } < /proc/version
 
-       local module
+       local module args
        # Loop over every line in modules file
        ( \
-               grep -hvE '^(#|[[:blank:]]*$)' /etc/modules /etc/modules.$kernel /etc/modules.$kerneleq 2>/dev/null
+               grep -hvE '^(#|[[:blank:]]*$)' /etc/$modules_file /etc/$modules_file.$kernel /etc/$modules_file.$kerneleq 2>/dev/null
                echo '' # make sure there is a LF at the end
        ) | while read module args; do
                [ -z "$module" ] && continue
-               modprobe -s $module -- $args
+               # strip comments
+               args=${args%%#*}
+               show "Loading %s kernel module(s)" "$module"
+               busy
+               modprobe -s $module -- $args && ok || fail
        done
 }
 
-# boot logging to /var/log/boot.msg. install showconsole package to get it.
+check_root_fs() {
+       show "Checking root filesystem"; started
+       initlog -c "fsck -C -T -a $fsckoptions /"
+       rc=$?
+
+       # A return of 4 or higher means there were serious problems.
+       if [ $rc -gt 3 ]; then
+               [ -e /proc/splash ] && echo "verbose" > /proc/splash
+               # don't use '\n' in nls macro !
+               echo
+               echo
+               nls "*** An error occurred during the file system check."
+               nls "*** Dropping you to a shell; the system will reboot"
+               nls "*** when you leave the shell."
+               echo
+
+               PS1="$(nls '(Repair filesystem)# ')"; export PS1
+               [ "$SELINUX" = "1" ] && disable_selinux
+               if ! is_no "$RUN_SULOGIN_ON_ERR"; then
+                       /sbin/sulogin
+               else
+                       /bin/sh
+               fi
+
+               run_cmd "Unmounting file systems" umount -a
+               mount -n -o remount,ro /
+               run_cmd "Automatic reboot in progress" reboot
+       # A return of 2 or 3 means that filesystem was repaired but we need
+       # to reboot.
+       elif [ "$rc" = "2" -o "$rc" = "3" ]; then
+               [ -e /proc/splash ] && echo "verbose" > /proc/splash
+               echo
+               nls "*** Filesystem was repaired but system needs to be"
+               nls "*** rebooted before mounting it."
+               nls "*** REBOOTING ***"
+               echo
+
+               run_cmd "Unmounting file systems" umount -a
+               mount -n -o remount,ro /
+               run_cmd "Automatic reboot in progress" reboot
+       elif [ "$rc" = "1" ]; then
+               _RUN_QUOTACHECK=1
+       fi
+}
+
+# boot logging to /var/log/boot.log. install showconsole package to get it.
 if [ -x /sbin/blogd ] && ! is_no "$RC_BOOTLOG"; then
        RC_BOOTLOG=1
 else
@@ -113,18 +168,27 @@ else
 fi
 
 if ! is_yes "$VSERVER" ; then
+       if [ -d /run ]; then
+               is_fsmounted tmpfs /run || mount -n -t tmpfs run /run
+       fi
+
        # we need /proc mounted before everything
-       is_fsmounted proc /proc || mount -n -o gid=17 -t proc /proc /proc
+       is_fsmounted proc /proc || mount -n /proc || mount -n -o gid=17,hidepid=2 -t proc /proc /proc
+
+       # Early sysctls
+       sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
 
        # Only read this once.
        cmdline=$(cat /proc/cmdline)
+       if strstr "$cmdline" "pld.no-upstart" ; then
+               USE_UPSTART="no"
+       fi
 
        # sysfs is also needed before any other things (under kernel > 2.5)
        if grep -q sysfs /proc/filesystems 2>/dev/null ; then
                is_fsmounted sysfs /sys || mount -n -o gid=17 -t sysfs sysfs /sys
-               if [ "$(kernelver)" -ge "002006014" ] && \
-                       grep -q securityfs /proc/filesystems 2>/dev/null ; then
-                               mount -n -o gid=17 -t securityfs securityfs /sys/kernel/security
+               if grep -q securityfs /proc/filesystems 2>/dev/null ; then
+                       mount -n -o gid=17 -t securityfs securityfs /sys/kernel/security
                fi
        fi
 
@@ -149,7 +213,7 @@ if ! is_yes "$VSERVER" ; then
        fi
 
        # Disable splash when requested
-       [ -e /proc/splash ] && is_no "$BOOT_SPLASH" && echo "0" > /proc/splash
+       is_no "$BOOT_SPLASH" && [ -e /proc/splash ] && echo "0" > /proc/splash
 
        # Check SELinux status
        selinuxfs=$(awk '/ selinuxfs / { print $2 }' /proc/mounts 2> /dev/null)
@@ -199,15 +263,16 @@ fi
 if ! is_yes "$VSERVER"; then
        # Set console loglevel
        if [ -n "$CONSOLE_LOGLEVEL" ]; then
-               /bin/dmesg -n $CONSOLE_LOGLEVEL
+               dmesg -n $CONSOLE_LOGLEVEL
        fi
 
-       if ! is_no "$START_UDEV"; then
-               if [ -x /sbin/start_udev ]; then
-                       /sbin/start_udev
-               elif [ -x /lib/firmware/firmware-loader.sh ]; then
-                       /sbin/sysctl -e -w kernel.hotplug=/lib/firmware/firmware-loader.sh
-               fi
+       if ! is_no "$START_UDEV" && [ -x /sbin/start_udev ] && [[ "$container" != lxc* ]]; then
+               is_fsmounted devtmpfs /dev || mount -n -t devtmpfs devtmpfs /dev
+               load_kernel_modules modules.preudev
+               /sbin/start_udev
+               [ -x /sbin/initctl ] && /sbin/initctl -q start udev
+       elif [ -x /lib/firmware/firmware-loader.sh ]; then
+               /sbin/sysctl -e -w kernel.hotplug=/lib/firmware/firmware-loader.sh > /dev/null 2>&1
        fi
 
        # Unmount the initrd, if necessary
@@ -222,68 +287,20 @@ if ! is_yes "$VSERVER"; then
                /sbin/blogd
        fi
 
-       # cpuset support (mounted unconditionally, shouldn't be a problem)
-       if grep -q cgroup /proc/filesystems 2>/dev/null ; then
-               mount -n -t cgroup none /dev/cpuset -o cpuset,noprefix
-               [ $? -eq 0 ] && echo "/sbin/cpuset_release_agent" > /dev/cpuset/release_agent
-       elif grep -q cpuset /proc/filesystems 2>/dev/null ; then
-               mount -n -t cpuset none /dev/cpuset
-       fi
-
        # Configure Linux kernel (initial configuration, some required modules still
        # may be missing).
-       /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
-
-       # Set the system clock.
-       ARC=0
-       SRM=0
-       UTC=0
-
-       if [ -f /etc/sysconfig/clock ]; then
-               . /etc/sysconfig/clock
-
-               # convert old style clock config to new values
-               if [ "${CLOCKMODE}" = "GMT" ]; then
-                       UTC=true
-               elif [ "${CLOCKMODE}" = "ARC" ]; then
-                       ARC=true
-               fi
-       fi
-
-       if grep "system serial" /proc/cpuinfo 2>/dev/null | grep -q MILO 2>/dev/null ; then
-               ARC=true
-       fi
-
-       CLOCKDEF=""
-       CLOCKFLAGS="--hctosys"
-
-       if is_yes "$UTC" ; then
-               CLOCKFLAGS="$CLOCKFLAGS --utc"
-               CLOCKDEF="$CLOCKDEF (utc)"
-       else
-               CLOCKFLAGS="$CLOCKFLAGS --localtime"
-               CLOCKDEF="$CLOCKDEF (local)"
-       fi
-
-       if is_yes "$ARC" ; then
-               CLOCKFLAGS="$CLOCKFLAGS -A"
-               CLOCKDEF="$CLOCKDEF (arc)"
-       fi
-
-       if is_yes "$SRM" ; then
-               CLOCKFLAGS="$CLOCKFLAGS -S"
-               CLOCKDEF="$CLOCKDEF (srm)"
-       fi
+       sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
 
        # Check if timezone definition is available
-       if [ -e /etc/localtime ] ; then
-               if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
+       if [ -e /etc/localtime ] && [ -e /dev/rtc -o -e /dev/rtc0 ] ; then
+               if run_cmd "$(nls 'Setting clock')" hwclock --hctosys; then
                        show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
                fi
        else
                TIME_SETUP_DELAYED=yes
        fi
 
+       delay_cryptsetup=0
        if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then
                # XXX might need modules dep
                # Device mapper & related initialization
@@ -291,10 +308,11 @@ if ! is_yes "$VSERVER"; then
                        modprobe dm-mod
                fi
 
-               # but should do this before swapon?
                . /etc/rc.d/init.d/cryptsetup
                show "Starting disk encryption"
-               init_crypto 0 && ok || fail
+               init_crypto 0
+               delay_cryptsetup=$?
+               [ $delay_cryptsetup = 0 ] && ok || fail
        fi
 
        # Start up swapping
@@ -323,9 +341,9 @@ if ! is_yes "$VSERVER"; then
 
        needusbstorage=
        if [ "$usb" = "1" ]; then
-               needusbstorage=$(LC_ALL=C cat /proc/bus/usb/devices 2>/dev/null|grep -e "^I.*Cls=08" 2>/dev/null)
+               needusbstorage=$(cat /proc/bus/usb/devices 2>/dev/null | grep -e "^I.*Cls=08" 2>/dev/null)
                if [ "$(kernelverser)" -lt "002006" ]; then
-                       LC_ALL=C grep -q 'hid' /proc/bus/usb/drivers 2>/dev/null || run_cmd "Initializing USB HID interface" modprobe hid 2> /dev/null
+                       grep -q 'hid' /proc/bus/usb/drivers 2>/dev/null || run_cmd "Initializing USB HID interface" modprobe hid 2> /dev/null
                        mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02" 2>/dev/null)
                        kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01" 2>/dev/null)
                        if [ -n "$kbdoutput" ]; then
@@ -367,50 +385,8 @@ if ! is_yes "$VSERVER"; then
        _ROOTFS_DEVICE=$(awk '($1 !~ /^#/ && $2 == "/" && NF >= 6) { print $1}' /etc/fstab)
        _ROOTFS_TYPE=$(awk '$2 == "/" && $3 != "rootfs" { print $3 }' /proc/mounts 2>/dev/null)
 
-       if [ -z "$fastboot" -a "$_ROOTFS_TYPE" != "nfs" -a "$_ROOTFS_TYPE" != "romfs" -a "$_ROOTFS_PASSNO" != 0 -a -e $_ROOTFS_DEVICE ]; then
-               show "Checking root filesystem"; started
-               initlog -c "fsck -C -T -a $fsckoptions /"
-
-               rc=$?
-
-               # A return of 4 or higher means there were serious problems.
-               if [ $rc -gt 3 ]; then
-                       [ -e /proc/splash ] && echo "verbose" > /proc/splash
-                       # don't use '\n' in nls macro !
-                       echo
-                       echo
-                       nls "*** An error occurred during the file system check."
-                       nls "*** Dropping you to a shell; the system will reboot"
-                       nls "*** when you leave the shell."
-                       echo
-
-                       PS1="`nls '(Repair filesystem)# '`"; export PS1
-                       [ "$SELINUX" = "1" ] && disable_selinux
-                       if ! is_no "$RUN_SULOGIN_ON_ERR"; then
-                               /sbin/sulogin
-                       else
-                               /bin/sh
-                       fi
-
-                       run_cmd "Unmounting file systems" umount -a
-                       mount -n -o remount,ro /
-                       run_cmd "Automatic reboot in progress" reboot
-               # A return of 2 or 3 means that filesystem was repaired but we need
-               # to reboot.
-               elif [ "$rc" = "2" -o "$rc" = "3" ]; then
-                       [ -e /proc/splash ] && echo "verbose" > /proc/splash
-                       echo
-                       nls "*** Filesystem was repaired but system needs to be"
-                       nls "*** rebooted before mounting it."
-                       nls "*** REBOOTING ***"
-                       echo
-
-                       run_cmd "Unmounting file systems" umount -a
-                       mount -n -o remount,ro /
-                       run_cmd "Automatic reboot in progress" reboot
-               elif [ "$rc" = "1" ]; then
-                       _RUN_QUOTACHECK=1
-               fi
+       if [ -z "$fastboot" -a "$_ROOTFS_TYPE" != "aufs" -a "$_ROOTFS_TYPE" != "nfs" -a "$_ROOTFS_TYPE" != "romfs" -a "$_ROOTFS_TYPE" != "squashfs" -a "$_ROOTFS_PASSNO" != 0 -a -e $_ROOTFS_DEVICE ] && [[ "$container" != lxc* ]]; then
+               check_root_fs
        fi
 
        # Check for arguments
@@ -452,10 +428,11 @@ if ! is_yes "$VSERVER"; then
                done
        fi
 
-       if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then
-               # XXX, this must be probably done after random is initialized from /var/run/random-seed
+       if [ "$delay_cryptsetup" != 0 ]; then
                show "Starting disk encryption using the RNG"
-               init_crypto 1 && ok || fail
+               init_crypto 1
+               delay_cryptsetup=$?
+               [ $delay_cryptsetup = 0 ] && ok || fail
        fi
 else
        # Start logging console output since we have all /dev stuff setup
@@ -492,28 +469,32 @@ if ! is_yes "$VSERVER"; then
        [ -f /etc/cryptomtab ] && :>/etc/cryptomtab
 
        # Enter root, /proc, /sys and other into mtab.
-       mount -f /
-       mount -f /proc
+       mount -f / 2> /dev/null
+       mount -f /proc 2> /dev/null
+       if is_fsmounted devtmpfs /dev; then
+               mount -f -t devtmpfs devtmpfs /dev 2> /dev/null
+       fi
+       if is_fsmounted tmpfs /run; then
+               mount -f -t tmpfs run /run 2> /dev/null
+       fi
+
        if is_fsmounted usbfs /proc/bus/usb; then
-               mount -f -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb
+               mount -f -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb 2> /dev/null
        fi
 
        if is_fsmounted sysfs /sys; then
-               mount -f -t sysfs sysfs /sys
+               mount -f -t sysfs sysfs /sys 2> /dev/null
                if is_fsmounted securityfs /sys/kernel/security ; then
-                       mount -f -t securityfs securityfs /sys/kernel/security
+                       mount -f -t securityfs securityfs /sys/kernel/security 2> /dev/null
                fi
        fi
 
        if is_fsmounted selinuxfs /selinux; then
-               mount -f -t selinuxfs selinuxfs /selinux
+               mount -f -t selinuxfs selinuxfs /selinux 2> /dev/null
        fi
 
-       if is_fsmounted cgroup /dev/cpuset; then
-               mount -f -t cgroup -o cpuset,noprefix none /dev/cpuset
-       elif is_fsmounted cpuset /dev/cpuset; then
-               mount -f -t cpuset none /dev/cpuset
-       fi
+       emit --no-wait root-filesystem
+       emit --no-wait virtual-filesystems
 
        if [ ! -f /proc/modules ]; then
                USEMODULES=
@@ -570,12 +551,12 @@ if ! is_yes "$VSERVER"; then
                                [ "$alias" = "off" ] && continue
                                run_cmd "$(nls 'Initializing firewire controller') ($alias)" /sbin/modprobe $alias
                        done
-                       LC_ALL=C grep -E "SBP2" /proc/bus/ieee1394/devices 2>/dev/null && /sbin/modprobe -s sbp2 > /dev/null 2>&1
+                       grep -E "SBP2" /proc/bus/ieee1394/devices 2>/dev/null && /sbin/modprobe -s sbp2 > /dev/null 2>&1
                fi
        fi
 
        # Load sound modules if they need persistent DMA buffers
-       if (/sbin/modprobe -c 2> /dev/null | grep -q "^options sound dmabuf=1"); then
+       if /sbin/modprobe -c | grep -q "^options sound dmabuf=1"; then
                RETURN=0
                alias=$(/sbin/modprobe -c | grep -sE "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
                if [ -n "$alias" -a "$alias" != "off" ] ; then
@@ -590,9 +571,18 @@ if ! is_yes "$VSERVER"; then
        fi
 
        # Load modules
-       load_kernel_modules
+       if ! use_upstart; then
+               load_kernel_modules modules
+               for f in /etc/modules-load.d/*.conf; do
+                       # already loaded by implicit "modules" load
+                       [ "${f##*/}" = "modules.conf" ] && continue
+
+                       [ -r $f ] || continue
+                       load_kernel_modules ${f##/etc/}
+               done
+       fi
 
-       if [ -x /sbin/multipath ]; then
+       if [ -x /sbin/multipath ] && ! is_no "$DM_MULTIPATH"; then
                # first make nodes that were discarded due (possible) new /dev mount
                modprobe -s dm-mod
                /sbin/dmsetup mknodes
@@ -633,30 +623,44 @@ if ! is_yes "$VSERVER"; then
        fi
 
        # LVM (keep in sync with LVM starting after RAID run!)
-       if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
-               lvmversion=$(LC_ALL=C /sbin/vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}')
+       if ! is_no "$LVM2" && [ -x /sbin/vgscan -a -x /sbin/vgchange ] || is_yes "$EVMS_LVM"; then
+               if is_no "$LVM2"; then
+                       lvmversion=$(LC_ALL=C /sbin/vgchange --version 2>/dev/null | awk '/LVM version:/{if ($3 >= 2) print "2"}')
+               else
+                       lvmversion=2
+               fi
                if [ "$lvmversion" = "1" ] ; then
                        modprobe -s lvm-mod >/dev/null 2>&1
-                       lvmignorelock=""
+                       lvmignorelocking=""
+                       lvmsysinit=""
                elif [ "$lvmversion" = "2" ] ; then
                        modprobe -s dm-mod >/dev/null 2>&1
-                       lvmignorelock="--ignorelockingfailure"
+                       lvmignorelocking="--ignorelockingfailure"
+                       lvmsysinit="--sysinit"
                else
                        modprobe -s lvm-mod >/dev/null 2>&1
                        # device mapper (2.5+ and patched 2.4)
                        modprobe -s dm-mod >/dev/null 2>&1
-                       lvmignorelock=""
+                       lvmignorelocking=""
+                       lvmsysinit=""
                fi
 
-               run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelock
-               run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmignorelock
+               run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelocking
+               run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmsysinit
                if [ "$lvmversion" = "2" ]; then
-                       /sbin/vgmknodes
+                       /sbin/vgmknodes $lvmignorelocking
                        # display VG statistics
-                       /sbin/vgdisplay -s
+                       /sbin/vgdisplay -s $lvmignorelocking
                fi
        fi
 
+       if [ "$delay_cryptsetup" != 0 ]; then
+               show "Starting disk encryption"
+               init_crypto 1
+               delay_cryptsetup=$?
+               [ $delay_cryptsetup = 0 ] && ok || fail
+       fi
+
        # Add raid devices
        if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ] || [ -f /etc/raidtab ]; then
                modprobe -s md >/dev/null 2>&1
@@ -665,10 +669,20 @@ if ! is_yes "$VSERVER"; then
                        golvm=0
                        rc=0
                        if [ -x /sbin/mdadm -a -f /etc/mdadm.conf ]; then
-                               if (grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null); then
-                                       run_cmd "Starting up RAID devices" /sbin/mdadm --assemble --scan --auto=yes
+                               if grep -qE "^([[:blank:]]|)ARRAY[[:blank:]]" /etc/mdadm.conf 2>/dev/null; then
+                                       show "Starting up RAID devices"; busy
+                                       /sbin/mdadm --assemble --scan --auto=yes
                                        rc=$?
-                                       [ "$rc" -eq 0 ] && goraidtab=0 && golvm=1
+                                       if [ "$rc" -eq 0 -o "$rc" -eq 2 ]; then
+                                               # rc is used later, too so set sane value
+                                               rc=0
+                                               deltext; ok
+                                               goraidtab=0
+                                               golvm=1
+                                       else
+                                               deltext; fail
+                                       fi
+
                                fi
                        fi
 
@@ -734,9 +748,9 @@ if ! is_yes "$VSERVER"; then
                        fi
                        # LVM on RAID (keep in sync with LVM setting few lines above)
                        if [ "$golvm" -eq "1" ]; then
-                               if is_yes "$EVMS_LVM" || [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
-                                       run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmignorelock
-                                       run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmignorelock
+                               if [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
+                                       run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmignorelocking
+                                       run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmsysinit
                                        [ "$lvmversion" = "2" ] && /sbin/vgmknodes
                                fi
                        fi
@@ -842,7 +856,7 @@ if ! is_yes "$VSERVER"; then
                fi
 
                show "Remounting encrypted filesystems back in rw mode"; busy
-               awk '
+               LC_ALL=C awk '
                FILENAME=="/proc/mounts" {
                        TAB[$2]=$1;
                }
@@ -857,7 +871,7 @@ if ! is_yes "$VSERVER"; then
 
        # /var/log should be writable now, so start saving the boot output
        if [ "$RC_BOOTLOG" ]; then
-               echo > /var/log/boot.msg
+               echo > /var/log/boot.log
                killall -IO blogd
        fi
 
@@ -870,14 +884,20 @@ if ! is_yes "$VSERVER"; then
                run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -aug
        fi
 
+       emit --no-wait local-filesystems
+
+       # FIXME: this should be delayed until remote filesystems are mounted,
+       #        especialy when /usr or other standard fs is remote
+       emit --no-wait filesystem
+
        # Turn on process accounting
        if [ -x /etc/rc.d/rc.acct ]; then
                /etc/rc.d/rc.acct start
        fi
 
        # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
-       if is_yes "$TIME_SETUP_DELAYED"; then
-               if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
+       if is_yes "$TIME_SETUP_DELAYED" && [ -e /dev/rtc -o -e /dev/rtc0 ]; then
+               if run_cmd "$(nls 'Setting clock')" hwclock --hctosys; then
                        show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
                fi
        fi
@@ -889,15 +909,21 @@ if ! is_yes "$VSERVER"; then
 
        if [ -f /proc/sys/kernel/panic -a -n "$PANIC_REBOOT_TIME" -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
                show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy
-               if (sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1); then ok; else fail; fi
+               # NOTE: you should use /etc/sysctl.conf instead
+               if sysctl -w kernel.panic=$PANIC_REBOOT_TIME >/dev/null 2>&1; then ok; else fail; fi
        fi
 
        # ... and here finish configuring parameters
-       /sbin/sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
+       sysctl -e -p /etc/sysctl.conf > /dev/null 2>&1
 else
+       emit --no-wait root-filesystem
+       emit --no-wait virtual-filesystems
+       emit --no-wait local-filesystems
+       emit --no-wait filesystem
+
        # /var/log should be writable now, so start saving the boot output
        if [ "$RC_BOOTLOG" ]; then
-               echo > /var/log/boot.msg
+               echo > /var/log/boot.log
                killall -IO blogd
        fi
 
@@ -923,7 +949,7 @@ for afile in /var/lock/* /var/run/*; do
                        ;;
                esac
        else
-               [ "$bafile" != "hwprofile" ] && rm -f $afile 2> /dev/null
+               [ "$bafile" != "hwprofile" -a "$bafile" != "random-seed" ] && rm -f $afile 2> /dev/null
        fi
 done
 
@@ -949,9 +975,8 @@ else
 fi
 
 # Clean /tmp
-if is_yes "$CLEAN_TMP"; then
-       # XXX LC_ALL needed here
-       rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
+if is_yes "$CLEAN_TMP" && ! is_fsmounted tmpfs /tmp; then
+       LC_ALL=C rm -rf /tmp/* /tmp/.[a-zA-Z0-9]*
 fi
 
 # System protected dirs
@@ -960,9 +985,10 @@ chown root:root /tmp/.ICE-unix
 [ -n "$SELINUX" ] && restorecon /tmp/.ICE-unix >/dev/null 2>&1
 
 if ! is_yes "$VSERVER"; then
-       run_cmd "Enabling swap space" /bin/true
+       run_cmd "Enabling swap space" true
        # Right, now turn on swap in case we swap to files
        swapon -a >/dev/null 2>&1
+       emit --no-wait all-swaps
 
        # If a SCSI tape has been detected, load the st module unconditionally
        # since many SCSI tapes don't deal well with st being loaded and unloaded
@@ -977,7 +1003,7 @@ if ! is_yes "$VSERVER"; then
 
        # Now that we have all of our basic modules loaded and the kernel going,
        # let's dump the syslog ring somewhere so we can find it later
-       dmesg > /var/log/dmesg
+       dmesg --raw > /var/log/dmesg
        i=5
        while [ $i -ge 0 ]; do
                if [ -f /var/log/dmesg.$i ]; then
@@ -988,15 +1014,31 @@ if ! is_yes "$VSERVER"; then
        done
        cp -f /var/log/dmesg /var/log/dmesg.0
        chmod 0600 /var/log/dmesg /var/log/dmesg.0
+else
+       emit --no-wait all-swaps
 fi
 
-kill -TERM $(/sbin/pidof getkey) >/dev/null 2>&1
+if ! is_no "$RC_PROMPT"; then
+       while :; do
+               pid=$(/sbin/pidof getkey)
+               [ -n "$pid" -o -e /var/run/getkey_done ] && break
+               usleep 100000
+       done
+       [ -n "$pid" ] && kill -TERM "$pid" >/dev/null 2>&1
+fi
 } &
 
-# extra check if the background process we just spawned is still running,
+# /proc extra check if the background process we just spawned is still running,
 # as in case of vserver bootup it finishes quite instantly.
 if ! is_no "$RC_PROMPT" && [ -d /proc/$! ]; then
-       /sbin/getkey -c 5 i && touch /var/run/confirm
+       /sbin/getkey i && touch /var/run/confirm
+       touch /var/run/getkey_done
 fi
 wait
+if ! is_no "$RC_PROMPT"; then
+       rm -f /var/run/getkey_done
+fi
 echo
+
+emit --no-wait pld.sysinit-done
+
This page took 0.067653 seconds and 4 git commands to generate.