#!/bin/bash
CPWD=`cd $(dirname $0);pwd`
cd $CPWD
lsscsi -g |grep "ST8000NM0055" > ST8000NM0055_hdd_map
for DEV in `cat ST8000NM0055_hdd_map |awk '{print $6}'`;do
	Model=$(smartctl -a ${DEV} |grep "Device Model" |awk '{print $NF}')
	FW_Ver=$(smartctl -a ${DEV} |grep "Firmware Version" |awk '{print $NF}')
	if [[ "${Model}" = "ST8000NM0055-1RM112" ]];then
		if [[ "${FW_Ver}" =~ "PN0" ]] && [[ "${FW_Ver}" != "PN04" ]];then
			echo "This is Inspur customized model ST8000NM0055 which need update FW to PN04"
			./SeaChest_static_64 -d ${DEV} --downloadFW MakaraPlus512N_Ali_PN04.LOD
		elif [[ "${FW_Ver}" =~ "SN0" ]] && [[ "${FW_Ver}"  != "SN05" ]];then
			./SeaChest_static_64 -d ${DEV} --downloadFW ST8000NM0055.lod
		fi
	fi
done
