#!/bin/bash
#
# $Id$
#

if [ $# -lt 1 ];then
    echo " "
    echo "Usage: ipxe host1 [host2 host3 ...]"
    echo " "
    exit 1
fi

#echo
#echo "cmd: ipmitool -I lanplus -H $1 -U root chassis power reset"
#echo

if [ ! $IPMI_PASSWORD ]; then
    stty -echo
    read -p "Password: " passw; echo
    stty echo
fi

# Do the deed for all requested hosts (4/28/08)

while (( "$#" )) ; do 

    if [ $IPMI_PASSWORD ]; then
	/usr/bin/ipmitool -E -I lanplus -H $1 -U root chassis power reset
    else
	/usr/bin/ipmitool -I lanplus -H $1 -U root -P $passw chassis power reset
    fi

    shift
done

exit 0
