summaryrefslogtreecommitdiffstats
path: root/source/a/sysvinit-scripts/scripts/rc.S
diff options
context:
space:
mode:
Diffstat (limited to 'source/a/sysvinit-scripts/scripts/rc.S')
-rw-r--r--source/a/sysvinit-scripts/scripts/rc.S193
1 files changed, 113 insertions, 80 deletions
diff --git a/source/a/sysvinit-scripts/scripts/rc.S b/source/a/sysvinit-scripts/scripts/rc.S
index 7b152e90e..20064e558 100644
--- a/source/a/sysvinit-scripts/scripts/rc.S
+++ b/source/a/sysvinit-scripts/scripts/rc.S
@@ -32,14 +32,14 @@ if [ -x /etc/rc.d/rc.loop ]; then
. /etc/rc.d/rc.loop start
fi
-# Initialize udev to manage /dev entries and hotplugging for 3.x kernels.
+# Initialize udev to manage /dev entries and hotplugging.
# You may turn off udev by making the /etc/rc.d/rc.udev file non-executable
# or giving the "nohotplug" option at boot, but realize that if you turn off
# udev that you will have to load all the kernel modules that you need
-# yourself (possibly in /etc/rc.d/rc.modules, which does not promise to list
-# all of them), and make any additional device nodes that you need in the
-# /dev directory. Even USB and IEEE1394 devices will need to have the
-# modules loaded by hand if udev is not used. So use it. :-)
+# yourself (possibly in /etc/rc.d/rc.modules.local), and make any additional
+# device nodes that you need in the /dev directory. Even USB and IEEE1394
+# devices will need to have the modules loaded by hand if udev is not used.
+# So use it. :-)
if grep -wq sysfs /proc/mounts && grep -q devtmpfs /proc/filesystems ; then
if ! grep -wq nohotplug /proc/cmdline ; then
if [ -x /etc/rc.d/rc.udev ]; then
@@ -53,11 +53,11 @@ if grep -wq cgroup /proc/filesystems ; then
if [ -d /sys/fs/cgroup ]; then
# See linux-*/Documentation/cgroups/cgroups.txt (section 1.6)
# Check if we have some tools to autodetect the available cgroup controllers
- if [ -x /usr/bin/lssubsys -a -x /usr/bin/tr -a -x /usr/bin/sed ]; then
+ if [ -x /bin/cut -a -x /bin/tail ]; then
# Mount a tmpfs as the cgroup filesystem root
mount -t tmpfs -o mode=0755 cgroup_root /sys/fs/cgroup
# Autodetect available controllers and mount them in subfolders
- controllers="$(lssubsys -a 2>/dev/null | tr '\n' ' ' | sed s/.$//)"
+ controllers="$(/bin/cut -f 1 /proc/cgroups | /bin/tail -n +2)"
for i in $controllers; do
mkdir /sys/fs/cgroup/$i
mount -t cgroup -o $i $i /sys/fs/cgroup/$i
@@ -73,6 +73,7 @@ if grep -wq cgroup /proc/filesystems ; then
fi
fi
+
# Initialize the Logical Volume Manager.
# This won't start unless we find /etc/lvmtab (LVM1) or
# /etc/lvm/backup/ (LVM2). This is created by /sbin/vgscan, so to
@@ -96,7 +97,36 @@ if [ -r /etc/lvmtab -o -d /etc/lvm/backup ]; then
fi
fi
-# Open any volumes created by cryptsetup:
+# Open any volumes created by cryptsetup.
+#
+# Some notes on /etc/crypttab in Slackware:
+# Only LUKS formatted volumes are supported (except for swap)
+# crypttab follows the following format:
+# <luks_name> <device> <password> <options>
+#
+# <luks_name>: This is the name of your LUKS volume.
+# For example: crypt-home
+#
+# <device>: This is the device containing your LUKS volume.
+# For example: /dev/sda2
+#
+# <password>: This is either the volume password in plain text, or the name of
+# a key file. Use 'none' to interactively enter password on boot.
+#
+# <options>: Comma-separated list of options. Note that there must be a
+# password field for any options to be picked up (use a password of 'none' to
+# get a password prompt at boot). The following options are supported:
+#
+# discard -- this will cause --allow-discards to be passed to the cryptsetup
+# program while opening the LUKS volume.
+#
+# ro -- this will cause --readonly to be passed to the cryptsetup program while
+# opening the LUKS volume.
+#
+# swap -- this option cannot be used with other options. The device given will
+# be formatted as a new encrypted volume with a random key on boot, and used as
+# swap.
+#
if [ -f /etc/crypttab -a -x /sbin/cryptsetup ]; then
# First, check for device-mapper support.
if ! grep -wq device-mapper /proc/devices ; then
@@ -113,25 +143,31 @@ if [ -f /etc/crypttab -a -x /sbin/cryptsetup ]; then
OPTS="${LUKSARRAY[3]}"
LUKSOPTS=""
if echo $OPTS | grep -wq ro ; then LUKSOPTS="${LUKSOPTS} --readonly" ; fi
-
+ if echo $OPTS | grep -wq discard ; then LUKSOPTS="${LUKSOPTS} --allow-discards" ; fi
# Skip LUKS volumes that were already unlocked (in the initrd):
/sbin/cryptsetup status $LUKS 2>/dev/null | head -n 1 | grep -q "is active" && continue
if /sbin/cryptsetup isLuks $DEV 2>/dev/null ; then
- echo "Unlocking LUKS crypt volume '${LUKS}' on device '$DEV':"
- if [ -n "${PASS}" ]; then
- if [ -f ${PASS} ]; then
+ if [ -z "${LUKSOPTS}" ]; then
+ echo "Unlocking LUKS encrypted volume '${LUKS}' on device '$DEV':"
+ else
+ echo "Unlocking LUKS encrypted volume '${LUKS}' on device '$DEV' with options '${LUKSOPTS}':"
+ fi
+ if [ -n "${PASS}" -a "${PASS}" != "none" ]; then
+ if [ -f "${PASS}" ]; then
+ # A password was given a key-file filename
/sbin/cryptsetup ${LUKSOPTS} --key-file=${PASS} luksOpen $DEV $LUKS
- elif [ "${PASS}" != "none" ]; then
- # A password field of 'none' indicates a line for swap:
+ else
+ # A password was provided in plain text
echo "${PASS}" | /sbin/cryptsetup ${LUKSOPTS} luksOpen $DEV $LUKS
fi
else
+ # No password was given, or a password of 'none' was given
/sbin/cryptsetup ${LUKSOPTS} luksOpen $DEV $LUKS </dev/tty0 >/dev/tty0 2>&1
fi
elif echo $OPTS | grep -wq swap ; then
# If any of the volumes is to be used as encrypted swap,
# then encrypt it using a random key and run mkswap:
- echo "Creating encrypted swap on device '$DEV' mapped to '${LUKS}':"
+ echo "Creating encrypted swap volume '${LUKS}' on device '$DEV':"
/sbin/cryptsetup --cipher=aes --key-file=/dev/urandom --key-size=256 create $LUKS $DEV
mkswap /dev/mapper/$LUKS
fi
@@ -146,19 +182,41 @@ if [ -x /etc/rc.d/rc.fuse ]; then
sh /etc/rc.d/rc.fuse start
fi
+# Set the tick and frequency for the system clock.
+# Default values are: TICK=10000 and FREQ=0
+TICK=10000
+FREQ=0
+# If there's a /etc/default/adjtimex config file, source it to override
+# the default TICK and FREQ:
+if [ -r /etc/default/adjtimex ]; then
+ . /etc/default/adjtimex
+fi
+if /sbin/adjtimex --tick $TICK --frequency $FREQ; then
+ echo "Setting the system clock rate: /sbin/adjtimex --tick $TICK --frequency $FREQ"
+else
+ echo "Failed to set system clock with adjtimex, possibly invalid parameters? (TICK=$TICK FREQ=$FREQ)"
+fi
+
# Set the system time from the hardware clock using hwclock --hctosys.
if [ -x /sbin/hwclock ]; then
# Check for a broken motherboard RTC clock (where ioports for rtc are
# unknown) to prevent hwclock causing a hang:
- if ! grep -q -w rtc /proc/ioports ; then
+ if ! grep -q " : rtc" /proc/ioports ; then
CLOCK_OPT="--directisa"
fi
- if grep -wq "^UTC" /etc/hardwareclock ; then
- echo -n "Setting system time from the hardware clock (UTC): "
- /sbin/hwclock $CLOCK_OPT --utc --hctosys
- else
- echo -n "Setting system time from the hardware clock (localtime): "
+ if [ /etc/adjtime -nt /etc/hardwareclock ]; then
+ if grep -q "^LOCAL" /etc/adjtime ; then
+ echo -n "Setting system time from the hardware clock (localtime): "
+ else
+ echo -n "Setting system time from the hardware clock (UTC): "
+ fi
+ /sbin/hwclock $CLOCK_OPT --hctosys
+ elif grep -wq "^localtime" /etc/hardwareclock 2> /dev/null ; then
+ echo -n "Setting system time from the hardware clock (localtime): "
/sbin/hwclock $CLOCK_OPT --localtime --hctosys
+ else
+ echo -n "Setting system time from the hardware clock (UTC): "
+ /sbin/hwclock $CLOCK_OPT --utc --hctosys
fi
date
fi
@@ -224,51 +282,20 @@ if [ ! $READWRITE = yes ]; then
echo "Remounting root device with read-write enabled."
/sbin/mount -w -v -n -o remount /
if [ $? -gt 0 ] ; then
- echo
- echo "Attempt to remount root device as read-write failed! This is going to"
+ echo "FATAL: Attempt to remount root device as read-write failed! This is going to"
echo "cause serious problems."
- echo
- echo "If you're using the UMSDOS filesystem, you **MUST** mount the root partition"
- echo "read-write! You can make sure the root filesystem is getting mounted "
- echo "read-write with the 'rw' flag to Loadlin:"
- echo
- echo "loadlin vmlinuz root=/dev/hda1 rw (replace /dev/hda1 with your root device)"
- echo
- echo "Normal bootdisks can be made to mount a system read-write with the rdev command:"
- echo
- echo "rdev -R /dev/fd0 0"
- echo
- echo "You can also get into your system by using a boot disk with a command like this"
- echo "on the LILO prompt line: (change the root partition name as needed)"
- echo
- echo "LILO: mount root=/dev/hda1 rw"
- echo
- echo "Please press ENTER to continue, then reboot and use one of the above methods to"
- echo -n "get into your machine and start looking for the problem. "
- read junk;
fi
else
echo "Testing root filesystem status: read-write filesystem"
echo
- echo "*** ERROR: Root partition has already been mounted read-write. Cannot check!"
+ echo "ERROR: Root partition has already been mounted read-write. Cannot check!"
echo
echo "For filesystem checking to work properly, your system must initially mount"
- echo "the root partition as read only. Please modify your kernel with 'rdev' so that"
- echo "it does this. If you're booting with LILO, add a line:"
+ echo "the root partition as read only. If you're booting with LILO, add a line:"
echo
echo " read-only"
echo
echo "to the Linux section in your /etc/lilo.conf and type 'lilo' to reinstall it."
- echo
- echo "If you boot from a kernel on a floppy disk, put it in the drive and type:"
- echo " rdev -R /dev/fd0 1"
- echo
- echo "If you boot from a bootdisk, or with Loadlin, you can add the 'ro' flag."
- echo
- echo "This will fix the problem *AND* eliminate this annoying message. :^)"
- echo
- echo -n "Press ENTER to continue. "
- read junk;
fi # Done checking root filesystem
@@ -278,12 +305,15 @@ fi # Done checking root filesystem
# Add entry for / to /etc/mtab:
/sbin/mount -f -w /
-# Add /proc and /sys mounts to /etc/mtab:
+# Add /proc, /sys, and /dev/shm mounts to /etc/mtab:
if [ -d /proc/sys ]; then
- /sbin/mount -f proc /proc -t proc
+ /sbin/mount -f -t proc proc /proc
fi
if [ -d /sys/bus ]; then
- /sbin/mount -f sysfs /sys -t sysfs
+ /sbin/mount -f -t sysfs sysfs /sys
+fi
+if grep -q '^[^ ]\+ /dev/shm ' /proc/mounts 2> /dev/null ; then
+ /sbin/mount -f -t tmpfs tmpfs /dev/shm
fi
# Configure ISA Plug-and-Play devices:
@@ -293,30 +323,20 @@ if [ -r /etc/isapnp.conf ]; then
fi
fi
-# This loads any kernel modules that are needed. These might be required to
-# use your ethernet card, sound card, or other optional hardware.
-# Priority is given first to a script named "rc.modules.local", then
-# to "rc.modules-$FULL_KERNEL_VERSION", and finally to the plain "rc.modules".
-# Note that if /etc/rc.d/rc.modules.local is found, then that will be the ONLY
-# rc.modules script the machine will run, so make sure it has everything in
-# it that you need.
-if [ -x /etc/rc.d/rc.modules.local -a -r /proc/modules ]; then
- echo "Running /etc/rc.d/rc.modules.local:"
- /bin/sh /etc/rc.d/rc.modules.local
-elif [ -x /etc/rc.d/rc.modules-$(uname -r) -a -r /proc/modules ]; then
- echo "Running /etc/rc.d/rc.modules-$(uname -r):"
- . /etc/rc.d/rc.modules-$(uname -r)
-elif [ -x /etc/rc.d/rc.modules -a -r /proc/modules -a -L /etc/rc.d/rc.modules ]; then
- echo "Running /etc/rc.d/rc.modules -> $(readlink /etc/rc.d/rc.modules):"
- . /etc/rc.d/rc.modules
-elif [ -x /etc/rc.d/rc.modules -a -r /proc/modules ]; then
- echo "Running /etc/rc.d/rc.modules:"
+# Run the kernel module script. This updates the module dependencies and
+# also supports manually loading kernel modules through rc.modules.local.
+if [ -x /etc/rc.d/rc.modules ]; then
. /etc/rc.d/rc.modules
fi
-# Configure runtime kernel parameters:
+# Configure kernel parameters:
if [ -x /sbin/sysctl -a -r /etc/sysctl.conf ]; then
- /sbin/sysctl -e -p /etc/sysctl.conf
+ echo "Configuring kernel parameters: /sbin/sysctl -e --system"
+ /sbin/sysctl -e --system
+elif [ -x /sbin/sysctl ]; then
+ echo "Configuring kernel parameters: /sbin/sysctl -e --system"
+ # Don't say "Applying /etc/sysctl.conf" or complain if the file doesn't exist
+ /sbin/sysctl -e --system 2> /dev/null | grep -v "Applying /etc/sysctl.conf"
fi
# Check all the non-root filesystems:
@@ -344,9 +364,12 @@ fi
echo "Mounting non-root local filesystems:"
sleep 3
if /bin/grep -wq devpts /proc/mounts ; then
- /sbin/mount -a -v -t nonfs,nosmbfs,nocifs,noproc,nosysfs,nodevpts
+ # This pipe after the mount command is just to convert the new
+ # mount verbose output back to the old format that contained
+ # more useful information:
+ /sbin/mount -a -v -t nonfs,nosmbfs,nocifs,noproc,nosysfs,nodevpts | grep successfully | cut -f 1 -d : | tr -d ' ' | while read dev ; do mount | grep "${dev} " ; done
else
- /sbin/mount -a -v -t nonfs,nosmbfs,nocifs,noproc,nosysfs
+ /sbin/mount -a -v -t nonfs,nosmbfs,nocifs,noproc,nosysfs | grep successfully | cut -f 1 -d : | tr -d ' ' | while read dev ; do mount | grep "${dev} " ; done
fi
# Enable swapping again. This is needed in case a swapfile is used,
@@ -354,6 +377,11 @@ fi
# mounted read-write.
/sbin/swapon -a 2> /dev/null
+# Start cgmanager (or cgproxy in a container):
+if [ -x /etc/rc.d/rc.cgmanager -a -d /sys/fs/cgroup ]; then
+ sh /etc/rc.d/rc.cgmanager start
+fi
+
# Clean up some temporary files:
rm -f /var/run/* /var/run/*/* /var/run/*/*/* /etc/nologin \
/etc/dhcpc/*.pid /etc/forcefsck /etc/fastboot \
@@ -362,6 +390,11 @@ rm -f /var/run/* /var/run/*/* /var/run/*/*/* /etc/nologin \
( cd /var/log/setup/tmp && rm -rf * )
( cd /tmp && rm -rf kde-[a-zA-Z]* ksocket-[a-zA-Z]* hsperfdata_[a-zA-Z]* plugtmp* )
+# Clear /var/lock/subsys:
+if [ -d /var/lock/subsys ]; then
+ rm -f /var/lock/subsys/*
+fi
+
# Create /tmp/{.ICE-unix,.X11-unix} if they are not present:
if [ ! -e /tmp/.ICE-unix ]; then
mkdir -p /tmp/.ICE-unix