diff options
Diffstat (limited to 'source/a/sysvinit-scripts')
-rw-r--r-- | source/a/sysvinit-scripts/scripts/rc.6 | 84 | ||||
-rw-r--r-- | source/a/sysvinit-scripts/scripts/rc.M | 43 | ||||
-rw-r--r-- | source/a/sysvinit-scripts/scripts/rc.S | 358 | ||||
-rwxr-xr-x | source/a/sysvinit-scripts/sysvinit-scripts.SlackBuild | 2 |
4 files changed, 271 insertions, 216 deletions
diff --git a/source/a/sysvinit-scripts/scripts/rc.6 b/source/a/sysvinit-scripts/scripts/rc.6 index e9197ff45..383c5490b 100644 --- a/source/a/sysvinit-scripts/scripts/rc.6 +++ b/source/a/sysvinit-scripts/scripts/rc.6 @@ -4,15 +4,21 @@ # 0 (halt) or runlevel 6 (reboot). It kills all processes, # unmounts file systems and then either halts or reboots. # -# Version: @(#)/etc/rc.d/rc.6 2.47 Sat Jan 13 13:37:26 PST 2001 +# Version: @(#)/etc/rc.d/rc.6 15.0 Wed Nov 10 21:19:42 UTC 2021 # # Author: Miquel van Smoorenburg <miquels@drinkel.nl.mugnet.org> # Modified by: Patrick J. Volkerding, <volkerdi@slackware.com> -# # Set the path. PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin +# If we are in an lxc container, set $container to skip parts of the script. +# Thanks to Matteo Bernardini <ponce@slackbuilds.org> and Chris Willing for +# the initial work making this script lxc compatible. +if grep -aq container=lxc /proc/1/environ 2> /dev/null ; then + container="lxc" +fi + # If there are SystemV init scripts for this runlevel, run them. if [ -x /etc/rc.d/rc.sysvinit ]; then /etc/rc.d/rc.sysvinit @@ -43,7 +49,7 @@ esac # Save the system time to the hardware clock using hwclock --systohc. # This will also create or update the timestamps in /etc/adjtime. -if [ -x /sbin/hwclock ]; then +if [ -x /sbin/hwclock -a -z "$container" ]; then # Check for a broken motherboard RTC clock (where ioports for rtc are # unknown) to prevent hwclock causing a hang: if ! grep -q " : rtc" /proc/ioports ; then @@ -112,7 +118,7 @@ if [ -x /etc/rc.d/rc.openldap ]; then fi # Stop the haveged entropy daemon: -if [ -x /etc/rc.d/rc.haveged ]; then +if [ -x /etc/rc.d/rc.haveged -a -z "$container" ]; then /etc/rc.d/rc.haveged stop fi @@ -172,7 +178,7 @@ if /bin/ls /etc/dhcpc/*.pid 1> /dev/null 2> /dev/null ; then fi # Shut down PCMCIA devices: -if [ -x /etc/rc.d/rc.pcmcia ]; then +if [ -x /etc/rc.d/rc.pcmcia -a -z "$container" ]; then /etc/rc.d/rc.pcmcia stop # The cards might need a little extra time here to deactivate: /bin/sleep 5 @@ -184,12 +190,12 @@ if [ -x /sbin/accton -a -r /var/log/pacct ]; then fi # Terminate acpid before syslog: -if [ -x /etc/rc.d/rc.acpid -a -r /var/run/acpid.pid ]; then # quit +if [ -x /etc/rc.d/rc.acpid -a -r /var/run/acpid.pid -a -z "$container" ]; then # quit /etc/rc.d/rc.acpid stop fi # Stop udev: -if [ -x /etc/rc.d/rc.udev ]; then +if [ -x /etc/rc.d/rc.udev -a -z "$container" ]; then /etc/rc.d/rc.udev force-stop fi @@ -205,48 +211,52 @@ fi # Try to turn off quota. if /bin/grep -q quota /etc/fstab ; then - if [ -x /sbin/quotaoff ]; then + if [ -x /sbin/quotaoff -a -z "$container" ]; then echo "Turning off filesystem quotas." /sbin/quotaoff -a fi fi # Carry a random seed between reboots. -echo "Saving random seed from /dev/urandom in /etc/random-seed." -# Use the pool size from /proc, or 4096 bits: -if [ -r /proc/sys/kernel/random/poolsize ]; then - /bin/dd if=/dev/urandom of=/etc/random-seed count=1 bs=$(expr $(cat /proc/sys/kernel/random/poolsize) / 8) 2> /dev/null -else - /bin/dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2> /dev/null +if [ -z "$container" ]; then + echo "Saving random seed from /dev/urandom in /etc/random-seed." + # Use the pool size from /proc, or 4096 bits: + if [ -r /proc/sys/kernel/random/poolsize ]; then + /bin/dd if=/dev/urandom of=/etc/random-seed count=1 bs=$(expr $(cat /proc/sys/kernel/random/poolsize) / 8) 2> /dev/null + else + /bin/dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2> /dev/null + fi + /bin/chmod 600 /etc/random-seed fi -/bin/chmod 600 /etc/random-seed # Before unmounting file systems write a reboot or halt record to wtmp. $shutdown_command -w # Turn off swap: -if [ ! "$(cat /proc/swaps | wc -l)" = "1" ]; then +if [ ! "$(cat /proc/swaps | wc -l)" = "1" -a -z "$container" ]; then echo "Turning off swap." /sbin/swapoff -a /bin/sync fi # Umount all tmpfs mounts except /dev/shm and under /run: -cat /proc/mounts | grep " tmpfs " | grep -v -e " /run " -e " /run/" -e " /dev/shm " | while read mount ; do - umount --recursive -v $(echo $mount | cut -f 2 -d ' ') 2> /dev/null -done +if [ -z "$container" ]; then + cat /proc/mounts | grep " tmpfs " | grep -v -e " /run " -e " /run/" -e " /dev/shm " | while read mount ; do + umount --recursive -v $(echo $mount | cut -f 2 -d ' ') 2> /dev/null + done +fi # Unmount local file systems: -echo "Unmounting local file systems:" -/bin/umount -v -a -t no,proc,sysfs,devtmpfs,fuse.gvfsd-fuse,tmpfs - -# JFS needs a sync here or the / partition cannot be remounted read-only. -# In spite of this, it seems that a JFS root partition will always be checked -# (and found to be clean) at boot: -/bin/sync - -echo "Remounting root filesystem read-only:" -/bin/mount -v -n -o remount,ro / +if [ -z "$container" ]; then + echo "Unmounting local file systems:" + /bin/umount -v -a -t no,proc,sysfs,devtmpfs,fuse.gvfsd-fuse,tmpfs + # JFS needs a sync here or the / partition cannot be remounted read-only. + # In spite of this, it seems that a JFS root partition will always be checked + # (and found to be clean) at boot: + /bin/sync + echo "Remounting root filesystem read-only:" + /bin/mount -v -n -o remount,ro / +fi # This never hurts: /bin/sync @@ -273,9 +283,11 @@ if [ -f /etc/crypttab -a -x /sbin/cryptsetup ]; then fi # Deactivate LVM volume groups: -if [ -r /etc/lvmtab -o -d /etc/lvm/backup ]; then - echo "Deactivating LVM volume groups:" - /sbin/vgchange -an +if [ -z "$container" ]; then + if [ -r /etc/lvmtab -o -d /etc/lvm/backup ]; then + echo "Deactivating LVM volume groups:" + /sbin/vgchange -an + fi fi # This never hurts again (especially since root-on-LVM always fails @@ -290,7 +302,7 @@ fi # This is to ensure all processes have completed on SMP machines: wait -if [ -x /sbin/genpowerd ]; then +if [ -x /sbin/genpowerd -a -z "$container" ]; then # See if this is a powerfail situation: if /bin/egrep -q "FAIL|SCRAM" /etc/upsstatus 2> /dev/null ; then # Signal UPS to shut off the inverter: @@ -306,6 +318,11 @@ if [ -x /sbin/genpowerd ]; then fi fi +if [ "$container" = "lxc" ]; then + # Confirm successful shutdown of the container: + echo "LXC container stopped." +fi + # Now halt (poweroff with APM or ACPI enabled kernels) or reboot. if [ "$shutdown_command" = "reboot" ]; then echo "Rebooting." @@ -313,4 +330,3 @@ if [ "$shutdown_command" = "reboot" ]; then else /sbin/poweroff fi - diff --git a/source/a/sysvinit-scripts/scripts/rc.M b/source/a/sysvinit-scripts/scripts/rc.M index 8a1a9b046..c1e04c58f 100644 --- a/source/a/sysvinit-scripts/scripts/rc.M +++ b/source/a/sysvinit-scripts/scripts/rc.M @@ -14,6 +14,13 @@ # Tell the viewers what's going to happen. echo "Going multiuser..." +# If we are in an lxc container, set $container to skip parts of the script. +# Thanks to Matteo Bernardini <ponce@slackbuilds.org> and Chris Willing for +# the initial work making this script lxc compatible. +if grep -aq container=lxc /proc/1/environ 2> /dev/null ; then + container="lxc" +fi + # Update all the shared library links: if [ -x /sbin/ldconfig ]; then echo "Updating shared library links: /sbin/ldconfig &" @@ -22,17 +29,19 @@ fi # Call the setterm init script to set screen blanking and power management # defaults: -if [ -x /etc/rc.d/rc.setterm ]; then +if [ -x /etc/rc.d/rc.setterm -a -z "$container" ]; then /etc/rc.d/rc.setterm fi -# Set the hostname. -if [ -r /etc/HOSTNAME ]; then - /bin/hostname $(cat /etc/HOSTNAME) -else - # fall back on this old default: - echo "darkstar.example.net" > /etc/HOSTNAME - /bin/hostname $(cat /etc/HOSTNAME) +# Set the hostname: +if [ -z "$container" ]; then + if [ -r /etc/HOSTNAME ]; then + /bin/hostname $(cat /etc/HOSTNAME) + else + # fall back on this old default: + echo "darkstar.example.net" > /etc/HOSTNAME + /bin/hostname $(cat /etc/HOSTNAME) + fi fi # Set the permissions on /var/log/dmesg according to whether the kernel @@ -68,7 +77,7 @@ fi # Hopefully this situation will be unified in the future, but for now # that's how it is... # -if [ -x /etc/rc.d/rc.pcmcia ]; then +if [ -x /etc/rc.d/rc.pcmcia -a -z "$container" ]; then /etc/rc.d/rc.pcmcia start # The cards might need a little extra time here to initialize. sleep 5 @@ -90,19 +99,19 @@ fi # to look for device changes and to generate persistent rules if needed. 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 + if [ -x /etc/rc.d/rc.udev -a -z "$container" ]; then /etc/rc.d/rc.udev start fi fi fi # Start the haveged entropy daemon: -if [ -x /etc/rc.d/rc.haveged ]; then +if [ -x /etc/rc.d/rc.haveged -a -z "$container" ]; then /etc/rc.d/rc.haveged start fi # Start the rngd entropy daemon: -if [ -x /etc/rc.d/rc.rngd ]; then +if [ -x /etc/rc.d/rc.rngd -a -z "$container" ]; then /etc/rc.d/rc.rngd start fi @@ -167,12 +176,12 @@ chmod 755 / 2> /dev/null chmod 1777 /tmp /var/tmp # Start ACPI daemon. -if [ -x /etc/rc.d/rc.acpid ]; then +if [ -x /etc/rc.d/rc.acpid -a -z "$container" ]; then /etc/rc.d/rc.acpid start fi # Enable CPU frequency scaling: -if [ -x /etc/rc.d/rc.cpufreq ]; then +if [ -x /etc/rc.d/rc.cpufreq -a -z "$container" ]; then /etc/rc.d/rc.cpufreq start fi @@ -258,7 +267,7 @@ fi # Start smartd, which monitors the status of S.M.A.R.T. compatible # hard drives and reports any problems: -if [ -x /etc/rc.d/rc.smartd ]; then +if [ -x /etc/rc.d/rc.smartd -a -z "$container" ]; then /etc/rc.d/rc.smartd start fi @@ -269,7 +278,7 @@ fi # /usr/doc/genpower-*/ directory. # You'll also need to configure a similar block in /etc/rc.d/rc.6 if you want # support for stopping the UPS's inverter after the machine halts. -#if [ -x /sbin/genpowerd ]; then +#if [ -x /sbin/genpowerd -a -z "$container" ]; then # echo "Starting genpowerd daemon..." # /sbin/genpowerd #fi @@ -339,7 +348,7 @@ elif [ -x /etc/rc.d/rc.postfix -a -x usr/sbin/postdrop ]; then fi # Load ALSA (sound) defaults: -if [ -x /etc/rc.d/rc.alsa ]; then +if [ -x /etc/rc.d/rc.alsa -a -z "$container" ]; then /etc/rc.d/rc.alsa fi diff --git a/source/a/sysvinit-scripts/scripts/rc.S b/source/a/sysvinit-scripts/scripts/rc.S index ecf2e5502..1edce78e9 100644 --- a/source/a/sysvinit-scripts/scripts/rc.S +++ b/source/a/sysvinit-scripts/scripts/rc.S @@ -7,26 +7,33 @@ PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin +# If we are in an lxc container, set $container to skip parts of the script. +# Thanks to Matteo Bernardini <ponce@slackbuilds.org> and Chris Willing for +# the initial work making this script lxc compatible. +if grep -aq container=lxc /proc/1/environ 2> /dev/null ; then + container="lxc" +fi + # Mount /proc if it is not already mounted: -if [ ! -d /proc/sys ]; then +if [ ! -d /proc/sys -a -z "$container" ]; then /sbin/mount -v proc /proc -n -t proc 2> /dev/null fi # Mount /sys if it is not already mounted: -if [ ! -d /sys/kernel ]; then +if [ ! -d /sys/kernel -a -z "$container" ]; then /sbin/mount -v sysfs /sys -n -t sysfs 2> /dev/null fi # If /run exists, mount a tmpfs on it (unless the # initrd has already done so): -if [ -d /run ]; then +if [ -d /run -a -z "$container" ]; then if ! grep -wq "tmpfs /run tmpfs" /proc/mounts ; then /sbin/mount -v -n -t tmpfs tmpfs /run -o mode=0755,size=32M,nodev,nosuid,noexec fi fi # Load the loop device kernel module: -if [ -x /etc/rc.d/rc.loop ]; then +if [ -x /etc/rc.d/rc.loop -a -z "$container" ]; then /etc/rc.d/rc.loop start fi @@ -40,34 +47,36 @@ fi # 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 + if [ -x /etc/rc.d/rc.udev -a -z "$container" ]; then /etc/rc.d/rc.udev start fi fi fi # Mount Control Groups filesystem interface: -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 /bin/cut -a -x /bin/tail ]; then - # Mount a tmpfs as the cgroup filesystem root - mount -t tmpfs -o mode=0755,size=8M cgroup_root /sys/fs/cgroup - # Autodetect available controllers and mount them in subfolders - 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 - done - unset i controllers +if [ -z "$container" ]; then + 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 /bin/cut -a -x /bin/tail ]; then + # Mount a tmpfs as the cgroup filesystem root + mount -t tmpfs -o mode=0755,size=8M cgroup_root /sys/fs/cgroup + # Autodetect available controllers and mount them in subfolders + 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 + done + unset i controllers + else + # We can't use autodetection so fall back mounting them all together + mount -t cgroup cgroup /sys/fs/cgroup + fi else - # We can't use autodetection so fall back mounting them all together - mount -t cgroup cgroup /sys/fs/cgroup + mkdir -p /dev/cgroup + mount -t cgroup cgroup /dev/cgroup fi - else - mkdir -p /dev/cgroup - mount -t cgroup cgroup /dev/cgroup fi fi @@ -76,21 +85,23 @@ fi # /etc/lvm/backup/ (LVM2). This is created by /sbin/vgscan, so to # use LVM you must run /sbin/vgscan yourself the first time (and # create some VGs and LVs). -# Create LVM lock/run directories: -mkdir -p -m 0700 /run/lvm /run/lock /run/lock/lvm -if [ -r /etc/lvmtab -o -d /etc/lvm/backup ]; then - echo "Initializing LVM (Logical Volume Manager):" - # Check for device-mapper support. - if ! grep -wq device-mapper /proc/devices ; then - # Try to load a device-mapper kernel module: - /sbin/modprobe -q dm-mod - fi - # Scan for new volume groups: - /sbin/vgscan --mknodes --ignorelockingfailure 2> /dev/null - if [ $? = 0 ]; then - # Make volume groups available to the kernel. - # This should also make logical volumes available. - /sbin/vgchange -ay --ignorelockingfailure +if [ -z "$container" ]; then + # Create LVM lock/run directories: + mkdir -p -m 0700 /run/lvm /run/lock /run/lock/lvm + if [ -r /etc/lvmtab -o -d /etc/lvm/backup ]; then + echo "Initializing LVM (Logical Volume Manager):" + # Check for device-mapper support. + if ! grep -wq device-mapper /proc/devices ; then + # Try to load a device-mapper kernel module: + /sbin/modprobe -q dm-mod + fi + # Scan for new volume groups: + /sbin/vgscan --mknodes --ignorelockingfailure 2> /dev/null + if [ $? = 0 ]; then + # Make volume groups available to the kernel. + # This should also make logical volumes available. + /sbin/vgchange -ay --ignorelockingfailure + fi fi fi @@ -124,7 +135,7 @@ fi # 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 +if [ -f /etc/crypttab -a -x /sbin/cryptsetup -a -z "$container" ]; then # First, check for device-mapper support. if ! grep -wq device-mapper /proc/devices ; then # If device-mapper exists as a module, try to load it. @@ -172,25 +183,29 @@ if [ -f /etc/crypttab -a -x /sbin/cryptsetup ]; then fi # Enable swapping: -/sbin/swapon -a 2> /dev/null +if [ -z "$container" ]; then + /sbin/swapon -a 2> /dev/null +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)" +if [ -z "$container" ]; then + 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 fi # Set the system time from the hardware clock using hwclock --hctosys. -if [ -x /sbin/hwclock ]; then +if [ -x /sbin/hwclock -a -z "$container" ]; then # Check for a broken motherboard RTC clock (where ioports for rtc are # unknown) to prevent hwclock causing a hang: if ! grep -q " : rtc" /proc/ioports ; then @@ -214,106 +229,113 @@ if [ -x /sbin/hwclock ]; then fi # Test to see if the root partition is read-only, like it ought to be. -READWRITE=no -if touch /fsrwtestfile 2>/dev/null; then - rm -f /fsrwtestfile - READWRITE=yes -else - echo "Testing root filesystem status: read-only filesystem" +if [ -z "$container" ]; then + READWRITE=no + if touch /fsrwtestfile 2>/dev/null; then + rm -f /fsrwtestfile + READWRITE=yes + else + echo "Testing root filesystem status: read-only filesystem" + fi fi # See if a forced filesystem check was requested at shutdown: -if [ -r /etc/forcefsck ]; then +if [ -r /etc/forcefsck -a -z "$container" ]; then FORCEFSCK="-f" fi -# If we're using F2FS for the root filesystem, don't check it as it doesn't -# allow checking a read-only filesystem: -if grep -q ' / f2fs ' /proc/mounts ; then - echo "Remounting root device with read-write enabled." - /sbin/mount -w -v -n -o remount / -elif [ ! $READWRITE = yes ]; then - # Check the root filesystem: - RETVAL=0 - if [ ! -r /etc/fastboot ]; then - echo "Checking root filesystem:" - /sbin/fsck $FORCEFSCK -C -a / - RETVAL=$? - fi - # An error code of 2 or higher will require a reboot. - if [ $RETVAL -ge 2 ]; then - # An error code equal to or greater than 4 means that some errors - # could not be corrected. This requires manual attention, so we - # offer a chance to try to fix the problem in single-user mode: - if [ $RETVAL -ge 4 ]; then - echo - echo "***********************************************************" - echo "*** An error occurred during the root filesystem check. ***" - echo "*** You will now be given a chance to log into the ***" - echo "*** system in single-user mode to fix the problem. ***" - echo "*** ***" - echo "*** If you are using the ext2 filesystem, running ***" - echo "*** 'e2fsck -v -y <partition>' might help. ***" - echo "***********************************************************" - echo - echo "Once you exit the single-user shell, the system will reboot." - echo - PS1="(Repair filesystem) \#"; export PS1 - sulogin - else # With an error code of 2 or 3, reboot the machine automatically: - echo - echo "***********************************" - echo "*** The filesystem was changed. ***" - echo "*** The system will now reboot. ***" - echo "***********************************" - echo +# Check the root filesystem: +if [ -z "$container" ]; then + # If we're using F2FS for the root filesystem, don't check it as it doesn't + # allow checking a read-only filesystem: + if grep -q ' / f2fs ' /proc/mounts ; then + echo "Remounting root device with read-write enabled." + /sbin/mount -w -v -n -o remount / + elif [ ! $READWRITE = yes ]; then + # Check the root filesystem: + RETVAL=0 + if [ ! -r /etc/fastboot ]; then + echo "Checking root filesystem:" + /sbin/fsck $FORCEFSCK -C -a / + RETVAL=$? fi - echo "Unmounting file systems." - /sbin/umount -a -r - /sbin/mount -n -o remount,ro / - echo "Rebooting system." - reboot -f - fi - # Remount the root filesystem in read-write mode - echo "Remounting root device with read-write enabled." - /sbin/mount -w -v -n -o remount / - if [ $? -gt 0 ] ; then - echo "FATAL: Attempt to remount root device as read-write failed! This is going to" - echo "cause serious problems." - fi -else - echo "Testing root filesystem status: read-write filesystem" - echo - 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. 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." -fi # Done checking root filesystem + # An error code of 2 or higher will require a reboot. + if [ $RETVAL -ge 2 ]; then + # An error code equal to or greater than 4 means that some errors + # could not be corrected. This requires manual attention, so we + # offer a chance to try to fix the problem in single-user mode: + if [ $RETVAL -ge 4 ]; then + echo + echo "***********************************************************" + echo "*** An error occurred during the root filesystem check. ***" + echo "*** You will now be given a chance to log into the ***" + echo "*** system in single-user mode to fix the problem. ***" + echo "*** ***" + echo "*** If you are using the ext2 filesystem, running ***" + echo "*** 'e2fsck -v -y <partition>' might help. ***" + echo "***********************************************************" + echo + echo "Once you exit the single-user shell, the system will reboot." + echo + PS1="(Repair filesystem) \#"; export PS1 + sulogin + else # With an error code of 2 or 3, reboot the machine automatically: + echo + echo "***********************************" + echo "*** The filesystem was changed. ***" + echo "*** The system will now reboot. ***" + echo "***********************************" + echo + fi + echo "Unmounting file systems." + /sbin/umount -a -r + /sbin/mount -n -o remount,ro / + echo "Rebooting system." + reboot -f + fi + # Remount the root filesystem in read-write mode + echo "Remounting root device with read-write enabled." + /sbin/mount -w -v -n -o remount / + if [ $? -gt 0 ] ; then + echo "FATAL: Attempt to remount root device as read-write failed! This is going to" + echo "cause serious problems." + fi + else + echo "Testing root filesystem status: read-write filesystem" + echo + 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. 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." + fi # Done checking root filesystem +fi # If /etc/mtab is a symlink (probably to /proc/mounts) then we don't want to mess with it. if [ ! -L /etc/mtab -o ! -r /etc/mtab ]; then # /etc/mtab is a file (or doesn't exist), so we'll handle it the old way: # Any /etc/mtab that exists here is old, so we start with a new one: /bin/rm -f /etc/mtab{,~,.tmp} && /bin/touch /etc/mtab - # Add /, /proc, /sys, and /dev/shm mounts to /etc/mtab: - /sbin/mount -f -w / - if [ -d /proc/sys ]; then - /sbin/mount -f -t proc proc /proc - fi - if [ -d /sys/bus ]; then - /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 + if [ -z "$container" ]; then + # Add /, /proc, /sys, and /dev/shm mounts to /etc/mtab: + /sbin/mount -f -w / + if [ -d /proc/sys ]; then + /sbin/mount -f -t proc proc /proc + fi + if [ -d /sys/bus ]; then + /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 fi fi # Configure ISA Plug-and-Play devices: -if [ -r /etc/isapnp.conf ]; then +if [ -r /etc/isapnp.conf -a -z "$container" ]; then if [ -x /sbin/isapnp ]; then /sbin/isapnp /etc/isapnp.conf fi @@ -321,31 +343,33 @@ fi # 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 +if [ -x /etc/rc.d/rc.modules -a -z "$container" ]; then /etc/rc.d/rc.modules fi # Configure kernel parameters: -if [ -x /sbin/sysctl -a -r /etc/sysctl.conf ]; then +if [ -x /sbin/sysctl -a -r /etc/sysctl.conf -a -z "$container" ]; then echo "Configuring kernel parameters: /sbin/sysctl -e --system" /sbin/sysctl -e --system -elif [ -x /sbin/sysctl ]; then +elif [ -x /sbin/sysctl -a -z "$container" ]; 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: -if [ ! -r /etc/fastboot ]; then +if [ ! -r /etc/fastboot -a -z "$container" ]; then echo "Checking non-root filesystems:" /sbin/fsck $FORCEFSCK -C -R -A -a fi # Mount usbfs only if it is found in /etc/fstab: -if grep -wq usbfs /proc/filesystems; then - if ! grep -wq usbfs /proc/mounts ; then - if grep -wq usbfs /etc/fstab; then - /sbin/mount -v /proc/bus/usb +if [ -z "$container" ]; then + if grep -wq usbfs /proc/filesystems; then + if ! grep -wq usbfs /proc/mounts ; then + if grep -wq usbfs /etc/fstab; then + /sbin/mount -v /proc/bus/usb + fi fi fi fi @@ -355,14 +379,16 @@ fi # because those have already been mounted. Also check that # devpts is not already mounted before attempting to mount # it. With a 2.6.x or newer kernel udev mounts devpts. -echo "Mounting non-root local filesystems:" -if /bin/grep -wq devpts /proc/mounts ; then - # 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 | grep successfully | cut -f 1 -d : | tr -d ' ' | while read dev ; do mount | grep " ${dev} " ; done +if [ -z "$container" ]; then + echo "Mounting non-root local filesystems:" + if /bin/grep -wq devpts /proc/mounts ; then + # 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 | grep successfully | cut -f 1 -d : | tr -d ' ' | while read dev ; do mount | grep " ${dev} " ; done + fi fi # Make sure that /var/run is a symbolic link pointing to /run: @@ -373,7 +399,9 @@ fi # Enable swapping again. This is needed in case a swapfile is used, # as it can't be enabled until the filesystem it resides on has been # mounted read-write. -/sbin/swapon -a 2> /dev/null +if [ -z "$container" ]; then + /sbin/swapon -a 2> /dev/null +fi # Start libcgroup services: if [ -x /etc/rc.d/rc.cgconfig -a -x /etc/rc.d/rc.cgred -a -d /sys/fs/cgroup ]; then @@ -430,19 +458,21 @@ fi # CAREFUL! This can make some systems hang if the rc.serial script isn't # set up correctly. If this happens, you may have to edit the file from a # boot disk, and/or set it as non-executable: -if [ -x /etc/rc.d/rc.serial ]; then +if [ -x /etc/rc.d/rc.serial -a -z "$container" ]; then /etc/rc.d/rc.serial start fi # Carry an entropy pool between reboots to improve randomness. -if [ -f /etc/random-seed ]; then - echo "Using /etc/random-seed to initialize /dev/urandom." - cat /etc/random-seed > /dev/urandom -fi -# Use the pool size from /proc, or 4096 bits: -if [ -r /proc/sys/kernel/random/poolsize ]; then - dd if=/dev/urandom of=/etc/random-seed count=1 bs=$(expr $(cat /proc/sys/kernel/random/poolsize) / 8) 2> /dev/null -else - dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2> /dev/null +if [ -z "$container" ]; then + if [ -f /etc/random-seed ]; then + echo "Using /etc/random-seed to initialize /dev/urandom." + cat /etc/random-seed > /dev/urandom + fi + # Use the pool size from /proc, or 4096 bits: + if [ -r /proc/sys/kernel/random/poolsize ]; then + dd if=/dev/urandom of=/etc/random-seed count=1 bs=$(expr $(cat /proc/sys/kernel/random/poolsize) / 8) 2> /dev/null + else + dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2> /dev/null + fi + chmod 600 /etc/random-seed fi -chmod 600 /etc/random-seed diff --git a/source/a/sysvinit-scripts/sysvinit-scripts.SlackBuild b/source/a/sysvinit-scripts/sysvinit-scripts.SlackBuild index 6a16c6a91..72391f0b6 100755 --- a/source/a/sysvinit-scripts/sysvinit-scripts.SlackBuild +++ b/source/a/sysvinit-scripts/sysvinit-scripts.SlackBuild @@ -25,7 +25,7 @@ cd $(dirname $0) ; CWD=$(pwd) PKGNAM=sysvinit-scripts VERSION=${VERSION:-15.0} ARCH=noarch -BUILD=${BUILD:-5} +BUILD=${BUILD:-6} # If the variable PRINT_PACKAGE_NAME is set, then this script will report what # the name of the created package would be, and then exit. This information |