#!/bin/bash
_mac1=`ipmitool lan print 1|grep "^MAC Address" |awk '{print $NF}'  |awk -F":" '{print $1}'`
_mac2=`ipmitool lan print 1|grep "^MAC Address" |awk '{print $NF}'  |awk -F":" '{print $2}'`
_mac3=`ipmitool lan print 1|grep "^MAC Address" |awk '{print $NF}'  |awk -F":" '{print $3}'`
_mac4=`ipmitool lan print 1|grep "^MAC Address" |awk '{print $NF}'  |awk -F":" '{print $4}'`
_mac5=`ipmitool lan print 1|grep "^MAC Address" |awk '{print $NF}'  |awk -F":" '{print $5}'`
_mac6=`ipmitool lan print 1|grep "^MAC Address" |awk '{print $NF}'  |awk -F":" '{print $6}'`
bmc_file=`ls F10_KMH_C01_BMC_0U01_V227_U01.ima`
chmod +x socflash_x64
PN=`dmidecode -s system-product-name`
BMC_Ver_main=`ipmitool mc info |grep "Firmware Revision" |awk '{print $NF}'`
BMC_Ver=${BMC_Ver_main}
if [[ $PN} =~ "X640 G40" ]] && [[ x"${BMC_Ver}" != x"2.27" ]];then
	echo y |./socflash_x64 if=${bmc_file}
	sleep 120
fi
ipmitool raw 0x0c 0x01 0x01 0xc2 0x00
ipmitool raw 0x0c 0x01 0x01 0x05 0x${_mac1} 0x${_mac2} 0x${_mac3} 0x${_mac4} 0x${_mac5} 0x${_mac6}
sleep 30
ipmitool lan set 1 ipsrc dhcp
sleep 3
ipmitool user set name 2 root
sleep 30
ipmitool user set password 2 ucloud.cn
