@echo off
REM #     cfgbmc.cmd  - script to configure IPMI BMC
REM #
set bmcip=10.243.42.137
set bmcuser=user2
set bmcpswd=password2
set baud=115.2k
set setasset= -a asset4wd
set setsernum= -s sernum4wd
set logfile=%DeploymentStore%\cfgbmc.log
set ADDLOG=call addLogRecord
REM set ADDLOG=echo
set RET=0

REM # init the logfile
echo cfgbmc start >%logfile%

echo "" >>%logfile%
set parms=serial -c -B %baud% -q 2 -u %bmcuser% 
ipmiutil %parms% -p %bmcpswd% >>%logfile% 2>&1
if errorlevel 1 goto sererror 
 %ADDLOG% IPMI_serial INFO "Success: ipmiutil %parms%"
 goto serdone
:sererror
 set RET=%ERRORLEVEL%
 %ADDLOG% IPMI_serial ERROR "Error %ERRORLEVEL%: ipmiutil %parms%"
:serdone
echo "ipmiutil %parms% done "

set parms=lan -e -I %bmcip% -q 2 -u %bmcuser% 
ipmiutil %parms% -p %bmcpswd% >>%logfile% 2>&1
if errorlevel 1  goto lanerror 
 %ADDLOG% IPMI_lan INFO "Success: ipmiutil %parms%"
 goto landone
:lanerror
 set RET=%ERRORLEVEL%
 %ADDLOG% IPMI_lan ERROR "Error %ERRORLEVEL%: ipmiutil %parms%"
:landone
echo "ipmiutil %parms% done  "

set parms=fru %setasset% %setsernum%
ipmiutil %parms% >>%logfile% 2>&1
if errorlevel 1  goto fruerror 
 %ADDLOG% IPMI_fru INFO "Success: ipmiutil %parms%"
 goto frudone
:fruerror
 set RET=%ERRORLEVEL%
 %ADDLOG% IPMI_fru ERROR "Error %ERRORLEVEL%: ipmiutil %parms%"
:frudone
echo "ipmiutil %parms% done  "
exit /B %RET%
