#!/bin/sh
#     cfgbmc.sh  - script to configure IPMI BMC
#
bmcip=10.243.42.137
bmcuser=user2
bmcpswd=password2
baud=115.2k
setasset="-a asset4wd"
setsernum="-s sernum4wd"
logfile=$DeploymentStore/cfgbmc.log
ADDLOG=addLogRecord
# ADDLOG=echo

if [ $# -ge 1 ]
then
   bmcip=$1
   if [ $# -ge 2 ]
   then
      bmcuser=$2
      if [ $# -ge 3 ]
      then
         bmcpswd=$3
      fi
   fi
fi

# init the logfile
date >$logfile

echo "" >>$logfile
parms="serial -c -B $baud -q 2 -u $bmcuser "
ipmiutil $parms -p $bmcpswd >>$logfile 2>&1
ret=$?
if [ $ret -eq 0 ]
then
 $ADDLOG IPMI_serial INFO "Success: ipmiutil $parms"
else
 $ADDLOG IPMI_serial ERROR "Error $ret: ipmiutil $parms"
fi
echo "ipmiutil $parms returned $ret "

parms="lan -e -I $bmcip -u $bmcuser "
ipmiutil $parms -p $bmcpswd >>$logfile 2>&1
ret=$?
if [ $ret -eq 0 ]
then
 $ADDLOG IPMI_lan INFO "Success: ipmiutil $parms"
else
 $ADDLOG IPMI_lan ERROR "Error $ret: ipmiutil $parms"
fi
echo "ipmiutil $parms returned $ret  "

parms="fru $setasset $setsernum"
ipmiutil $parms >>$logfile 2>&1
ret=$?
if [ $ret -eq 0 ]
then
 $ADDLOG IPMI_fru INFO "Success: ipmiutil $parms"
else
 $ADDLOG IPMI_fru ERROR "Error $ret: ipmiutil $parms"
fi
echo "ipmiutil $parms returned $ret "
exit $ret 
