3 # shutdwn Common script for system halt/reboot.
5 # Author: Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
6 # Changes: Grzegorz Stanislawski <stangrze@open.net.pl>
7 # Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
9 # $Id: rc.shutdown,v 1.21 2003/01/25 00:37:38 misiek Exp $
12 PATH=/sbin:/bin:/usr/bin:/usr/sbin
17 . /etc/rc.d/init.d/functions
20 [ "${BASH+bash}" = bash ] && enable kill
24 run_cmd "Sending all processes the TERM signal" killall5 -15
26 run_cmd "Sending all processes the KILL signal" killall5 -9
28 # Write to wtmp file before unmounting /var
31 # Turn off swap, then unmount file systems.
32 run_cmd "Turning off swap and accounting" swapoff -a
33 [ -x /sbin/accton ] && LC_ALL=C /sbin/accton 2>&1 | grep -v "not implemented"
35 if [ -x /sbin/quotaoff ]; then
36 run_cmd "Turning off quotas for local filesystems" /sbin/quotaoff -a
39 # Unmount file systems, killing processes if we have to.
43 remaining=$(awk '!/(^#| proc | loopfs | devfs | devpts | shm | iso9660 | ramfs | tmpfs |^none|^\/dev\/root| \/ )/ {print $2}' /proc/mounts)
44 while [ -n "$remaining" -a "$retry" -gt 0 ]
46 show "Unmounting file systems" ; busy
47 if ERRORS=$(umount -a $FORCE -t noproc,devfs 2>&1) ; then
51 [ -n "$ERRORS" ] && echo "$ERRORS"
55 remaining=$(awk '!/(^#| proc | loopfs | devfs | devpts | shm |^none|^\/dev\/root| \/ )/ {print $2}' /proc/mounts)
56 [ -z "$remaining" ] && break
57 /sbin/fuser -k -m $sig $remaining > /dev/null
64 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
67 if [ -x /sbin/raidstop -a -f /etc/raidtab ]; then
68 # we can not use raidstop -a here because this will only stop
69 # devices listed in the default config file which is not always
70 # the case. So we look only for the active raid devices
71 if [ -f /proc/mdstat ] ; then
72 mddevs=$(awk '/^md.* active/ {print $1}' /proc/mdstat)
73 for mddev in $mddevs ; do
74 run_cmd "Turning off RAID for $mddev" raidstop /dev/$mddev
78 #runcmd "Turning off RAID" /sbin/raidstop -a
81 show "Remounting remaining filesystems ro mode"; busy
82 if ( mount | awk '/ext2|ext3|reiserfs|xfs|jfs/ { print $3 }' | \
84 mount -n -o ro,remount $line; done ); then
90 if [ "$runlevel" = "0" ] ; then
91 show "The system is halted"; ok
92 [ -f /fastboot ] && (show "On the next boot fsck will be skipped."; ok)
94 if [ -x /sbin/poweroff-ups -a -f /etc/killpower -a -f /etc/sysconfig/ups ] ; then
96 is_yes "$POWEROFF_UPS" && /sbin/poweroff-ups
100 show "Please stand by while rebooting the system"; ok
101 [ -f /fastboot ] && (show "On the next boot fsck will be skipped."; ok)
105 # This must be last line !
106 # vi:syntax=sh:tw=78:ts=8:sw=4