100 lines
2.8 KiB
Bash
100 lines
2.8 KiB
Bash
#!/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
|
|
<RIBCL VERSION="2.0">
|
|
<LOGIN USER_LOGIN="adminname" PASSWORD="password">
|
|
<USER_INFO MODE="read">
|
|
<GET_USER USER_LOGIN="Administrator"/>
|
|
</USER_INFO>
|
|
</LOGIN>
|
|
</RIBCL>
|
|
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
|
|
<!-- HPONCFG VERSION = "1.9" -->
|
|
<!-- Generated 1/31/2013 16:8:49 -->
|
|
<RIBCL VERSION="2.1">
|
|
<LOGIN USER_LOGIN="Administrator" PASSWORD="xxxxx">
|
|
<USER_INFO MODE="write">
|
|
<MOD_USER USER_LOGIN="Administrator">
|
|
<USER_NAME value="Administrator"/>
|
|
<PASSWORD value="admin11=="/>
|
|
<ADMIN_PRIV value="Yes"/>
|
|
<REMOTE_CONS_PRIV value="Yes"/>
|
|
<RESET_SERVER_PRIV value="Yes"/>
|
|
<VIRTUAL_MEDIA_PRIV value="Yes"/>
|
|
<CONFIG_ILO_PRIV value="Yes"/>
|
|
<!-- Firmware support infomation for next 6 tags: -->
|
|
<!-- iLO 2 - None. -->
|
|
<!-- iLO - Version earlier than 1.40. -->
|
|
<!-- RILOE II - None. -->
|
|
<!-- <VIEW_LOGS_PRIV value="Yes"/> -->
|
|
<!-- <CLEAR_LOGS_PRIV value="Yes"/> -->
|
|
<!-- <EMS_PRIV value="Yes"/> -->
|
|
<!-- <UPDATE_ILO_PRIV value="No"/> -->
|
|
<!-- <CONFIG_RACK_PRIV value="Yes"/> -->
|
|
<!-- <DIAG_PRIV value="Yes"/> -->
|
|
</MOD_USER>
|
|
</USER_INFO>
|
|
</LOGIN>
|
|
</RIBCL>
|
|
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
|