#! /bin/sh
# Copyright (c) 1996 S.u.S.E. GmbH Fuerth, Germany.  All rights reserved.
#
# Author: Florian La Roche <florian@suse.de>, 1996
#	  Werner Fink <werner@suse.de>, 1996
# Hacked by Koblinger Egmont <egmont@fazekas.hu>
#
# /sbin/init.d/halt (and symlinked to reboot)
#

. /etc/rc.config

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

#
# first do local stuff
#
test -e /sbin/init.d/halt.local && {
    sh /sbin/init.d/halt.local
}

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

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

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

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

/sbin/init.d/filesystem stop

echo $message
exec $command -d -f
