#!/bin/bash
CPWD=`cd $(dirname  $0);pwd`
os_version=`uname -r |awk -F"el" '{print $2}' |awk -F"." '{print $1}'`
BIOS_Ver=`dmidecode -t 0 |awk '/Version/{print $NF}' |sed 's/\s*//g'`
Pro_name=`ipmitool fru print 0 |awk -F":" '/Product Name/{print $NF}' |sed 's/^\s*//g'`

R610_R620_G30(){
if [[ "${os_version}" = "7" ]] && [[ "${BIOS_Ver}" = "UJGS011236-U03" ]];then
    ./SCELNX_64_5.05.01.0002_2021 /i /s UJGS011236-U03.cfg
fi
}

R620_G50(){
if [[ "${os_version}" = "7" ]] && [[ "${BIOS_Ver}" = "UNH1011023-U01" ]];then
    ./SCELNX_64_5.05.01.0002_2021 /i /s UNH1011023-U02_20230911.cfg
fi
}

R640_G30(){
if [[ "${os_version}" = "7" ]] && [[ "${BIOS_Ver}" = "UJGS011232-U04" ]];then
    ./SCELNX_64_5.05.01.0002_2021 /i /s UJGS011232-U04_20240311.cfg 
fi
}
X640_G40(){
if [[ "${os_version}" = "7" ]] && [[ "${BIOS_Ver}" = "UKMH011035-U01" ]];then
    ./SCELNX_64_5.05.01.0002_2021 /i /s X640_G40_20240318.cfg 
fi
}

R610_G30(){
if [[ "${os_version}" = "7" ]] && [[ "${BIOS_Ver}" = "UJGS011228" ]];then
    ./SCELNX_64_5.05.01.0002_2021 /i /s R610_G30_20240321.cfg
fi
}
if [[ "${Pro_name}" == "R620 G30" ]];then
	R610_R620_G30
elif [[ "${Pro_name}" == "R620 G50" ]];then
	R620_G50 
elif [[ "${Pro_name}" == "R640 G30" ]];then
	R640_G30
elif [[ "${Pro_name}" == "X640 G40" ]];then
  	X640_G40      
elif [[ "${Pro_name}" == "R610 G30" ]];then
        R610_G30
else 
	echo "this machine don't have BIOScfg file"
	exit 1
fi
