#! /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 # Modified by: Patrick J. Volkerding # # Set the path. PATH=/sbin:/bin:/usr/bin:/usr/sbin . /etc/shell-colors # 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 -e "${BOLDWHITE}Turning off filesystem quotas${COLOR_RESET}" /sbin/quotaoff -a fi fi # Try to turn off accounting: if [ -x /sbin/accton -a -r /var/log/pacct ]; then echo -e "${BOLDWHITE}Turning off accounting${COLOR_RESET}" /sbin/accton fi ############## STOPING DAEMONS AND NETWORK SERVICES ################## # We won't stop these services from here blacklist(){ for mask in \~ .new rc.S rc.M rc.K rc.4 rc.0 rc.6 .conf alsa messagebus rc.services rc.inet1 rc.inet2 rc.postinstall \ rc.modules rc.local rc.acpid rc.netfilter rc.numlock rc.font rc.keymap rc.wireless rc.licences ; do echo $1 | grep $mask done } # Here we go echo -e "${BOLDCYAN}Shutting down services${COLOR_RESET}" for rcscript in /etc/rc.d/rc.* ; do [ "$(blacklist $rcscript)" ] && continue if [ -x $rcscript ]; then service="$(basename $rcscript | sed -e 's/^rc\.\(.*\)$/\1/')" echo -e "${BOLDWHITE}Shutting down $service${COLOR_RESET}" $rcscript stop fi done # Unmount any NFS, SMB, or CIFS filesystems: echo -e "${BOLDWHITE}Unmounting remote filesystems${COLOR_RESET}" umount -a -r -t nfs,smbfs,cifs # Kill all processes. echo echo -e "${BOLDCYAN}Sending all processes the SIGHUP signal${COLOR_RESET}" killall5 -1 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 -e "${BOLDCYAN}Sending all processes the SIGTERM signal${COLOR_RESET}" killall5 -15 echo -n "Waiting for processes to terminate" for loop in 0 1 2 3 4 5 ; do sleep 1 echo -n "." done echo echo -e "${BOLDCYAN}Sending all processes the SIGKILL signal${COLOR_RESET}" killall5 -9 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 -e "${BOLDMAGENTA}Going to single user mode...${COLOR_RESET}" telinit -t 1 1