#!/bin/sh

echo "Sending all processes a SIGTERM (15)."
killall5 -15 || error=$? ; sleep 5

echo "Sending all processes a 2nd SIGTERM (15)."
killall5 -15 || error=$? ; sleep 5

echo "Sending all processes a SIGKILL (9)."
killall5 -9 || error=$? ; sleep 5

echo "Turning off swap devices."
swapoff -a || error=$?
sync ; sleep 1

echo "Unmounting filesystems."
umount -avf || error=$?

if [[ "$*" = *-h* ]]; then
	echo "Powering off."
	halt -pf
else
	echo "Rebooting the system."
	reboot -f
fi
