#!/bin/bash
#
# ======================================================================
# VI editor settings
# set shiftwidth=4
# set tabstop=4
# ======================================================================
# Title: Forces node to reset - right now
# Author: Mike Gore
# Date: 7 July 2015
# Depends: package: openipmi, BASH scripts:  common_host,common_vars,common_functions and /usr/local/bin/NODES
#
# Example: ./pxereset host-ilom
#           - Where host-ilom is the node ILOM/BMC interface
#           - needs and AMDIN user and password to function
# Result: Reset node NOW
#
# Notes:
#        The script will prompt for ADMIN user and password unless the following environment variables are set:
# ADMIN - userid of ADMIN user
# ADMINPASS - Password of "ADMIN" user
# ======================================================================

. common_vars

setadmin

LOM="$1"
if [ -z "$LOM" ]
then
	echo "Expected node ILOM name"
	exit 1
fi
if ping -c 1 -w 1 "$LOM" 2>/dev/null >/dev/null
then
	echo "Node $LOM is up"
	host $LOM
	ipmitool -H $LOM -U $ADMIN -P $ADMINPASS power reset
else
	echo "Node $LOM is down"
fi