#! /bin/sh
#
# Copyright (c) 1998 Florian La Roche
#

PATH=/sbin:/bin:/usr/bin
export PATH

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 \"halt\" or \"reboot\" please!"
		exit 1
esac

# Write to wtmp file before unmounting /var
$command -w 

echo "Sending all processes the TERM signal..."
killall5 -15

if test "$1" = fast ; then
	sleep 1
else
	sleep 5
fi

echo "Sending all processes the KILL signal..."
killall5 -9

echo "Turning off swap."
sync ; sync
swapoff -a

echo "Unmounting file systems"
umount -avt proc
umount -avr
sync

mount -no remount,ro /
sync

echo $message
exec $command -d -f
