#!/bin/bash
CPWD=`cd $(dirname  $0);pwd`
#os_version=`uname -r |awk -F"el" '{print $2}' |awk -F"." '{print $1}'`
kernel_pre_version=`uname -r |awk -F"." '{print $1}'`
kernel_sub_version=`uname -r |awk -F"." '{print $2}'`
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'`

cd $CPWD
if [[ "${Pro_name}" == "RS720A-E9-RS12V2" ]] && [[ "${BIOS_Ver}" == "3003" ]];then
	if [[ ${kernel_pre_version} == 4 ]];then
		./SCELNX_64 /i /s RS720A-E9-RS12V2_20220426.cfg
	else [[ ${kernel_pre_version} == 5 ]]
		if [[ ${kernel_sub_version} == 10 ]];then
			./SCELNX_64_5.05.01.0002_2021 /i /s RS720A-E9-RS12V2_20220426.cfg
		fi
	fi
elif [[ "${Pro_name}" == "RS500A-E10-RS4" ]] && [[ "${BIOS_Ver}" == "0601" ]];then
	if [[ ${kernel_pre_version} == 4 ]];then
                ./SCELNX_64 /i /s RS500A-E10-RS4_20220426.cfg
        else [[ ${kernel_pre_version} == 5 ]]
                if [[ ${kernel_sub_version} == 10 ]];then
                        ./SCELNX_64_5.05.01.0002_2021 /i /s RS500A-E10-RS4_20220426.cfg
                fi
        fi
elif [[ "${Pro_name}" == "RS720A-E11-RS12" ]] && [[ "${BIOS_Ver}" == "0701" ]];then
        if [[ ${kernel_pre_version} == 4 ]];then
                ./SCELNX_64 /i /s RS720A-E11-RS12_20220426.cfg
        else [[ ${kernel_pre_version} == 5 ]]
                if [[ ${kernel_sub_version} == 10 ]];then
                        ./SCELNX_64_5.05.01.0002_2021 /i /s RS720A-E11-RS12_20220426.cfg
                fi
        fi
fi
