#!/bin/bash
for i in `seq 1 $(cat ipmi.list |wc -l)` 
do 
   IPMI_IP=`cat ipmi.list |sed -n "$i"p |awk '{print $1}'`
   SN=$(dmidecode -s system-serial-number |grep -v ^#  | sed s/[[:space:]]//g)
   IPMI_pw=$(curl -s -H "Content-Type:application/json" -X POST --data  '{"data":  ["'${SN}'"],"type": "SN"}' http://udcm.ucloudadmin.com/api/ipmi/v1/getpwd/ | jq -r '.[]|.IPMIPassword')
   [[ -n $IPMI_pw  ]] || exit 1
   #IPMI_pw=`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' | sed 's/,$//g'`

   echo "$IPMI_IP"
   ./sum -i ${IPMI_IP} -u root -p ${IPMI_pw} -c updatebmc --file X11DPG_QT_Beta_9.99.bin
 done

