]> 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 218c83937775abe2a73cc1434fb866d5b719f00e..d486c8e797bb5ab269b6cc345a49f044d2ad2e12 100755 (executable)
@@ -37,10 +37,10 @@ fi
 CONSOLE_LOGLEVEL=1
 
 # Read functions
-. /etc/rc.d/init.d/functions
+. /lib/rc-scripts/functions
 
 disable_selinux() {
-       typeset _d selinuxfs _t _r
+       local _d selinuxfs _t _r
 
        while read _d selinuxfs _t _r; do
                [ "$_t" = "selinuxfs" ] && break
@@ -52,7 +52,7 @@ disable_selinux() {
 }
 
 relabel_selinux() {
-       typeset _d selinuxfs _t _r
+       local _d selinuxfs _t _r
 
        while read _d selinuxfs _t _r; do
                [ "$_t" = "selinuxfs" ] && break
@@ -81,8 +81,86 @@ clean_vserver_mtab() {
        rm -f /etc/mtab.clean
 }
 
+# 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
+       {
+               read _x _y v _z
+               old_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 args
+       # Loop over every line in modules file
+       ( \
+               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
+               # strip comments
+               args=${args%%#*}
+               show "Loading %s kernel module(s)" "$module"
+               busy
+               modprobe -s $module -- $args && ok || fail
+       done
+}
+
+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.msg. install showconsole package to get it.
+# 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
@@ -90,24 +168,32 @@ 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
-       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
-               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
+               is_fsmounted sysfs /sys || mount -n -o gid=17 -t sysfs sysfs /sys
+               if grep -q securityfs /proc/filesystems 2>/dev/null ; then
+                       mount -n -o gid=17 -t securityfs securityfs /sys/kernel/security
                fi
-                                                                                                               
        fi
 
        # selinux
-       if grep -q selinuxfs /proc/filesystems 2>/dev/null && ! grep -q selinuxfs /proc/mounts 2>/dev/null; then
+       if grep -q selinuxfs /proc/filesystems 2>/dev/null && ! is_fsmounted selinuxfs /selinux; then
                mount -n -o gid=17 -t selinuxfs selinuxfs /selinux
        fi
 
@@ -127,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)
@@ -141,11 +227,10 @@ if ! is_yes "$VSERVER" ; then
                fi
        fi
 
-       if [ -x /sbin/restorecon ] && LC_ALL=C fgrep -q " /dev " /proc/mounts 2>/dev/null ; then
+       if [ -x /sbin/restorecon ] && is_fsmounted tmpfs /dev; then
                /sbin/restorecon -R /dev 2>/dev/null
        fi
 
-
        [ -z "${CONSOLETYPE}" ] && CONSOLETYPE="$(/sbin/consoletype)"
 
        if [ "$CONSOLETYPE" = "vt" -a -x /sbin/setsysfont ]; then
@@ -178,107 +263,56 @@ fi
 if ! is_yes "$VSERVER"; then
        # Set console loglevel
        if [ -n "$CONSOLE_LOGLEVEL" ]; then
-               /bin/dmesg -n $CONSOLE_LOGLEVEL
+               dmesg -n $CONSOLE_LOGLEVEL
        fi
 
-       [ -x /sbin/start_udev ] && /sbin/start_udev
+       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
        if grep -q /initrd /proc/mounts 2>/dev/null && ! grep -q /initrd/loopfs /proc/mounts 2>/dev/null; then
-               if [ -e /initrd/dev/.devfsd ]; then
-                       umount /initrd/dev
-               fi
                umount /initrd/dev 2>/dev/null
                umount /initrd
                /sbin/blockdev --flushbufs /dev/ram0 >/dev/null 2>&1
        fi
 
-       # /dev must be also mounted before everything but only if we want use them ;-)
-       if is_yes "$MOUNT_DEVFS"; then
-               run_cmd "Mounting Device Filesystem" mount -n -t devfs /dev /dev
-       fi
-       # set up devfsd
-       if [ -e /dev/.devfsd -a -x /sbin/devfsd ]; then
-               run_cmd "Starting Device Filesystem Daemon" /sbin/devfsd /dev
-       fi
-
        # Start logging console output since we have all /dev stuff setup
        if [ "$RC_BOOTLOG" ]; then
                /sbin/blogd
        fi
 
-       # cpuset support (mounted unconditionally, shouldn't be a problem)
-       if grep -q cpuset /proc/filesystems 2>/dev/null ; then
-               # mkdir for udev (FIXME fix the udev instead)
-               mkdir -p /dev/cpuset 2>/dev/null
-               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 -a -e /dev/rtc ] ; 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
 
-       if [ -f /etc/crypttab ]; then
+       delay_cryptsetup=0
+       if [ -f /etc/crypttab ] && ! is_empty_file /etc/crypttab; then
                # XXX might need modules dep
                # Device mapper & related initialization
-               if ! fgrep -q device-mapper /proc/devices; then
+               if ! grep -qF device-mapper /proc/devices; 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
@@ -286,10 +320,10 @@ if ! is_yes "$VSERVER"; then
 
        # Initialize USB controllers
        usb=0
-       if ! strstr "$cmdline" "nousb" && ! grep -q "/proc/bus/usb" /proc/mounts 2>/dev/null ; then
+       if ! strstr "$cmdline" "nousb" && ! is_fsmounted usbfs /proc/bus/usb ; then
                aliases=$(/sbin/modprobe -c | awk '/^alias[\t ]+usb-controller/ { print $3 }')
                if [ -n "$aliases" -a "$aliases" != "off" ] ; then
-                       /sbin/modprobe -s -k usbcore
+                       /sbin/modprobe -s usbcore
                        for alias in $aliases ; do
                                [ "$alias" = "off" ] && continue
                                run_cmd "$(nls 'Initializing USB controller') ($alias)" /sbin/modprobe -s $alias
@@ -301,15 +335,15 @@ if ! is_yes "$VSERVER"; then
                fi
        fi
 
-       if [ "$usb" = "1" -a ! -f /proc/bus/usb/devices ]; then
-               run_cmd "Mounting USB filesystem" mount -n -t usbfs usbfs /proc/bus/usb
+       if [ "$usb" = "1" ] && ! is_fsmounted usbfs /proc/bus/usb ; then
+               run_cmd "Mounting USB filesystem" mount -n -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb
        fi
 
        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
@@ -348,52 +382,11 @@ if ! is_yes "$VSERVER"; then
        fi
 
        _RUN_QUOTACHECK=0
+       _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 ]; 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
@@ -409,7 +402,7 @@ if ! is_yes "$VSERVER"; then
                        run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf
                fi
                if ! is_no "$RUN_KERNELPNP"; then
-                       /sbin/modprobe -k isa-pnp 2> /dev/null
+                       /sbin/modprobe isa-pnp 2> /dev/null
                        if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then
                                show "Setting up ISA PNP devices (kernelspace pnp)"; busy
                                grep -v "^#" /etc/isapnp/isapnp-kernel.conf 2>/dev/null >/proc/isapnp && (deltext; ok) || (deltext; fail)
@@ -417,8 +410,11 @@ if ! is_yes "$VSERVER"; then
                fi
        fi
 
+       _ROOTFS_RO=$(awk '($1 !~ /^#/ && $2 == "/" && ($4 == "ro" || $4 ~ /,ro$/ || $4 ~ /^ro,/ || $4 ~ /,ro,/ ) && NF >= 6) { print "ro" }' /etc/fstab)
        # Remount the root filesystem read-write
-       run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
+       if [ -z "$_ROOTFS_RO" ]; then
+               run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
+       fi
 
        # Update quotas if fsck was run on /
        if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
@@ -432,10 +428,11 @@ if ! is_yes "$VSERVER"; then
                done
        fi
 
-       if [ -f /etc/crypttab ]; then
-               # XXX, this must be probably done after random is initialized from /var/run/random-seed
-               show "Starting disk encryption using the RNG:"
-               init_crypto 1 && ok || fail
+       if [ "$delay_cryptsetup" != 0 ]; then
+               show "Starting disk encryption using the RNG"
+               init_crypto 1
+               delay_cryptsetup=$?
+               [ $delay_cryptsetup = 0 ] && ok || fail
        fi
 else
        # Start logging console output since we have all /dev stuff setup
@@ -445,7 +442,7 @@ else
 fi
 
 # Remove stale backups
-rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~
+rm -f /etc/mtab~ /etc/mtab~~ /etc/cryptomtab~ /etc/cryptomtab~~ >/dev/null 2>&1
 
 # Remove /etc/nologin when starting system
 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
@@ -471,27 +468,34 @@ if ! is_yes "$VSERVER"; then
        :>/etc/mtab
        [ -f /etc/cryptomtab ] && :>/etc/cryptomtab
 
-       # Enter root, /proc, /sys, devfs and other into mtab.
-       mount -f /
-       mount -f /proc
-       [ -f /proc/bus/usb/devices ] && mount -f -t usbfs usbfs /proc/bus/usb
-       [ -e /dev/.devfsd ] && mount -f -t devfs devfs /dev
+       # Enter root, /proc, /sys and other into mtab.
+       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 grep -q sysfs /proc/mounts 2>/dev/null; then
-               mount -f -t sysfs sysfs /sys
-               if grep -q securityfs /proc/mounts 2>/dev/null ; then
-                               mount -f -t securityfs securityfs /sys/kernel/security
-               fi
+       if is_fsmounted usbfs /proc/bus/usb; then
+               mount -f -t usbfs -o devgid=78,devmode=664 usbfs /proc/bus/usb 2> /dev/null
        fi
 
-       if grep -q selinuxfs /proc/mounts 2>/dev/null; then
-               mount -f -t selinuxfs selinuxfs /selinux
+       if is_fsmounted sysfs /sys; then
+               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 2> /dev/null
+               fi
        fi
 
-       if grep -q cpuset /proc/mounts 2>/dev/null; then
-               mount -f -t cpuset none /dev/cpuset
+       if is_fsmounted selinuxfs /selinux; then
+               mount -f -t selinuxfs selinuxfs /selinux 2> /dev/null
        fi
 
+       emit --no-wait root-filesystem
+       emit --no-wait virtual-filesystems
+
        if [ ! -f /proc/modules ]; then
                USEMODULES=
        elif ! strstr "$cmdline" nomodules; then
@@ -500,30 +504,29 @@ if ! is_yes "$VSERVER"; then
                USEMODULES=
        fi
 
+       uname_r=$(uname -r)
        # Adjust symlinks as necessary in /boot to keep system services from
        # spewing messages about mismatched System maps and so on.
        if ! is_no "$SET_SLINKS"; then
-               uname_r=$(uname -r)
                if [ -L /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
                        ln -s -f System.map-$uname_r /boot/System.map
                fi
                if [ ! -e /boot/System.map -a -r /boot/System.map-$uname_r ] ; then
                        ln -s -f System.map-$uname_r /boot/System.map
                fi
-               unset uname_r
        fi
 
        # Run depmod if RUN_DEPMOD != "no" and:
        # a) user requested or RUN_DEPMOD="";
        # b) modules.dep is missing
-       # c) modules.dep is older than /etc/modules.conf or /lib/modules/`uname -r`
        if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
                if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then
                        run_cmd "Finding module dependencies" depmod -a
-               elif [ "$RUN_DEPMOD" = "ifmissing" ]; then
+               elif [ "$RUN_DEPMOD" = "ifmissing" ] && [ ! -f /lib/modules/$uname_r/modules.dep ]; then
                        run_cmd "Finding module dependencies" depmod -A
                fi
        fi
+       unset uname_r
 
        if [ -f /proc/sys/kernel/modprobe ]; then
                if [ -n "$USEMODULES" ]; then
@@ -537,7 +540,7 @@ if ! is_yes "$VSERVER"; then
 
        # Load usb storage here, to match most other things
        if [ -n "$needusbstorage" ]; then
-               modprobe -k usb-storage >/dev/null 2>&1
+               modprobe usb-storage >/dev/null 2>&1
        fi
 
        # Load firewire devices
@@ -548,27 +551,19 @@ 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 [ $(kernelverser) = "002006" ]; then
-               MODULES_CONF=/etc/modprobe.conf
-       elif [ -r /etc/modules.conf ]; then
-               MODULES_CONF=/etc/modules.conf
-       else
-               MODULES_CONF=/etc/conf.modules
-       fi
-
-       if grep -q "^options sound dmabuf=1" "$MODULES_CONF" 2>/dev/null ; then
+       if /sbin/modprobe -c | grep -q "^options sound dmabuf=1"; then
                RETURN=0
-               alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
+               alias=$(/sbin/modprobe -c | grep -sE "^alias[[:space:]]+sound[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
                if [ -n "$alias" -a "$alias" != "off" ] ; then
                        run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
                        RETURN=$?
                fi
-               alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound-slot-0[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
+               alias=$(/sbin/modprobe -c | grep -sE "^alias[[:space:]]+sound-slot-0[[:space:]]+" 2>/dev/null | awk '{ print $3 }')
                if [ -n "$alias" -a "$alias" != "off" ] ; then
                        run_cmd "$(nls 'Loading sound module') ($alias)" modprobe -s $alias
                        RETURN=$?
@@ -576,15 +571,24 @@ if ! is_yes "$VSERVER"; then
        fi
 
        # Load modules
-       if [ -x /etc/rc.d/rc.modules ]; then
-               /etc/rc.d/rc.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
+               modprobe -s dm-multipath
                run_cmd "Activating dm-multipath" /sbin/multipath -v 0
-               /sbin/dmsetup ls --target multipath --exec '/sbin/kpartx -a'
+               /sbin/dmsetup ls --target multipath --exec '/sbin/kpartx -a -p p'
        fi
 
        if [ -x /sbin/dmraid ]; then
@@ -596,19 +600,19 @@ if ! is_yes "$VSERVER"; then
        if [ -x /sbin/evms_activate ]; then
                if [ "$(kernelverser)" -lt "002006" ]; then
                        # Linux 2.4 core modules
-                       modprobe -s -k evms > /dev/null 2>&1
-                       modprobe -s -k evms_passthru > /dev/null 2>&1
-                       modprobe -s -k ldev_mgr > /dev/null 2>&1
-                       modprobe -s -k dos_part > /dev/null 2>&1
+                       modprobe -s evms > /dev/null 2>&1
+                       modprobe -s evms_passthru > /dev/null 2>&1
+                       modprobe -s ldev_mgr > /dev/null 2>&1
+                       modprobe -s dos_part > /dev/null 2>&1
                else
                        # Linux 2.6 core module
-                       modprobe -s -k evmscore > /dev/null 2>&1
+                       modprobe -s evmscore > /dev/null 2>&1
                fi
 
-               is_yes "$EVMS_GUID_PTABLE" && modprobe -s -k gpt_part >/dev/null 2>&1
-               is_yes "$EVMS_LVM" && modprobe -s -k lvm_vge >/dev/null 2>&1
-               is_yes "$EVMS_AIX" && modprobe -s -k AIXlvm_vge >/dev/null 2>&1
-               is_yes "$EVMS_OS2" && modprobe -s -k os2lvm_vge >/dev/null 2>&1
+               is_yes "$EVMS_GUID_PTABLE" && modprobe -s gpt_part >/dev/null 2>&1
+               is_yes "$EVMS_LVM" && modprobe -s lvm_vge >/dev/null 2>&1
+               is_yes "$EVMS_AIX" && modprobe -s AIXlvm_vge >/dev/null 2>&1
+               is_yes "$EVMS_OS2" && modprobe -s os2lvm_vge >/dev/null 2>&1
                run_cmd "Discovering EVMS volumes" /sbin/evms_activate
                if is_yes "$EVMS_LVM" && is_yes "$EVMS_LVM_COMPAT_NODES" ; then
                        # Link nodes for compatibility with LVM
@@ -619,24 +623,42 @@ 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=$(/sbin/vgchange --version 2>/dev/null | awk '{gsub("vgchange: Logical Volume Manager ",""); gsub("LVM version:     ",""); gsub(/\..*/,"");print $1; exit}')
+       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 -k lvm-mod >/dev/null 2>&1
-                       lvmignorelock=""
+                       modprobe -s lvm-mod >/dev/null 2>&1
+                       lvmignorelocking=""
+                       lvmsysinit=""
                elif [ "$lvmversion" = "2" ] ; then
-                       modprobe -s -k dm-mod >/dev/null 2>&1
-                       lvmignorelock="--ignorelockingfailure"
+                       modprobe -s dm-mod >/dev/null 2>&1
+                       lvmignorelocking="--ignorelockingfailure"
+                       lvmsysinit="--sysinit"
                else
-                       modprobe -s -k lvm-mod >/dev/null 2>&1
+                       modprobe -s lvm-mod >/dev/null 2>&1
                        # device mapper (2.5+ and patched 2.4)
-                       modprobe -s -k dm-mod >/dev/null 2>&1
-                       lvmignorelock=""
+                       modprobe -s dm-mod >/dev/null 2>&1
+                       lvmignorelocking=""
+                       lvmsysinit=""
+               fi
+
+               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 $lvmignorelocking
+                       # display VG statistics
+                       /sbin/vgdisplay -s $lvmignorelocking
                fi
+       fi
 
-               run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmignorelock
-               run_cmd "Activating LVM volume groups" /sbin/vgchange -a y $lvmignorelock
-               [ "$lvmversion" = "2" ] && /sbin/vgmknodes
+       if [ "$delay_cryptsetup" != 0 ]; then
+               show "Starting disk encryption"
+               init_crypto 1
+               delay_cryptsetup=$?
+               [ $delay_cryptsetup = 0 ] && ok || fail
        fi
 
        # Add raid devices
@@ -647,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
 
@@ -716,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
@@ -771,7 +803,7 @@ if ! is_yes "$VSERVER"; then
        # now we have /usr mounted, recheck if we have gettext and tput available.
        if is_no "$TPUT"; then
                GETTEXT=
-               TPUT=
+               TPUT=
                rc_gettext_init
        fi
 
@@ -824,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;
                }
@@ -839,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
 
@@ -852,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" && [ -e /dev/rtc ]; 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
@@ -871,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
 
@@ -890,9 +934,10 @@ fi
 [ -n "$SELINUX" ] && [ -f /.autorelabel ] && relabel_selinux
 
 # Clean up /.
-rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff
+rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff >/dev/null 2>&1
 
 # Clean up /var
+# /usr could be still not mounted if it is on NFS.
 for afile in /var/lock/* /var/run/*; do
        bafile=${afile##*/}
        if [ -d "$afile" ]; then
@@ -900,13 +945,14 @@ for afile in /var/lock/* /var/run/*; do
                news|sudo|mon|cvs)
                        ;;
                *)
-                       rm -rf $afile/*
+                       echo $afile/* | xargs rm -rf
                        ;;
                esac
        else
-               [ "$bafile" != "hwprofile" ] && rm -f $afile 2> /dev/null
+               [ "$bafile" != "hwprofile" -a "$bafile" != "random-seed" ] && rm -f $afile 2> /dev/null
        fi
 done
+
 # Delete stale files
 rm -f /var/lib/rpm/__db* /var/spool/postoffice/.pid.* /tmp/.X*-lock \
        /tmp/.lock.* /tmp/.gdm_socket /tmp/.s.PGSQL.*
@@ -929,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
@@ -940,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
@@ -957,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 -s 131072 > /var/log/dmesg
+       dmesg --raw > /var/log/dmesg
        i=5
        while [ $i -ge 0 ]; do
                if [ -f /var/log/dmesg.$i ]; then
@@ -968,18 +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
 
-# This must be last line !
-# vi:syntax=sh
+emit --no-wait pld.sysinit-done
+
This page took 0.105725 seconds and 4 git commands to generate.