3 # shutdwn Common script for system halt/reboot.
5 # Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
6 # Modified for PLD Linux by Grzegorz Stanislawski
7 # Changes: Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
9 # $Id: rc.shutdown,v 1.9 2000/06/18 09:52:05 kloczek Exp $
12 PATH=/sbin:/bin:/usr/bin:/usr/sbin
15 NLS_DOMAIN="rc-scripts"
20 . /etc/rc.d/init.d/functions
23 [ "${BASH+bash}" = bash ] && enable kill
25 run_cmd "Sending all processes the TERM signal" killall5 -15
27 run_cmd "Sending all processes the KILL signal" killall5 -9
29 # Write to wtmp file before unmounting /var
32 # Turn off swap, then unmount file systems.
33 run_cmd "Turning off swap and accounting" swapoff -a
34 [ -x /sbin/accton ] && /sbin/accton
36 if [ -x /sbin/quotaoff ]; then
37 run_cmd "Turning off quotas for local filesystems" /sbin/quotaoff -a
40 # Unmount file systems, killing processes if we have to.
43 remaining=`awk '!/(^#|proc|loopfs|devfs|devpts|^none|^\/dev\/root| \/ )/ {print $2}' /proc/mounts`
44 while [ -n "$remaining" -a "$retry" -gt 0 ]
46 show "Unmounting file systems"; busy
47 if [ "$retry" -lt 3 ]; then
48 run_cmd "Unmounting file systems" umount -a -f -t noproc
50 run_cmd "Unmounting file systems" umount -a -f -t noproc
53 remaining=`awk '!/(^#|proc|loopfs|devfs|devpts|^none|^\/dev\/root| \/ )/ {print $2}' /proc/mounts`
54 [ -z "$remaining" ] && break
55 /sbin/fuser -k -m $sig $remaining >/dev/null
61 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
64 if [ -x /sbin/raidstop -a -f /etc/raidtab ]; then
65 # we can not use raidstop -a here because this will only stop
66 # devices listed in the default config file which is not always
67 # the case. So we look only for the active raid devices
68 if [ -f /proc/mdstat ] ; then
69 mddevs=$(awk '/^md.* active/ {print $1}' /proc/mdstat)
70 for mddev in $mddevs ; do
71 MESSAGE="`nls "Turning off RAID for %s" "$mddev"`"
72 run_cmd "$MESSAGE" raidstop /dev/$mddev
76 #runcmd "Turning off RAID" /sbin/raidstop -a
79 show "Remounting remaining filesystems ro mode"; busy
80 if ( mount | awk '/ext2/ { print $3 }' | \
82 mount -n -o ro,remount $line; done ); then