ReachableCEO-ShellScriptPor.../config-iLO

142 lines
3.3 KiB
Bash

#!/bin/bash
#Script for configuring iLO - modified version, works with hponcfg-4.2.0-0.i386.rpm
#set -x
function configure-ilo()
{
echo "Now running $FUNCNAME...."
#Install hponcfg
#yum install -y hponcfg
#Reset to factory defaults (just in case)
hponcfg -r
#Dynamic values for the generated XML
ILONAME="$(hostname -s)-iLO"
ILOIP="$(dig -x @DNS_SERVER_IP $ILONAME.$TLD +short)"
#VLAN verification and configuration
case $ILOIP in
172.16.10*.*)
GATEWAY=172.16.103.254
NETMASK=255.255.252.0
ENABLEV=Y
VLAN=101
;;
172.16.11*.*)
GATEWAY=172.16.115.254
NETMASK=255.255.252.0
ENABLEV=Y
VLAN=112
;;
172.17.1.*)
GATEWAY=0.0.0.0
NETMASK=255.255.252.0
ENABLEV=N
VLAN=243
;;
172.17.2.*)
GATEWAY=0.0.0.0
NETMASK=255.255.252.0
ENABLEV=N
VLAN=243
;;
esac
#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">
<DIR_INFO MODE="write">
<MOD_DIR_CONFIG>
<DIR_AUTHENTICATION_ENABLED VALUE = "No"/>
<DIR_LOCAL_USER_ACCT VALUE = "Y"/>
<DIR_SERVER_ADDRESS VALUE = ""/>
<DIR_SERVER_PORT VALUE = "636"/>
<DIR_OBJECT_DN VALUE = ""/>
<DIR_OBJECT_PASSWORD VALUE = ""/>
<DIR_USER_CONTEXT_1 VALUE = ""/>
<DIR_USER_CONTEXT_2 VALUE = ""/>
<DIR_USER_CONTEXT_3 VALUE = ""/>
</MOD_DIR_CONFIG>
</DIR_INFO>
<RIB_INFO MODE="write">
<MOD_NETWORK_SETTINGS>
<DHCP_ENABLE VALUE = "No"/>
<SPEED_AUTOSELECT VALUE = "Yes"/>
<NIC_SPEED VALUE = "10"/>
<FULL_DUPLEX VALUE = "Y"/>
<IP_ADDRESS VALUE = "$ILOIP"/>
<SUBNET_MASK VALUE = "$NETMASK"/>
<GATEWAY_IP_ADDRESS VALUE = "$GATEWAY"/>
<DNS_NAME VALUE = "$ILONAME"/>
<PRIM_DNS_SERVER value = "10.207.12.78"/>
<DOMAIN_NAME VALUE = "tplab.tippingpoint.com"/>
<DHCP_GATEWAY VALUE = "No"/>
<DHCP_DNS_SERVER VALUE = "No"/>
<DHCP_STATIC_ROUTE VALUE = "No"/>
<DHCP_WINS_SERVER VALUE = "No"/>
<REG_WINS_SERVER VALUE = "No"/>
<PRIM_WINS_SERVER VALUE = ""/>
<SHARED_NETWORK_PORT VALUE="Y"/>
<VLAN_ENABLED VALUE = "$ENABLEV"/>
<VLAN_ID VALUE = "$VLAN"/>
</MOD_NETWORK_SETTINGS>
<!-- iLO Advanced Activation -->
<LICENSE>
<ACTIVATE KEY="3GMPZW29YQP242466Q99355BM" />
</LICENSE>
</RIB_INFO>
<USER_INFO MODE="write">
<ADD_USER
USER_NAME="Guest"
USER_LOGIN="Guest"
PASSWORD="Wund3rB4r!!">
<ADMIN_PRIV value="Y"/>
<REMOTE_CONS_PRIV value="Y"/>
<RESET_SERVER_PRIV value="Y"/>
<VIRTUAL_MEDIA_PRIV value="Y"/>
<CONFIG_ILO_PRIV value="Y"/>
</ADD_USER>
</USER_INFO>
<USER_INFO MODE="write">
<MOD_USER USER_LOGIN="Administrator">
<USER_NAME value="Administrator"/>
<PASSWORD value="admin11=="/>
<ADMIN_PRIV value="N"/>
<REMOTE_CONS_PRIV value="Y"/>
<RESET_SERVER_PRIV value="Y"/>
<VIRTUAL_MEDIA_PRIV value="N"/>
<CONFIG_ILO_PRIV value="N"/>
</MOD_USER>
</USER_INFO>
</LOGIN>
</RIBCL>
ENDILO
#Apply config to the ILO card
hponcfg -f /tmp/ilo.dat
echo "iLO configured on $ILONAME, IP: $ILOIP"
}
#configure-ilo
##########################################################################################
## Control logic for the script ##
##########################################################################################
main()
{
echo "Configuring iLo on $ILONAME at $(date)"
configure-ilo
}
main