#!/bin/sh ################################################### # ILO configuration template # # Details: # This script attempts to determine the ILO's IP address from the hostname. # If the IP address cannot be found, then DHCP is used. # # Version History: # 2005Mar16 : Traivs Sidelinger : re-wrote the input parsing # added the --reset option # 2005Feb16 : Travis Sidelinger : Initial release # #set -x #set -v ###################################### ## Subrutines ## showhelp() { echo "Usage:" echo " `basename ${0}` [-h|--help]" echo " `basename ${0}` [options] " echo " `basename ${0}` [options] " echo "Options:" echo " -r --reset Resets the ILO to manufacture defaults" exit } ###################################### ## Main ## # Input case ${1} in -h) shift; showhelp;; --help) shift; showhelp;; -r) shift; RESET=YES;; --reset) shift; RESET=YES;; esac ## Variables ## ILO_CONF=/tmp/ilo.xml DHCP=No # Get input values if [ "${1}" ]; then ILOHOST="${1}"; fi if [ "${2}" ]; then IPADDR=${2}; fi # Determine missing input values if [ "${ILOHOST}" ]; then if [ ! "`echo ${ILOHOST} | grep '\-ilo'`" ]; then ILOHOST=`echo ${ILOHOST} | sed 's/\./-ilo./'`; fi if [ ! "`echo ${ILOHOST} | grep '\-ilo'`" ]; then ILOHOST="${ILOHOST}-ilo"; fi fi if [ ! "${ILOHOST}" ]; then ILOHOST="`hostname`-ilo" ; fi if [ ! "${IPADDR}" ]; then IPADDR=`getent hosts ${ILOHOST} | awk '{print $1}'`; fi if [ ! "${IPADDR}" ]; then ILOHOST=`hostname -f | sed 's/\./-ilo./'` IPADDR=`getent hosts ${ILOHOST} | awk '{print $1}'`; fi if [ ! "${IPADDR}" ]; then DHCP=Yes; fi echo ${ILOHOST} = ${IPADDR} DHCP=${DHCP} # Reset the ILO to manufacture defaults if [ "${RESET}" = 'YES' ]; then /usr/lib/hponcfg -reset fi # Create ILO config cat > ${ILO_CONF} <<__EOI__ __EOI__ # Apply the ILO configuration /usr/lib/hponcfg -f ${ILO_CONF} -m 1.600000 rm -f ${ILO_CONF} if [ "$RESET}" = 'YES' ]; then echo "SSH will not be available for 10-20 minutes while private keys are generated."; fi ###################################### ## End ## exit 0