#!/bin/bash
#
# ======================================================================
# VI editor settings
# set shiftwidth=4
# set tabstop=4
# ======================================================================
# Title: List ILOM/BMC users and permissions on a node
# Author: Mike Gore
# Date: 7 July 2015
# Depends: package: openipmi, BASH scripts:  common_host,common_vars,common_functions and /usr/local/bin/NODES
#
# Example: ./pxeuserlist host-ilom
#           - Where host-ilom is the node ILOM/BMC interface
#           - needs and AMDIN user and password to function
# Result: List ILOM/BMC users permissions on  a node
#
# 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
. NODES

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 -I lanplus  -H $LOM -U "$ADMIN" -P "$ADMINPASS" user list 1
else
	echo "Node $LOM is down"
fi