#!/bin/bash

password=`curl -H "Content-Type:application/json" -X POST --data  "{\"data\":  [\"${ipmi_ip}\"],\"type\": \"IPMI\"}" http://udcm.ucloudadmin.com/api/ipmi/v1/getpwd/ | jq "." | grep 'IPMIPassword' | awk '{print $NF}' | sed  's/^//g' | sed 's/^,$//g'`
if_file=`ls *_BMC`
chmod +x socflash_x64
bash socflash.sh if=${if_file}
sleep 120
ipmitool raw 0x06 0x45 0x01 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
sleep 3
ipmitool lan set 1 ipsrc dhcp
sleep 3
ipmitool user set name 2 root
sleep 30
ipmitool user set password 2 ${password}
