#!/bin/bash
CPWD=`cd $(dirname $0);pwd`
cd $CPWD
for DEV in `nvme list |egrep "\bSSDPF2KX076TZ" |awk '{print $1}' |awk -F"/" '{print $3}' |sed 's/n1$//g'`;do
        FW_Ver=`smartctl -a /dev/$DEV |awk '/Firmware Version/{print $NF}' |sed 's/\s*//g'`

        if [[ "$FW_Ver" != "JCV10500" ]];then
                nvme fw-download /dev/$DEV -f JCV10500_WFEM01S0_signed.bin
                nvme fw-activate /dev/$DEV -s 1 -a 1
                nvme reset /dev/$DEV
                sleep 5
        else
                echo "$DEV FW is already JCV10500"
        fi
done
