diff options
Diffstat (limited to 'source/a/sysvinit-scripts/scripts')
-rw-r--r-- | source/a/sysvinit-scripts/scripts/rc.6 | 40 | ||||
-rw-r--r-- | source/a/sysvinit-scripts/scripts/rc.M | 42 | ||||
-rw-r--r-- | source/a/sysvinit-scripts/scripts/rc.S | 37 |
3 files changed, 79 insertions, 40 deletions
diff --git a/source/a/sysvinit-scripts/scripts/rc.6 b/source/a/sysvinit-scripts/scripts/rc.6 index 21b5c4782..a091ef035 100644 --- a/source/a/sysvinit-scripts/scripts/rc.6 +++ b/source/a/sysvinit-scripts/scripts/rc.6 @@ -292,7 +292,7 @@ if [ -z "$container" ]; then # (and found to be clean) at boot: /bin/sync echo "Remounting root filesystem read-only:" - /bin/mount -v -n -o remount,ro / + /bin/mount -v -o remount,ro / fi # This never hurts: @@ -323,27 +323,33 @@ fi # This is to ensure all processes have completed on SMP machines: wait -if [ -x /sbin/genpowerd -a -z "$container" ]; then - # See if this is a powerfail situation: - if grep -E -q "FAIL|SCRAM" /etc/upsstatus 2> /dev/null ; then - # Signal UPS to shut off the inverter: - /sbin/genpowerd -k - if [ ! $? = 0 ]; then - echo - echo "There was an error signaling the UPS." - echo "Perhaps you need to edit /etc/genpowerd.conf to configure" - echo "the serial line and UPS type." - # Wasting 15 seconds of precious power: - /bin/sleep 15 - fi - fi -fi - if [ "$container" = "lxc" ]; then # Confirm successful shutdown of the container: echo "LXC container stopped." fi +# NUT UPS inverter shutdown support: +# If we see a file /etc/killpower, that means we want to shut off the UPS +# inverter on the way down. This will save as much battery power as possible +# and avoid unnecessary full-drain/full-recharge cycles. +if [ -e /etc/killpower -a -z "$container" ]; then + # First we need to restart udev or we won't be able to contact the UPS: + echo "Restarting udev to be able to shut the UPS inverter off..." + /etc/rc.d/rc.udev start + # Wasting precious battery power: + sleep 10 + echo "Shutting down UPS inverter..." + upsdrvctl shutdown + # The power should shut off during the following sleep, but we'll give a + # bit of notice otherwise. Also, be sure to set your machine to start when + # the power resumes in the BIOS settings so that it doesn't stay off. + sleep 45 + echo "The UPS power should have stopped by now, but has not." + echo "It's possible that the power came back during the shutdown process." + echo "Otherwise, check communication with the UPS." + sleep 15 +fi + # Now halt (poweroff with APM or ACPI enabled kernels) or reboot. if [ "$shutdown_command" = "reboot" ]; then echo "Rebooting." diff --git a/source/a/sysvinit-scripts/scripts/rc.M b/source/a/sysvinit-scripts/scripts/rc.M index fc63ce083..d101aa268 100644 --- a/source/a/sysvinit-scripts/scripts/rc.M +++ b/source/a/sysvinit-scripts/scripts/rc.M @@ -184,6 +184,11 @@ if [ -x /etc/rc.d/rc.autofs ]; then /etc/rc.d/rc.autofs start fi +# Start dnsmasq, a simple DHCP/DNS server: +if [ -x /etc/rc.d/rc.dnsmasq ]; then + /etc/rc.d/rc.dnsmasq start +fi + # Start the Network Time Protocol daemon: if [ -x /etc/rc.d/rc.ntpd ]; then /etc/rc.d/rc.ntpd start @@ -268,11 +273,6 @@ if [ -x /usr/bin/glib-compile-schemas ]; then /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas >/dev/null 2>&1 & fi -# Start dnsmasq, a simple DHCP/DNS server: -if [ -x /etc/rc.d/rc.dnsmasq ]; then - /etc/rc.d/rc.dnsmasq start -fi - # Start snmpd: if [ -x /etc/rc.d/rc.snmpd ]; then /etc/rc.d/rc.snmpd start @@ -298,17 +298,27 @@ if [ -x /etc/rc.d/rc.smartd -a -z "$container" ]; then /etc/rc.d/rc.smartd start fi -# Monitor the UPS with genpowerd. -# To use this, uncomment this section and edit your settings in -# /etc/genpowerd.conf (serial device, UPS type, etc). For more information, -# see "man genpowerd" or the extensive documentation in the -# /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 -a -z "$container" ]; then -# echo "Starting genpowerd daemon..." -# /sbin/genpowerd -#fi +# Load model-specific drivers for NUT (Network Uninterruptible power supply +# Tools). This should be started on the machine that controls the UPS. See +# the /etc/nut/ directory for configuration files. +# If you manage your UPS using a serial port, you'll need to add the nut user +# to the "dialout" group. +if [ -x /etc/rc.d/rc.nut-drvctl -a -z "$container" ]; then + /etc/rc.d/rc.nut-drvctl start +fi + +# Start the NUT UPS information server. This should be started on the machine +# that controls the UPS. See the /etc/nut/ directory for configuration files. +if [ -x /etc/rc.d/rc.nut-upsd -a -z "$container" ]; then + /etc/rc.d/rc.nut-upsd start +fi + +# Start the NUT UPS monitor and shutdown controller. This should be run on any +# machine that is powered by the UPS to monitor the power supply and initiate +# shutdown if necessary. See the /etc/nut/ directory for configuration files. +if [ -x /etc/rc.d/rc.nut-upsmon -a -z "$container" ]; then + /etc/rc.d/rc.nut-upsmon start +fi # Turn on process accounting. To enable process accounting, make sure the # option for BSD process accounting is enabled in your kernel, and then diff --git a/source/a/sysvinit-scripts/scripts/rc.S b/source/a/sysvinit-scripts/scripts/rc.S index 85a2ebc31..2e44be8be 100644 --- a/source/a/sysvinit-scripts/scripts/rc.S +++ b/source/a/sysvinit-scripts/scripts/rc.S @@ -16,12 +16,12 @@ fi # Mount /proc if it is not already mounted: if [ ! -d /proc/sys -a -z "$container" ]; then - /sbin/mount -v proc /proc -n -t proc 2> /dev/null + /sbin/mount -v proc /proc -t proc 2> /dev/null fi # Mount /sys if it is not already mounted: if [ ! -d /sys/kernel -a -z "$container" ]; then - /sbin/mount -v sysfs /sys -n -t sysfs 2> /dev/null + /sbin/mount -v sysfs /sys -t sysfs 2> /dev/null fi # The efivarfs filesystem is used for reading and writing EFI variables, such @@ -53,7 +53,7 @@ fi # initrd has already done so): 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 + /sbin/mount -v -t tmpfs tmpfs /run -o mode=0755,size=32M,nodev,nosuid,noexec fi fi @@ -140,6 +140,24 @@ if [ -z "$container" ]; then /sbin/swapon -a 2> /dev/null fi +# Enable swapping on a ZRAM device: +if [ -z "$container" -a -r /etc/default/zram ]; then + . /etc/default/zram + if [ "$ZRAM_ENABLE" = "1" ]; then + if [ ! -d /sys/devices/virtual/block/zram0 ]; then + modprobe zram num_devices=$ZRAMNUMBER + fi + echo "Setting up /dev/zram0: zramctl -f -a $ZRAMCOMPRESSION -s ${ZRAMSIZE}K" + ZRAM_DEVICE=$(zramctl -f -a $ZRAMCOMPRESSION -s ${ZRAMSIZE}K) + if [ ! -z $ZRAM_DEVICE ]; then + mkswap $ZRAM_DEVICE 1> /dev/null 2> /dev/null + echo "Activating ZRAM swap: swapon --priority $ZRAMPRIORITY $ZRAM_DEVICE" + swapon --priority $ZRAMPRIORITY $ZRAM_DEVICE + fi + fi + unset MEMTOTAL ZRAMCOMPRESSION ZRAMNUMBER ZRAMSIZE ZRAM_DEVICE ZRAM_ENABLE +fi + # Set the tick and frequency for the system clock. # Default values are: TICK=10000 and FREQ=0 if [ -z "$container" ]; then @@ -202,8 +220,13 @@ 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 / + echo "Remounting f2fs root device with read-write enabled." + /sbin/mount -w -v -o remount / + # If we're using bcachefs for the root filesystem(s), remount read-write + # and let bcachefs do its own fsck: + elif grep -q ' / bcachefs ' /proc/mounts ; then + echo "Remounting bcachefs root device(s) with read-write enabled." + /sbin/mount -o remount,rw,fsck / elif [ ! $READWRITE = yes ]; then # Check the root filesystem: RETVAL=0 @@ -242,13 +265,13 @@ if [ -z "$container" ]; then fi echo "Unmounting file systems." /sbin/umount -a -r - /sbin/mount -n -o remount,ro / + /sbin/mount -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 / + /sbin/mount -w -v -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." |