slackware-current/source/a/sysvinit-scripts/scripts/rc.K
Patrick J Volkerding 646a5c1cbf Mon May 28 19:12:29 UTC 2018
a/pkgtools-15.0-noarch-13.txz:  Rebuilt.
  installpkg: default line length for --terselength is the number of columns.
  removepkg: added --terse mode.
  upgradepkg: default line length for --terselength is the number of columns.
  upgradepkg: accept -option in addition to --option.
ap/vim-8.1.0026-x86_64-1.txz:  Upgraded.
d/bison-3.0.5-x86_64-1.txz:  Upgraded.
e/emacs-26.1-x86_64-1.txz:  Upgraded.
kde/kopete-4.14.3-x86_64-8.txz:  Rebuilt.
  Recompiled against libidn-1.35.
n/conntrack-tools-1.4.5-x86_64-1.txz:  Upgraded.
n/libnetfilter_conntrack-1.0.7-x86_64-1.txz:  Upgraded.
n/libnftnl-1.1.0-x86_64-1.txz:  Upgraded.
n/links-2.16-x86_64-2.txz:  Rebuilt.
  Rebuilt to enable X driver for -g mode.
n/lynx-2.8.9dev.19-x86_64-1.txz:  Upgraded.
n/nftables-0.8.5-x86_64-1.txz:  Upgraded.
n/p11-kit-0.23.11-x86_64-1.txz:  Upgraded.
n/ulogd-2.0.7-x86_64-1.txz:  Upgraded.
n/whois-5.3.1-x86_64-1.txz:  Upgraded.
xap/network-manager-applet-1.8.12-x86_64-1.txz:  Upgraded.
xap/vim-gvim-8.1.0026-x86_64-1.txz:  Upgraded.
2018-05-31 23:39:35 +02:00

121 lines
3.1 KiB
Bash

#! /bin/sh
#
# 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 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 'type nfs ' | cut -d ' ' -f 3 ) ; 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,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..."
telinit -t 1 1