]> git.pld-linux.org Git - projects/rc-scripts.git/blob - rc.d/init.d/shutdwn
356dfb6c04a77421db743f762a25121052a87318
[projects/rc-scripts.git] / rc.d / init.d / shutdwn
1 #!/bin/sh
2 #
3 # shutdwn       Common script for system halt/reboot.
4 #
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>
8 #
9 # $Id: shutdwn,v 1.9 1999/09/04 19:49:41 waszi Exp $
10
11 # Set the path.
12 PATH=/sbin:/bin:/usr/bin:/usr/sbin
13
14 # NLS
15 NLS_DOMAIN="rc-scripts"
16
17 . /etc/rc.d/init.d/functions
18
19 # Kill all processes.
20 [ "${BASH+bash}" = bash ] && enable kill
21
22 show "Sending all processes the TERM signal"
23 daemon killall5 -15
24 sleep 5
25 show "Sending all processes the KILL signal"
26 daemon killall5 -9
27
28 # Write to wtmp file before unmounting /var
29 halt -w
30
31 # Turn off swap, then unmount file systems.
32 run_cmd "Turning off swap and accounting" swapoff -a
33 [ -x /sbin/accton ] && /sbin/accton
34
35 _ERRORS=""
36 show "Unmounting file systems"; busy
37 if _ERRORS="`LANG_OLD=$LANG;LANG=C;initlog -c \"umount -a\" 2>&1;LANG=$LANG_OLD`"; then
38     deltext; ok
39 else
40     deltext; fail; echo $_ERRORS
41 fi
42 unset _ERRORS
43
44 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
45
46 # turn off raid
47 if [ -x /sbin/raidstop -a -f /etc/raidtab ]; then
48         # we can not use raidstop -a here because this will only stop
49         # devices listed in the default config file which is not always
50         # the case. So we look only for the active raid devices
51         if [ -f /proc/mdstat ] ; then
52                 mddevs=$(grep ^md /proc/mdstat | awk '{ print $1 }')
53                 for mddev in $mddevs ; do
54                         run_cmd "Turning off RAID for $mddev" raidstop /dev/$mddev
55                 done
56                 unset mddev mddevs
57         fi
58         #runcmd "Turning off RAID" /sbin/raidstop -a
59 fi
60
61 show "Remounting remaining filesystems ro mode"; busy
62 if ( mount | awk '/ext2/ { print $3 }' | \
63         while read line; do 
64         mount -n -o ro,remount $line; done ); then
65         deltext; ok
66 else
67         deltext; fail
68 fi
This page took 0.0209 seconds and 2 git commands to generate.