slackware-current/source/a/sysvinit-scripts/scripts/rc.K

127 lines
3.2 KiB
Text
Raw Normal View History

#!/bin/bash
#
# rc.K This file is executed by init when it goes into runlevel
# 1, which is the administrative state. It kills all
# daemons and then puts the system into single user mode.
# Note that the file systems are kept mounted.
#
# Version: @(#)/etc/rc.d/rc.K 3.1415 Sat Jan 13 13:37:26 PST 2001
#
# 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
# Load a custom screen font if the user has an rc.font script.
if [ -x /etc/rc.d/rc.font ]; then
/etc/rc.d/rc.font
fi
# Load any needed keyboard mappings:
if [ -x /etc/rc.d/rc.keymap ]; then
/etc/rc.d/rc.keymap
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
# Try to turn off quota:
if grep -q quota /etc/fstab ; then
if [ -x /sbin/quotaoff ]; then
echo "Turning off filesystem quotas."
/sbin/quotaoff -a
fi
fi
# Try to turn off accounting:
if [ -x /sbin/accton -a -r /var/log/pacct ]; then
/sbin/accton off
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 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
# 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:
Wed Jul 25 03:50:17 UTC 2018 a/kernel-generic-4.14.57-x86_64-1.txz: Upgraded. a/kernel-huge-4.14.57-x86_64-1.txz: Upgraded. a/kernel-modules-4.14.57-x86_64-1.txz: Upgraded. a/shadow-4.2.1-x86_64-5.txz: Rebuilt. adduser: added "input" to additional user groups. Thanks to stormtracknole. a/sysvinit-scripts-2.1-noarch-14.txz: Rebuilt. Handle remote (NFS, etc.) mounts with spaces in the name. Thanks to upnort. d/kernel-headers-4.14.57-x86-1.txz: Upgraded. d/parallel-20180722-noarch-1.txz: Upgraded. d/rust-1.27.2-x86_64-1.txz: Upgraded. d/subversion-1.10.2-x86_64-1.txz: Upgraded. k/kernel-source-4.14.57-noarch-1.txz: Upgraded. l/libgphoto2-2.5.19-x86_64-1.txz: Upgraded. l/libzip-1.5.1-x86_64-4.txz: Rebuilt. Make sure that the API-CHANGES file is included in the package documentation. x/xf86-video-r128-6.11.0-x86_64-1.txz: Upgraded. x/xorg-server-1.20.0-x86_64-3.txz: Rebuilt. Applied some patches that other distributions have been using for a while: Fix glamor so that the return value from glamor_fds_from_pixmap matches what's expected (thanks to Darth Vader for pointing out these patches). Autobind secondary GPUs to the master as output sink / offload source. This seems like a beneficial patch until/unless DEs start to handle this. For nvidia cards, if they are GeForce 8 or newer use the modesetting driver by default. Seems to be recommmended by upstream where they indicate that fixes going into nouveau are primarily to target older cards for legacy support and that the modesetting ddx is preferable for newer ones: https://bugs.freedesktop.org/show_bug.cgi?id=94844 x/xorg-server-xephyr-1.20.0-x86_64-3.txz: Rebuilt. x/xorg-server-xnest-1.20.0-x86_64-3.txz: Rebuilt. x/xorg-server-xvfb-1.20.0-x86_64-3.txz: Rebuilt. isolinux/initrd.img: Rebuilt. Use ter-v14v.psf.gz as the consolefont. It supports more character sets, and the larger font was causing wraparound on UEFI (at least on bare metal here). kernels/*: Upgraded. usb-and-pxe-installers/usbboot.img: Rebuilt.
2018-07-25 05:50:17 +02:00
/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"
# Shut down PCMCIA devices:
if [ -x /etc/rc.d/rc.pcmcia ] ; then
/etc/rc.d/rc.pcmcia stop
# The cards might need a little extra time here to deactivate:
sleep 5
fi
# Terminate acpid before syslog:
if [ -x /etc/rc.d/rc.acpid -a -r /var/run/acpid.pid ]; then # quit
/etc/rc.d/rc.acpid stop
fi
# Kill all processes.
OMITPIDS="$(for p in $(pgrep mdmon); do echo -o $p; done)" # Don't kill mdmon
echo
echo "Sending all processes the SIGHUP signal."
killall5 -1 $OMITPIDS
echo -n "Waiting for processes to hang up"
for loop in 0 1 2 3 4 5 ; do
sleep 1
echo -n "."
done
echo
echo "Sending all processes the SIGTERM signal."
killall5 -15 $OMITPIDS
echo -n "Waiting for processes to terminate"
for loop in 0 1 2 3 4 5 ; do
sleep 1
echo -n "."
done
echo
echo "Sending all processes the SIGKILL signal."
killall5 -9 $OMITPIDS
echo -n "Waiting for processes to exit"
for loop in 0 1 2 3 4 5 ; do
sleep 1
echo -n "."
done
echo
# Now go to the single user level
echo "Going to single user mode..."
/sbin/telinit -t 1 1