#!/bin/bash
#
# ======================================================================
# VI editor settings
# set shiftwidth=4
# set tabstop=4
# ======================================================================
# Title: List users and permissions on ALL nodes
# 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_nodes
#           - Where host-ilom is the node ILOM/BMC interface
#           - needs and AMDIN user and password to function
# Result: List ILOM/BMC users permissions on ALL nodes
#
# 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

for i in $ILOM_NODES
do 
	LOM="$i"
	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
done