CONSOLE_LOGLEVEL=1
# Read functions
-. /etc/rc.d/init.d/functions
+. /lib/rc-scripts/functions
disable_selinux() {
local _d selinuxfs _t _r
# 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 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
# strip comments
args=${args%%#*}
- modprobe -s $module -- $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
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)
# 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
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)
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
/sbin/blogd
fi
- # cpuset support (mount if not found in fstab - should be ^# excluded?)
- if grep -q cgroup /proc/filesystems 2>/dev/null ; then
- if ! grep -q cgroup /etc/fstab 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
- fi
- elif grep -q cpuset /proc/filesystems 2>/dev/null ; then
- if ! grep -q cpuset /etc/fstab 2>/dev/null ; then
- mount -n -t cpuset none /dev/cpuset
- fi
- fi
-
# Configure Linux kernel (initial configuration, some required modules still
# may be missing).
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
-
# Check if timezone definition is available
- if [ -e /etc/localtime -a -e /dev/rtc ] ; then
- if run_cmd "$(nls 'Setting clock')$CLOCKDEF" 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
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
fi
fi
- if [ "$usb" = "1" ] && ! is_fsmounted usbfs /proc/bus/usb ; then
+ if [ "$usb" = "1" -a -d /proc/bus/usb ] && ! 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
_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
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
[ -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
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
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
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
# 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 $lvmignorelock
- run_cmd "Activating LVM volume groups (on RAID)" /sbin/vgchange -a y $lvmignorelock
+ 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
# 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;
}
fi
show "Remounting encrypted filesystems back in rw mode"; busy
- awk '
+ LC_ALL=C awk '
FILENAME=="/proc/mounts" {
TAB[$2]=$1;
}
# /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
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" 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
# /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
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
# 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