#!/bin/bash

SCRIPT_DIR="$(cd "$(dirname "$0")"; pwd)"
OS_VERSION=$(uname -r | awk -F"el" '{print $2}' | awk -F"." '{print $1}')
BIOS_VERSION=$(dmidecode -t 0 | awk '/Version/{print $NF}' | tr -d '[:space:]')
PRODUCT_NAME=$(ipmitool fru print 0 | awk -F":" '/Product Name/{print $NF}' | xargs)


update_bios_config() {
    local config_file=$1
    if [[ "${OS_VERSION}" == "7" ]]  && [[ "${BIOS_VERSION}" == "EG0.10.00" ]]; then
        ./SCELNX_64 /i /s "$config_file"
    else
        echo "BIOS update not applicable for this system configuration."
        exit 1
    fi
}

if [[ "${PRODUCT_NAME}" == "H8230" ]]; then
    update_bios_config "HUAQIN_H8230_250626_EFI.cfg"
else
    echo "This ${PRODUCT_NAME} does not have a BIOS configuration file."
    exit 1
fi


