#!/bin/bash



IPMI=`ipmitool lan print |grep -i "IP Address" |grep -v Source|awk -F ':' '{print $2}'|sed 's/^[ ]*//g'`
SN=$(dmidecode -s system-serial-number |grep -v ^#  | sed s/[[:space:]]//g)
IPMI_PASSWD=$(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_PASSWD ]] || exit 1
echo "y"|ipmitool -H ${IPMI} -U root -P ${IPMI_PASSWD} -I lanplus hpm upgrade image.hpm  -z 8192 force

#echo "y"|ipmitool -H ${IPMI} -U root -P ${IPMI_PASSWD} -I lanplus hpm upgrade MP32_AR0_scp_signed_1.08.20211002_SHA256.hpm  -z 8192 force
