3 # hdw - linux /etc/init.d/down (copied from ROCK Linux)
5 # shutdown and reboot script.
10 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
13 *halt) command=halt ;;
14 *reboot) command=reboot ;;
15 *) echo "never call this script directly !" ; exit 1 ;;
18 touch /var/log/init.msg /var/log/boot.msg
19 mv /var/log/init.msg /var/log/init.old
20 mv /var/log/boot.msg /var/log/boot.old
22 echo "** shutting down hdw-linux **"
25 [ -f /fastdown ] && FASTDOWN=1
26 [ $FASTDOWN = 1 ] && echo "fast shutdown mode enabled."
28 echo "writing a wtmp record ..."
31 echo "saving kernel random seed ..."
32 dd if=/dev/urandom of=/var/state/random-seed count=1 2> /dev/null
36 echo "sending all processes a SIGTERM (15) ..."
37 killall5 -15 ; sleep 3
38 echo "sending all processes a SIGKILL (9) ..."
41 echo "sending all processes a SIGTERM (15) ..."
42 killall5 -15 ; sleep 5
43 echo "sending all processes a 2nd SIGTERM (15) ..."
44 killall5 -15 ; sleep 3
45 echo "sending all processes a SIGKILL (9) ..."
47 echo "sending all processes a 2nd SIGKILL (9) ..."
51 echo "turning off swap ..."
52 swapoff -a ; sync ; sleep 1
56 echo "unmounting file systems ..."
57 umount -vnra -t noproc,devfs,shm
58 mount -vn -o remount,ro /
59 sleep 1 ; sync ; sleep 1
61 echo "remounting sync/ro and umount filesystems ..."
62 grep -v '^none ' /etc/mtab /proc/mounts | grep -v ' / ' | \
63 cut -f1,2 -d' ' | sort -u -k2 -t' ' | sort -r -k2 -t' ' | \
64 while read dev fs ; do
65 echo -n "$dev on $fs: sync" ; mount -o remount,sync $fs
66 echo -n " ro" ; mount -o remount,ro $fs
67 echo " umount" ; umount $fs
70 echo "shutting down udev ..."
76 echo "unmounting remaining file systems ..."
78 grep -E -v '^none (/|[a-z]+:) ' /proc/mounts > /etc/mtab
79 umount -vnra -t noproc,devfs,shm
80 mount -vn -o remount,sync /
81 mount -vn -o remount,ro /
82 sleep 1 ; sync ; sleep 1
85 echo "going to $command the system ..."
86 exec $command -d -f -i -p