#!/bin/sh
# apcupsd halt script
# by Martin Mitchell <martin@debian.org>
# modifications by Gordon Morehouse <spambox@evernex.com> April 2001

# Modified to be "non-blocking" by Bjrn Wiberg <bjorn.wiberg@home.se> 2004-10-21
# Place this script as /etc/init.d/ups-monitor in order for /etc/init.d/halt to find it!

case "$1" in
	poweroff | killpower)
		if [ -f /etc/apcupsd/powerfail ]; then
			echo ""
			echo -n "apcupsd: Ordering UPS to kill power... "
			/etc/apcupsd/apccontrol killpower
			echo "done."
			echo ""
			echo "Please ensure the UPS has powered off before rebooting."
			echo "Otherwise, the UPS may cut the power during the reboot!"
			echo ""
		fi
	;;

	*)
	;;
esac

exit 0
