#! /bin/sh
#
# halt		Execute the halt command.
#
# Version:      @(#)halt  2.85-9  21-Dec-2003  miquels@cistron.nl
#

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

# The default is to poweroff.
if [ "$INIT_HALT" = "" ]
then
	INIT_HALT="POWEROFF"
fi

# See if we need to cut the power.
if [ "$INIT_HALT" = "POWEROFF" -a -x /etc/init.d/ups-monitor ]
then
	/etc/init.d/ups-monitor poweroff
fi

# Don't shut down drives if we're using RAID.
hddown="-h"
if grep -qs '^md.*active' /proc/mdstat
then
	hddown=""
fi

# If INIT_HALT=HALT don't poweroff.
poweroff="-p"
if [ "$INIT_HALT" = "HALT" ]
then
	poweroff=""
fi

halt -d -f -i $poweroff $hddown

: exit 0
