#!/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'`

SA5280M6(){
if [[ "${os_version}" = "7" ]] && [[ "${BIOS_Ver}" = "08.05.00" ]];then
    ./SCELNX_64_5.05.01.0002_2021 /i /s SA5280M6_20240412.cfg 
else
    exit 1
fi
}

NF5688-M7-A0-R0-00(){
if [[ "${os_version}" = "7" ]] && [[ "${BIOS_Ver}" = "06.02.00" ]];then
    ./SCELNX_64_5.05.01.0002_2021 /i /s NF5688-M7-H20_20240730.cfg 
else
    exit 1
fi
}

NF5468-A7-A0-R0-00(){
if [[ "${os_version}" = "7" ]] && [[ "${BIOS_Ver}" = "01.20.00" ]];then
    if [[ -d "/sys/firmware/efi" ]];then
    	./SCELNX_64_5.05.01.0002_2021 /i /s NF5468-A7-A0-R0-00_EFI_20241121.cfg
    else
	./SCELNX_64_5.05.01.0002_2021 /i /s NF5468-A7-A0-R0-00_BIOS_20240627.cfg
    fi
else
    exit 1	
fi
}

NF5468-M7-A0-R0-00(){
if [[ "${os_version}" = "7" ]] && [[ "${BIOS_Ver}" = "06.04.00" ]];then
    if [[ -d "/sys/firmware/efi" ]];then
        ./SCELNX_64_5.05.01.0002_2021 /i /s NF5468-M7-A0-R0-00_efi_20240930.cfg 
    else
        exit 1
    fi
else
    exit 1
fi
}



if [[ "${Pro_name}" == "SA5280M6" ]];then
	SA5280M6
elif [[ "${Pro_name}" == "NF5688-M7-A0-R0-00" ]];then
	NF5688-M7-A0-R0-00
elif [[ "${Pro_name}" == "NF5468-A7-A0-R0-00" ]];then
        NF5468-A7-A0-R0-00
elif [[ "${Pro_name}" == "NF5468-M7-A0-R0-00" ]];then
        NF5468-M7-A0-R0-00
else 
	echo "this machine don't have BIOScfg file"
	exit 1
fi
