summaryrefslogtreecommitdiffstats
path: root/source/a/sysvinit-scripts/scripts/rc.6
diff options
context:
space:
mode:
Diffstat (limited to 'source/a/sysvinit-scripts/scripts/rc.6')
-rw-r--r--source/a/sysvinit-scripts/scripts/rc.655
1 files changed, 35 insertions, 20 deletions
diff --git a/source/a/sysvinit-scripts/scripts/rc.6 b/source/a/sysvinit-scripts/scripts/rc.6
index 8288128c7..76895aca8 100644
--- a/source/a/sysvinit-scripts/scripts/rc.6
+++ b/source/a/sysvinit-scripts/scripts/rc.6
@@ -26,10 +26,10 @@ echo "Running shutdown script $0:"
# Find out how we were called.
case "$0" in
*0)
- command="halt"
+ shutdown_command="halt"
;;
*6)
- command=reboot
+ shutdown_command=reboot
;;
*)
echo "$0: call me as \"rc.0\" or \"rc.6\" please!"
@@ -38,18 +38,32 @@ case "$0" in
esac
# Save the system time to the hardware clock using hwclock --systohc.
+# This will also create or update the timestamps in /etc/adjtime.
if [ -x /sbin/hwclock ]; then
# Check for a broken motherboard RTC clock (where ioports for rtc are
# unknown) to prevent hwclock causing a hang:
- if ! grep -q -w rtc /proc/ioports ; then
+ if ! grep -q " : rtc" /proc/ioports ; then
CLOCK_OPT="--directisa"
fi
- if grep -q "^UTC" /etc/hardwareclock 2> /dev/null ; then
+ if [ /etc/adjtime -nt /etc/hardwareclock ]; then
+ if grep -q "^LOCAL" /etc/adjtime ; then
+ echo "Saving system time to the hardware clock (localtime)."
+ else
+ echo "Saving system time to the hardware clock (UTC)."
+ fi
+ /sbin/hwclock $CLOCK_OPT --systohc
+ elif grep -q "^UTC" /etc/hardwareclock 2> /dev/null ; then
echo "Saving system time to the hardware clock (UTC)."
+ if [ ! -r /etc/adjtime ]; then
+ echo "Creating system time correction file /etc/adjtime."
+ fi
/sbin/hwclock $CLOCK_OPT --utc --systohc
else
echo "Saving system time to the hardware clock (localtime)."
- /sbin/hwclock $CLOCK_OPT --localtime --systohc
+ if [ ! -r /etc/adjtime ]; then
+ echo "Creating system time correction file /etc/adjtime."
+ fi
+ /sbin/hwclock $CLOCK_OPT --localtime --systohc
fi
fi
@@ -101,7 +115,7 @@ 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
+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 $dir &
@@ -113,8 +127,8 @@ if [ ! -z "$FUSER_DELAY" ]; then
fi
# Unmount any NFS, SMB, or CIFS filesystems:
-echo "Unmounting remote filesystems."
-/bin/umount -v -a -l -f -r -t nfs,smbfs,cifs
+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"
# Try to shut down pppd:
PS="$(ps ax)"
@@ -171,12 +185,13 @@ if [ -x /etc/rc.d/rc.udev ]; then
fi
# Kill all remaining processes.
+OMITPIDS="$(for p in $(pgrep mdmon); do echo -o $p; done)" # Don't kill mdmon
if [ ! "$1" = "fast" ]; then
echo "Sending all processes the SIGTERM signal."
- /sbin/killall5 -15
+ /sbin/killall5 -15 $OMITPIDS
/bin/sleep 5
echo "Sending all processes the SIGKILL signal."
- /sbin/killall5 -9
+ /sbin/killall5 -9 $OMITPIDS
fi
# Try to turn off quota.
@@ -198,22 +213,22 @@ fi
/bin/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
+$shutdown_command -w
# Turn off swap:
echo "Turning off swap."
/sbin/swapoff -a
/bin/sync
-echo "Unmounting local file systems."
-/bin/umount -v -a -t no,proc,sysfs
+# Stop cgmanager and cgproxy:
+if [ -x /etc/rc.d/rc.cgmanager ]; then
+ sh /etc/rc.d/rc.cgmanager stop
+fi
+
+echo "Unmounting local file systems:"
+/bin/umount -v -a -t no,proc,sysfs | tr -d ' ' | grep successfully | sed "s/:successfullyunmounted/ has been successfully unmounted./g" 2> /dev/null
-echo "Remounting root filesystem read-only."
+echo "Remounting root filesystem read-only:"
/bin/mount -v -n -o remount,ro /
# This never hurts:
@@ -275,7 +290,7 @@ if [ -x /sbin/genpowerd ]; then
fi
# Now halt (poweroff with APM or ACPI enabled kernels) or reboot.
-if [ "$command" = "reboot" ]; then
+if [ "$shutdown_command" = "reboot" ]; then
echo "Rebooting."
/sbin/reboot
else