#!/bin/bash
#
# kuwatcher helper function: exec poweroff after a delay
#
# __copy1__
# __copy2__
#
CMD=${CMD:-"$0"}
DEBUG=${DEBUG:-"false"}

TIMEOUT=15

logger -s -t $CMD "system will be halted in $TIMEOUT seconds ..."
logger -s -t $CMD "create a file named '/nohalt' to stop me"

while [ $TIMEOUT != 0 ]
do
	[ -f /nohalt ] && {
		rm -f /nohalt
		exit 0
	}
	sleep 1
	TIMEOUT=`expr $TIMEOUT - 1`
done

exec /sbin/poweroff
