Radix cross Linux

The main Radix cross Linux repository contains the build scripts of packages, which have the most complete and common functionality for desktop machines

452 Commits   2 Branches   1 Tag
     5         kx #! /bin/sh
     5         kx #
     5         kx # rc.K          This file is executed by init when it goes into runlevel 1,
     5         kx #               which is the administrative state. It kills all daemons and
     5         kx #               then puts the system into single user mode. Note that the
     5         kx #               file systems are kept mounted.
     5         kx #
     5         kx # Author:       Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
     5         kx # Modified by:  Patrick J. Volkerding,  <volkerdi@slackware.com>,
   406         kx #               Andrey V. Kosteltsev,   <kx@radix-linux.su>
     5         kx #
     5         kx 
     5         kx # Set the path.
     5         kx PATH=/sbin:/usr/local/sbin:/bin:/usr/local/bin:/usr/sbin:/usr/bin
     5         kx 
     5         kx # Load a custom screen font if the user has an rc.font script.
     5         kx if [ -x /etc/rc.d/rc.font ]; then
     5         kx   /etc/rc.d/rc.font
     5         kx fi
     5         kx 
     5         kx # Load any needed keyboard mappings:
     5         kx if [ -x /etc/rc.d/rc.keymap ]; then
     5         kx   /etc/rc.d/rc.keymap
     5         kx fi
     5         kx 
     5         kx # If there are SystemV init scripts for this runlevel, run them.
     5         kx if [ -x /etc/rc.d/rc.sysvinit ]; then
     5         kx   /etc/rc.d/rc.sysvinit
     5         kx fi
     5         kx 
     5         kx # Try to turn off quota:
     5         kx if grep -q quota /etc/fstab ; then
     5         kx   if [ -x /sbin/quotaoff ]; then
     5         kx     echo "Turning off filesystem quotas."
     5         kx     /sbin/quotaoff -a
     5         kx   fi
     5         kx fi
     5         kx 
     5         kx # Try to turn off accounting:
     5         kx if [ -x /sbin/accton -a -r /var/log/pacct ]; then
     5         kx   /sbin/accton off
     5         kx fi
     5         kx 
     5         kx # Run any local shutdown scripts:
     5         kx if [ -x /etc/rc.d/rc.local_shutdown ]; then
     5         kx   /etc/rc.d/rc.local_shutdown stop
     5         kx fi
     5         kx 
     5         kx # Stop the Apache web server:
     5         kx if [ -x /etc/rc.d/rc.httpd ]; then
     5         kx   /etc/rc.d/rc.httpd stop
     5         kx fi
     5         kx 
     5         kx # Stop Nginx server:
     5         kx if [ -x /etc/rc.d/rc.nginx ]; then
     5         kx   /etc/rc.d/rc.nginx stop
     5         kx fi
     5         kx 
     5         kx # Stop Message broker RabbitMQ
     5         kx if [ -x /etc/rc.d/rc.rabbitmq ]; then
     5         kx   /etc/rc.d/rc.rabbitmq stop
     5         kx fi
     5         kx 
     5         kx # Stop key-value store Redis
     5         kx if [ -x /etc/rc.d/rc.redis ]; then
     5         kx   /etc/rc.d/rc.redis stop
     5         kx fi
     5         kx 
     5         kx # Stop uWSGI for cGit server:
     5         kx if [ -x /etc/rc.d/rc.cgit-uwsgi ]; then
     5         kx   /etc/rc.d/rc.cgit-uwsgi stop
     5         kx fi
     5         kx 
     5         kx # Stop FastCGI PHP server:
     5         kx if [ -x /etc/rc.d/rc.php-fpm ]; then
     5         kx   /etc/rc.d/rc.php-fpm stop
     5         kx fi
     5         kx 
     5         kx # Stop postgres
     5         kx if [ -x /etc/rc.d/rc.postgresql ]; then
     5         kx   /etc/rc.d/rc.postgresql stop
     5         kx fi
     5         kx 
     5         kx # Stop the MySQL database:
     5         kx if [ -r /var/run/mysql/mysql.pid ]; then
     5         kx   /etc/rc.d/rc.mysqld stop
     5         kx fi
     5         kx 
     5         kx # Stop the Samba server:
     5         kx if [ -x /etc/rc.d/rc.samba ]; then
     5         kx   /etc/rc.d/rc.samba stop
     5         kx fi
     5         kx 
     5         kx # Shut down the NFS server:
     5         kx if [ -x /etc/rc.d/rc.nfsd ]; then
     5         kx   /etc/rc.d/rc.nfsd stop
     5         kx fi
     5         kx 
     5         kx # Shut down the SSH server:
     5         kx if [ -x /etc/rc.d/rc.sshd ]; then
     5         kx   /etc/rc.d/rc.sshd stop
     5         kx fi
     5         kx 
     5         kx # Stop the Tomcat daemon:
     5         kx if [ -x /etc/rc.d/rc.tomcat ]; then
     5         kx   . /etc/rc.d/rc.tomcat stop
     5         kx fi
     5         kx 
     5         kx # Shut down the Memcached daemon:
     5         kx if [ -x /etc/rc.d/rc.memcached ]; then
     5         kx   /etc/rc.d/rc.memcached stop
     5         kx fi
     5         kx 
     5         kx # Shut down the Postfix daemon:
     5         kx if [ -x /etc/rc.d/rc.postfix ]; then
     5         kx   /etc/rc.d/rc.postfix stop
     5         kx fi
     5         kx 
     5         kx # Shut down the IMAP daemon:
     5         kx if [ -x /etc/rc.d/rc.cyrus-imapd ]; then
     5         kx   /etc/rc.d/rc.cyrus-imapd stop
     5         kx fi
     5         kx 
     5         kx # Shut down the SASL authentication daemon:
     5         kx if [ -x /etc/rc.d/rc.saslauthd ]; then
     5         kx   /etc/rc.d/rc.saslauthd stop
     5         kx fi
     5         kx 
     5         kx # Shut down OpenLDAP:
     5         kx if [ -x /etc/rc.d/rc.openldap ]; then
     5         kx   /etc/rc.d/rc.openldap stop
     5         kx fi
     5         kx 
     5         kx # Stop D-Bus:
     5         kx if [ -x /etc/rc.d/rc.messagebus ]; then
     5         kx   sh /etc/rc.d/rc.messagebus stop
     5         kx fi
     5         kx 
     5         kx # Kill any processes (typically gam) that would otherwise prevent
     5         kx # unmounting NFS volumes:
     5         kx unset FUSER_DELAY
     5         kx for dir in $(/bin/mount | grep -e 'type nfs ' -e 'type nfs4 ' | sed -e 's|.* on ||g' | cut -d ' ' -f 1) ; do
     5         kx   echo "Killing processes holding NFS mount $dir open..."
     5         kx   # Background this to prevent fuser from also blocking shutdown:
     5         kx   /usr/bin/fuser -k -M -m "$dir" &
     5         kx   FUSER_DELAY=5
     5         kx done
     5         kx # If fuser was run, let it have some delay:
     5         kx if [ ! -z "$FUSER_DELAY" ]; then
     5         kx   sleep $FUSER_DELAY
     5         kx fi
     5         kx 
     5         kx # Unmount any NFS, SMB, or CIFS filesystems:
     5         kx echo "Unmounting remote filesystems:"
     5         kx /bin/umount -v -a -l -f -r -t nfs,nfs4,smbfs,cifs | tr -d ' ' | grep successfully | sed "s/:successfullyunmounted/ has been successfully unmounted./g"
     5         kx 
     5         kx # Shut down PCMCIA devices:
     5         kx if [ -x /etc/rc.d/rc.pcmcia ] ; then
     5         kx   /etc/rc.d/rc.pcmcia stop
     5         kx   # The cards might need a little extra time here to deactivate:
     5         kx   sleep 5
     5         kx fi
     5         kx 
     5         kx # Terminate acpid before syslog:
     5         kx if [ -x /etc/rc.d/rc.acpid -a -r /var/run/acpid.pid ]; then # quit
     5         kx   /etc/rc.d/rc.acpid stop
     5         kx fi
     5         kx 
     5         kx # Terminate ntpd before syslog:
     5         kx if [ -x /etc/rc.d/rc.ntpd -a -r /var/run/ntpd.pid ]; then # quit
     5         kx   sh /etc/rc.d/rc.ntpd stop
     5         kx fi
     5         kx 
     5         kx # Kill all processes.
     5         kx OMITPIDS="$(for p in $(pgrep mdmon); do echo -o $p; done)" # Don't kill mdmon
     5         kx echo
     5         kx echo "Sending all processes the SIGHUP signal."
     5         kx killall5 -1 $OMITPIDS
     5         kx echo -n "Waiting for processes to hang up"
     5         kx for loop in 0 1 2 3 4 5 ; do
     5         kx   sleep 1
     5         kx   echo -n "."
     5         kx done
     5         kx echo
     5         kx echo "Sending all processes the SIGTERM signal."
     5         kx killall5 -15 $OMITPIDS
     5         kx echo -n "Waiting for processes to terminate"
     5         kx for loop in 0 1 2 3 4 5 ; do
     5         kx   sleep 1
     5         kx   echo -n "."
     5         kx done
     5         kx echo
     5         kx echo "Sending all processes the SIGKILL signal."
     5         kx killall5 -9 $OMITPIDS
     5         kx echo -n "Waiting for processes to exit"
     5         kx for loop in 0 1 2 3 4 5 ; do
     5         kx   sleep 1
     5         kx   echo -n "."
     5         kx done
     5         kx echo
     5         kx 
     5         kx # Now go to the single user level
     5         kx echo "Going to single user mode..."
     5         kx /sbin/telinit -t 1 1