aboutsummaryrefslogtreecommitdiff
path: root/templates/vserver-legacy/files/etc/rc.d/rc.0
diff options
context:
space:
mode:
Diffstat (limited to 'templates/vserver-legacy/files/etc/rc.d/rc.0')
-rwxr-xr-xtemplates/vserver-legacy/files/etc/rc.d/rc.0110
1 files changed, 110 insertions, 0 deletions
diff --git a/templates/vserver-legacy/files/etc/rc.d/rc.0 b/templates/vserver-legacy/files/etc/rc.d/rc.0
new file mode 100755
index 0000000..bfec90a
--- /dev/null
+++ b/templates/vserver-legacy/files/etc/rc.d/rc.0
@@ -0,0 +1,110 @@
+#! /bin/sh
+#
+# 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 2.47 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=/sbin:/etc:/bin:/usr/bin
+
+# 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.
+stty onlcr
+
+echo "Running shutdown script $0:"
+
+# Find out how we were called.
+case "$0" in
+ *0)
+ command="halt"
+ ;;
+ *6)
+ command=reboot
+ ;;
+ *)
+ echo "$0: call me as \"rc.0\" or \"rc.6\" please!"
+ exit 1
+ ;;
+esac
+
+# 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 [ -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
+
+# Try to kill dhcpcd so the DHCP leases can be returned:
+killall -15 dhcpcd 1> /dev/null 2> /dev/null
+
+# 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
+
+# Turn off process accounting:
+if [ -x /sbin/accton -a -r /var/log/pacct ]; then
+ echo "Turning off process accounting."
+ /sbin/accton
+fi
+
+# Kill all processes.
+# INIT is supposed to handle this entirely now, but this didn't always
+# work correctly without this second pass at killing off the processes.
+# Since INIT already notified the user that processes were being killed,
+# we'll avoid echoing this info this time around.
+if [ "$1" != "fast" ]; then # shutdown did not already kill all processes
+ killall5 -15
+ sleep 5
+ killall5 -9
+fi
+
+# Carry a random seed between reboots.
+echo "Saving random seed from /dev/urandom in /etc/random-seed."
+# Use the pool size from /proc, or 512 bytes:
+if [ -r /proc/sys/kernel/random/poolsize ]; then
+ dd if=/dev/urandom of=/etc/random-seed count=1 bs=$(cat /proc/sys/kernel/random/poolsize) 2> /dev/null
+else
+ dd if=/dev/urandom of=/etc/random-seed count=1 bs=512 2> /dev/null
+fi
+chmod 600 /etc/random-seed
+
+# Before unmounting file systems write a reboot or halt record to wtmp.
+$command -w
+
+# Clear /var/lock/subsys.
+if [ -d /var/lock/subsys ]; then
+ rm -f /var/lock/subsys/*
+fi
+
+# This never hurts:
+sync
+
+# sleep 1 fixes problems with some hard drives that don't
+# otherwise finish syncing before reboot or poweroff
+sleep 1
+
+# This is to ensure all processes have completed on SMP machines:
+wait
+