]> 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 267eab2443bcee56fd724f009f7f0fe3362acd57..d486c8e797bb5ab269b6cc345a49f044d2ad2e12 100755 (executable)
@@ -109,7 +109,9 @@ load_kernel_modules() {
                [ -z "$module" ] && continue
                # strip comments
                args=${args%%#*}
-               modprobe -s $module -- $args
+               show "Loading %s kernel module(s)" "$module"
+               busy
+               modprobe -s $module -- $args && ok || fail
        done
 }
 
@@ -171,7 +173,10 @@ if ! is_yes "$VSERVER" ; then
        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)
@@ -261,7 +266,8 @@ if ! is_yes "$VSERVER"; then
                dmesg -n $CONSOLE_LOGLEVEL
        fi
 
-       if ! is_no "$START_UDEV" && [ -x /sbin/start_udev ]; then
+       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
@@ -379,7 +385,7 @@ 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" != "aufs" -a "$_ROOTFS_TYPE" != "nfs" -a "$_ROOTFS_TYPE" != "romfs" -a "$_ROOTFS_TYPE" != "squashfs" -a "$_ROOTFS_PASSNO" != 0 -a -e $_ROOTFS_DEVICE ]; then
+       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
 
@@ -463,25 +469,28 @@ 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
+               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
 
        emit --no-wait root-filesystem
@@ -564,6 +573,13 @@ if ! is_yes "$VSERVER"; then
        # Load 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 ] && ! is_no "$DM_MULTIPATH"; then
@@ -607,7 +623,7 @@ if ! is_yes "$VSERVER"; then
        fi
 
        # LVM (keep in sync with LVM starting after RAID run!)
-       if is_no "$LVM2" || [ -x /sbin/vgscan -a -x /sbin/vgchange ] || is_yes "$EVMS_LVM"; then
+       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
@@ -615,23 +631,26 @@ if ! is_yes "$VSERVER"; then
                fi
                if [ "$lvmversion" = "1" ] ; then
                        modprobe -s lvm-mod >/dev/null 2>&1
+                       lvmignorelocking=""
                        lvmsysinit=""
                elif [ "$lvmversion" = "2" ] ; then
                        modprobe -s dm-mod >/dev/null 2>&1
+                       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
+                       lvmignorelocking=""
                        lvmsysinit=""
                fi
 
-               run_cmd "Scanning for LVM volume groups" /sbin/vgscan $lvmsysinit
+               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 $lvmsysinit
+                       /sbin/vgmknodes $lvmignorelocking
                        # display VG statistics
-                       /sbin/vgdisplay -s $lvmsysinit
+                       /sbin/vgdisplay -s $lvmignorelocking
                fi
        fi
 
@@ -650,9 +669,9 @@ 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
+                               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
+                                       /sbin/mdadm --assemble --scan --auto=yes
                                        rc=$?
                                        if [ "$rc" -eq 0 -o "$rc" -eq 2 ]; then
                                                # rc is used later, too so set sane value
@@ -730,7 +749,7 @@ if ! is_yes "$VSERVER"; then
                        # LVM on RAID (keep in sync with LVM setting few lines above)
                        if [ "$golvm" -eq "1" ]; then
                                if [ -x /sbin/vgscan -a -x /sbin/vgchange ]; then
-                                       run_cmd "Scanning for LVM volume groups (on RAID)" /sbin/vgscan $lvmsysinit
+                                       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
@@ -794,7 +813,7 @@ if ! is_yes "$VSERVER"; then
        # option is removed from /etc/mtab
        if [ -z "$fastboot" ] && grep "^[^#].*encryption=" /etc/fstab 2>/dev/null | grep -v -q "noauto" 2>/dev/null; then
                show "Checking encrypted filesystems"; started
-               LOOPLIST="$(awk '
+               LOOPLIST="$(LC_ALL=C awk '
                FILENAME=="/proc/mounts" {
                        TAB[$2]=$1;
                }
@@ -837,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;
                }
@@ -956,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
@@ -985,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
This page took 0.04371 seconds and 4 git commands to generate.