slackware-current/source/a/sysvinit-scripts/scripts/rc.6
Patrick J Volkerding a59816a829 Sat Jul 8 19:46:10 UTC 2023
a/cryptsetup-2.6.1-x86_64-3.txz:  Rebuilt.
  rc.luks: support start/stop/status.
  Add a manpage for crypttab.
  Thanks to PiterPunk.
a/sysvinit-scripts-15.1-noarch-6.txz:  Rebuilt.
  rc.M: call "rc.luks start" to unlock any volumes that are still locked.
  rc.6: call "rc.luks stop" to close volumes at shutdown.
  Thanks to PiterPunk.
kde/attica-5.108.0-x86_64-1.txz:  Upgraded.
kde/baloo-5.108.0-x86_64-1.txz:  Upgraded.
kde/bluez-qt-5.108.0-x86_64-1.txz:  Upgraded.
kde/breeze-icons-5.108.0-noarch-1.txz:  Upgraded.
kde/extra-cmake-modules-5.108.0-x86_64-1.txz:  Upgraded.
kde/frameworkintegration-5.108.0-x86_64-1.txz:  Upgraded.
kde/kactivities-5.108.0-x86_64-1.txz:  Upgraded.
kde/kactivities-stats-5.108.0-x86_64-1.txz:  Upgraded.
kde/kapidox-5.108.0-x86_64-1.txz:  Upgraded.
kde/karchive-5.108.0-x86_64-1.txz:  Upgraded.
kde/kauth-5.108.0-x86_64-1.txz:  Upgraded.
kde/kbookmarks-5.108.0-x86_64-1.txz:  Upgraded.
kde/kcalendarcore-5.108.0-x86_64-1.txz:  Upgraded.
kde/kcmutils-5.108.0-x86_64-1.txz:  Upgraded.
kde/kcodecs-5.108.0-x86_64-1.txz:  Upgraded.
kde/kcompletion-5.108.0-x86_64-1.txz:  Upgraded.
kde/kconfig-5.108.0-x86_64-1.txz:  Upgraded.
kde/kconfigwidgets-5.108.0-x86_64-1.txz:  Upgraded.
kde/kcontacts-5.108.0-x86_64-1.txz:  Upgraded.
kde/kcoreaddons-5.108.0-x86_64-1.txz:  Upgraded.
kde/kcrash-5.108.0-x86_64-1.txz:  Upgraded.
kde/kdav-5.108.0-x86_64-1.txz:  Upgraded.
kde/kdbusaddons-5.108.0-x86_64-1.txz:  Upgraded.
kde/kdeclarative-5.108.0-x86_64-1.txz:  Upgraded.
kde/kded-5.108.0-x86_64-1.txz:  Upgraded.
kde/kdelibs4support-5.108.0-x86_64-1.txz:  Upgraded.
kde/kdesignerplugin-5.108.0-x86_64-1.txz:  Upgraded.
kde/kdesu-5.108.0-x86_64-1.txz:  Upgraded.
kde/kdewebkit-5.108.0-x86_64-1.txz:  Upgraded.
kde/kdnssd-5.108.0-x86_64-1.txz:  Upgraded.
kde/kdoctools-5.108.0-x86_64-1.txz:  Upgraded.
kde/kemoticons-5.108.0-x86_64-1.txz:  Upgraded.
kde/kfilemetadata-5.108.0-x86_64-1.txz:  Upgraded.
kde/kglobalaccel-5.108.0-x86_64-1.txz:  Upgraded.
kde/kguiaddons-5.108.0-x86_64-1.txz:  Upgraded.
kde/kholidays-5.108.0-x86_64-1.txz:  Upgraded.
kde/khtml-5.108.0-x86_64-1.txz:  Upgraded.
kde/ki18n-5.108.0-x86_64-1.txz:  Upgraded.
kde/kiconthemes-5.108.0-x86_64-1.txz:  Upgraded.
kde/kidletime-5.108.0-x86_64-1.txz:  Upgraded.
kde/kimageformats-5.108.0-x86_64-1.txz:  Upgraded.
kde/kinit-5.108.0-x86_64-1.txz:  Upgraded.
kde/kio-5.108.0-x86_64-1.txz:  Upgraded.
kde/kirigami2-5.108.0-x86_64-1.txz:  Upgraded.
kde/kitemmodels-5.108.0-x86_64-1.txz:  Upgraded.
kde/kitemviews-5.108.0-x86_64-1.txz:  Upgraded.
kde/kjobwidgets-5.108.0-x86_64-1.txz:  Upgraded.
kde/kjs-5.108.0-x86_64-1.txz:  Upgraded.
kde/kjsembed-5.108.0-x86_64-1.txz:  Upgraded.
kde/kmediaplayer-5.108.0-x86_64-1.txz:  Upgraded.
kde/knewstuff-5.108.0-x86_64-1.txz:  Upgraded.
kde/knotifications-5.108.0-x86_64-1.txz:  Upgraded.
kde/knotifyconfig-5.108.0-x86_64-1.txz:  Upgraded.
kde/kpackage-5.108.0-x86_64-1.txz:  Upgraded.
kde/kparts-5.108.0-x86_64-1.txz:  Upgraded.
kde/kpeople-5.108.0-x86_64-1.txz:  Upgraded.
kde/kplotting-5.108.0-x86_64-1.txz:  Upgraded.
kde/kpty-5.108.0-x86_64-1.txz:  Upgraded.
kde/kquickcharts-5.108.0-x86_64-1.txz:  Upgraded.
kde/kross-5.108.0-x86_64-1.txz:  Upgraded.
kde/krunner-5.108.0-x86_64-1.txz:  Upgraded.
kde/kservice-5.108.0-x86_64-1.txz:  Upgraded.
kde/ktexteditor-5.108.0-x86_64-1.txz:  Upgraded.
kde/ktextwidgets-5.108.0-x86_64-1.txz:  Upgraded.
kde/kunitconversion-5.108.0-x86_64-1.txz:  Upgraded.
kde/kwallet-5.108.0-x86_64-1.txz:  Upgraded.
kde/kwayland-5.108.0-x86_64-1.txz:  Upgraded.
kde/kwidgetsaddons-5.108.0-x86_64-1.txz:  Upgraded.
kde/kwindowsystem-5.108.0-x86_64-1.txz:  Upgraded.
kde/kxmlgui-5.108.0-x86_64-1.txz:  Upgraded.
kde/kxmlrpcclient-5.108.0-x86_64-1.txz:  Upgraded.
kde/modemmanager-qt-5.108.0-x86_64-1.txz:  Upgraded.
kde/networkmanager-qt-5.108.0-x86_64-1.txz:  Upgraded.
kde/oxygen-icons5-5.108.0-noarch-1.txz:  Upgraded.
kde/plasma-framework-5.108.0-x86_64-1.txz:  Upgraded.
kde/prison-5.108.0-x86_64-1.txz:  Upgraded.
kde/purpose-5.108.0-x86_64-1.txz:  Upgraded.
kde/qqc2-desktop-style-5.108.0-x86_64-1.txz:  Upgraded.
kde/solid-5.108.0-x86_64-1.txz:  Upgraded.
kde/sonnet-5.108.0-x86_64-1.txz:  Upgraded.
kde/syndication-5.108.0-x86_64-1.txz:  Upgraded.
kde/syntax-highlighting-5.108.0-x86_64-1.txz:  Upgraded.
kde/threadweaver-5.108.0-x86_64-1.txz:  Upgraded.
xap/rxvt-unicode-9.26-x86_64-7.txz:  Rebuilt.
  Applied upstream patch to fix special character rendering when rxvt-unicode
  is built against perl-5.38.0. Thanks to pghvlaans.
2023-07-08 22:31:26 +02:00

353 lines
10 KiB
Bash

#!/bin/bash
#
# rc.6 This file is executed by init when it goes into runlevel
# 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 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
fi
# Set linefeed mode to avoid staircase effect.
/bin/stty onlcr
echo "Running shutdown script $0:"
# Find out how we were called.
case "$0" in
*0)
shutdown_command="halt"
;;
*6)
shutdown_command=reboot
;;
*)
echo "$0: call me as \"rc.0\" or \"rc.6\" please!"
exit 1
;;
esac
# Restart init. This prevents init from hanging on to file handles for removed
# glibc shared libraries in the case that those were upgraded or reinstalled.
/sbin/telinit u
# 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 -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
CLOCK_OPT="--directisa"
fi
if [ /etc/adjtime -nt /etc/hardwareclock ]; then
if grep -q "^LOCAL" /etc/adjtime ; then
echo "Saving system time to the hardware clock (localtime)."
else
echo "Saving system time to the hardware clock (UTC)."
fi
/sbin/hwclock $CLOCK_OPT --systohc
elif grep -q "^UTC" /etc/hardwareclock 2> /dev/null ; then
echo "Saving system time to the hardware clock (UTC)."
if [ ! -r /etc/adjtime ]; then
echo "Creating system time correction file /etc/adjtime."
fi
/sbin/hwclock $CLOCK_OPT --utc --systohc
else
echo "Saving system time to the hardware clock (localtime)."
if [ ! -r /etc/adjtime ]; then
echo "Creating system time correction file /etc/adjtime."
fi
/sbin/hwclock $CLOCK_OPT --localtime --systohc
fi
fi
# Run any local shutdown scripts:
if [ -x /etc/rc.d/rc.local_shutdown ]; then
/etc/rc.d/rc.local_shutdown stop
fi
# Stop the Apache web server:
if [ -x /etc/rc.d/rc.httpd ]; then
/etc/rc.d/rc.httpd stop
fi
# Stop the MySQL database:
if [ -x /etc/rc.d/rc.mysqld -a -r /var/run/mysql/mysql.pid ]; then
/etc/rc.d/rc.mysqld stop
fi
# Stop the Samba server:
if [ -x /etc/rc.d/rc.samba ]; then
/etc/rc.d/rc.samba stop
fi
# Shut down the NFS server:
if [ -x /etc/rc.d/rc.nfsd ]; then
/etc/rc.d/rc.nfsd stop
fi
# Shut down the SSH server:
if [ -x /etc/rc.d/rc.sshd ]; then
/etc/rc.d/rc.sshd stop
fi
# Shut down the SASL authentication daemon:
if [ -x /etc/rc.d/rc.saslauthd ]; then
/etc/rc.d/rc.saslauthd stop
fi
# Shut down OpenLDAP:
if [ -x /etc/rc.d/rc.openldap ]; then
/etc/rc.d/rc.openldap stop
fi
# Stop the haveged entropy daemon:
if [ -x /etc/rc.d/rc.haveged -a -z "$container" ]; then
/etc/rc.d/rc.haveged stop
fi
# Kill any processes (typically gam) that would otherwise prevent
# unmounting NFS volumes:
unset FUSER_DELAY
for dir in $(/bin/mount | grep -e 'type nfs ' -e 'type nfs4 ' | sed -e 's|.* on ||g' | cut -d ' ' -f 1) ; do
echo "Killing processes holding NFS mount $dir open..."
# Background this to prevent fuser from also blocking shutdown:
/usr/bin/fuser -k -M -m "$dir" &
FUSER_DELAY=5
done
# If fuser was run, let it have some delay:
if [ ! -z "$FUSER_DELAY" ]; then
sleep $FUSER_DELAY
fi
# Unmount any NFS, SMB, or CIFS filesystems:
echo "Unmounting remote filesystems:"
/bin/umount -v -a -l -f -r -t nfs,nfs4,smbfs,cifs | tr -d ' ' | grep successfully | sed "s/:successfullyunmounted/ has been successfully unmounted./g"
# Update PATH hashes:
hash -r
# Stop D-Bus:
if [ -x /etc/rc.d/rc.messagebus ]; then
/etc/rc.d/rc.messagebus stop
fi
# Try to shut down pppd:
PS="$(ps ax)"
if echo "$PS" | grep -q -w pppd ; then
if [ -x /usr/sbin/ppp-off ]; then
/usr/sbin/ppp-off
fi
fi
# Shut down YP services:
if [ -x /etc/rc.d/rc.yp ]; then
if grep -wq stop /etc/rc.d/rc.yp ; then
/etc/rc.d/rc.yp stop
fi
fi
# Bring down the networking system, but first make sure that this
# isn't a diskless client with the / partition mounted via NFS:
if ! /bin/mount | grep -q -e 'on / type nfs' -e 'on / type nfs4' ; then
if [ -x /etc/rc.d/rc.inet1 ]; then
/etc/rc.d/rc.inet1 stop
fi
fi
# In case dhcpcd might have been manually started on the command line,
# look for the .pid file, and shut dhcpcd down if it's found:
if /bin/ls /etc/dhcpc/*.pid 1> /dev/null 2> /dev/null ; then
/sbin/dhcpcd -k 1> /dev/null 2> /dev/null
# A little time for /etc/resolv.conf and/or other files to
# restore themselves.
sleep 2
fi
# If there is a firewall_shutdown script, run it. Most firewall setups
# will not need to be formally shut down, but in case yours needs that
# (perhaps to do some shutdown-time cleanup or to save the state), then
# create an /etc/rc.d/rc.firewall_shutdown script to do these things.
# If your rc.firewall script supports a "stop" parameter, you might only
# need this in your rc.firewall_shutdown script:
#
# /etc/rc.d/rc.firewall stop
#
# Or in that case you could also just make rc.firewall_shutdown a symlink
# to the rc.firewall script, since we also provide the stop parameter here.
if [ -x /etc/rc.d/rc.firewall_shutdown ]; then
/etc/rc.d/rc.firewall_shutdown stop
fi
# Shut down PCMCIA devices:
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
fi
# Turn off process accounting:
if [ -x /sbin/accton -a -r /var/log/pacct ]; then
/sbin/accton off
fi
# Terminate acpid before syslog:
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 -a -z "$container" ]; then
/etc/rc.d/rc.udev force-stop
fi
# Kill all remaining processes.
OMITPIDS="$(for p in $(pgrep mdmon); do echo -o $p; done)" # Don't kill mdmon
if [ ! "$1" = "fast" ]; then
echo "Sending all processes the SIGTERM signal."
/sbin/killall5 -15 $OMITPIDS
/bin/sleep 5
echo "Sending all processes the SIGKILL signal."
/sbin/killall5 -9 $OMITPIDS
fi
# Try to turn off quota.
if grep -q quota /etc/fstab ; 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.
# Doing this properly requires the seedrng utility.
if [ -z "$container" ]; then
# Any old seed that exists here shall be deemed useless:
if [ -f /etc/random-seed ]; then
rm -f /etc/random-seed
sync /etc
fi
if [ -x /usr/sbin/seedrng ]; then
/usr/sbin/seedrng
else # we have to fall back on the old method:
OLD_UMASK="$(umask)"
umask 077
mkdir -p /var/lib/seedrng
echo "The SeedRNG utility was not found. Generating a non-creditable and"
echo "inferior RNG seed: /var/lib/seedrng/seed.no-credit"
SEED="$(cat /var/lib/seedrng/seed.* 2>/dev/null | base64)"
rm -f /var/lib/seedrng/seed.*
sync /var/lib/seedrng
POOLSIZE=$(expr $(cat /proc/sys/kernel/random/poolsize 2> /dev/null || echo 4096) / 8)
{
head -c $POOLSIZE /dev/urandom
echo "$SEED" | base64 -d
} | sha512sum | cut -d ' ' -f 1 > /var/lib/seedrng/seed.no-credit
umask "$OLD_UMASK"
unset OLD_UMASK
unset SEED
fi
fi
# 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" -a -z "$container" ]; then
echo "Turning off swap."
/sbin/swapoff -a
/bin/sync
fi
# Umount all tmpfs mounts except /dev/shm and under /run:
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:
if [ -z "$container" ]; then
echo "Unmounting local file systems:"
/bin/umount -v -a -t no,proc,sysfs,devtmpfs,fuse.gvfsd-fuse,tmpfs
# Update PATH hashes:
hash -r
# 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
# Close any volumes opened by cryptsetup:
if [ -x /etc/rc.d/rc.luks ]; then
/etc/rc.d/rc.luks stop
fi
# Deactivate LVM volume groups:
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
# to deactivate the / logical volume... but at least it was
# remounted as read-only first)
/bin/sync
# sleep 3 fixes problems with some hard drives that don't
# otherwise finish syncing before reboot or poweroff
/bin/sleep 3
# 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
# Now halt (poweroff with APM or ACPI enabled kernels) or reboot.
if [ "$shutdown_command" = "reboot" ]; then
echo "Rebooting."
/sbin/reboot
else
/sbin/poweroff
fi