#!/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}'`
if_file=`ls *BMC*.ima`
chmod +x socflash_x64
./socflash_x64 if=${if_file}
sleep 120
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 60
ipmitool lan set 1 ipsrc dhcp
sleep 3
ipmitool user set name 2 root
sleep 30
ipmitool user set password 2 ucloud.cn
