blob: 7377385ea61394ca82fea31086c18b38c170f339 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
#!/bin/sh
#
# rc.halt 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.
#
# Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
# Modified for RHS Linux by Damien Neil
#
# Set the path.
PATH=/sbin:/bin:/usr/bin:/usr/sbin
. /etc/rc.d/init.d/functions
runcmd() {
echo -n "$1 "
shift
if [ "$BOOTUP" = "color" ]; then
$* && echo_success || echo_failure
else
$*
fi
echo
}
# See how we were called.
case "$0" in
*halt)
message="The system is halted"
command="halt"
;;
*reboot)
message="Please stand by while rebooting the system..."
command="reboot"
;;
*)
echo "$0: call me as \"rc.halt\" or \"rc.reboot\" please!"
exit 1
;;
esac
# Kill all processes.
[ "${BASH+bash}" = bash ] && enable kill
runcmd "Sending all processes the TERM signal..." /sbin/killall5 -15
sleep 5
runcmd "Sending all processes the KILL signal.." /sbin/killall5 -9
# Write to wtmp file before unmounting /var
halt -w
# Save mixer settings, here for lack of a better place.
grep -q "\(sparcaudio\|sound\)" /proc/devices
if [ $? = 0 ]; then
runcmd "Saving mixer settings" /bin/aumix-minimal -f /etc/.aumixrc -S
fi
# Turn off swap, then unmount file systems.
runcmd "Turning off swap and accounting" swapoff -a
# Turn off other swap that isn't in /etc/fstab
OTHERSWAP=`cut -f1 -d " " /proc/swaps | tail +2`
[ -n "$OTHERSWAP" ] && swapoff $OTHERSWAP
[ -x /sbin/accton ] && /sbin/accton
runcmd "Unmounting file systems" umount -a -f
mount -n -o remount,ro /
# turn off raid
if [ -x /sbin/raidstop -a -f /etc/raidtab ]; then
# we can not use raidstop -a here because this will only stop
# devices listed in the default config file which is not always
# the case. So we look only for the active raid devices
if [ -f /proc/mdstat ] ; then
mddevs=$(grep ^md /proc/mdstat | awk '{ print $1 }')
for mddev in $mddevs ; do
runcmd "Turning off RAID for $mddev" raidstop /dev/$mddev
done
unset mddev mddevs
fi
#runcmd "Turning off RAID" /sbin/raidstop -a
fi
# Remount read only anything that's left mounted.
#echo "Remounting remaining filesystems (if any) readonly"
mount | awk '/ext2/ { print $3 }' | while read line; do
mount -n -o ro,remount $line
done
# Now halt or reboot.
echo "$message"
if [ -f /fastboot ]; then
echo "On the next boot fsck will be skipped."
elif [ -f /forcefsck ]; then
echo "On the next boot fsck will be forced."
fi
eval $command -i -d -p
|