#!/bin/bash
#Standalone script for setting Administrator Privileges
#set -x
#Checks to see if the server is a HP
function server-check()
{
SERVER_TYPE="$(dmidecode -t system|grep Manufacturer |grep HP -c)"
if [ $SERVER_TYPE -eq 0 ]; then
echo This is not a HP server, exiting.
exit
fi
if [ $SERVER_TYPE -eq 1 ]; then
echo Server is a HP, checking admin privileges
#yum install -y hponcfg
ilo-check
fi
}
#Checks the status of iLO on the server
function ilo-check()
{
#Generates the XML file for checking iLO
cat > /tmp/ilo.check << ENDCHECK
ENDCHECK
#iLO Status variable
ILOSTATUS="$(hponcfg -f /tmp/ilo.check | grep ADMIN_PRIV |grep -i y -c)"
if [ $ILOSTATUS -eq 0 ]; then
echo Administrator does not have admin privileges. Enabling...
configure-ilo
fi
if [ $ILOSTATUS -eq 1 ]; then
echo Administrator has admin privileges, exiting
fi
}
function configure-ilo()
{
#Build xml config file for ILO
cat > /tmp/ilo.dat <
ENDILO
#Apply config to the iLO card
hponcfg -f /tmp/ilo.dat
echo "Admin Privileges enabled on $(hostname)"
}
##########################################################################################
## Control logic for the script ##
##########################################################################################
main()
{
echo "iLO Admin Privilege checker initiated on $(hostname) at $(date)"
server-check
}
main