#! /bin/bash
ipmi_raw_disable_monitor(){
    ipmitool raw 0x3c 0x3a 0x02 0xFE
}
ipmi_raw_monitor_status(){
    ipmitool raw 0x3c 0x3b 0x02
}

_install() {
    if [[ $RaidType = "LSI_HBA" && $Manufacture == 'INSPUR' ]];then
        CardInfo=$(lspci -d 1000:: )
        for chip in 2008 3008 2308
        do
            if [[ $CardInfo =~ $chip ]];then
                RaidChip=$chip
                break
            fi
        done
        if [[ -n $RaidChip ]] ;then
            if ipmi_raw_disable_monitor ;then
                PRINT_ERR "[ERROR] RAID $RaidChip CARD BMC monitor disable failed."
                return 1
            fi
            sleep 3
            monitor_status=$(ipmi_raw_monitor_status)
            if [[ -n $monitor_status ]] ;then
                return 1
            fi
        fi
    fi
}

_check() {
    _check="PASS"
    if [[ $RaidType == "LSI_HBA" ]]; then
        monitor_status=$(ipmi_raw_monitor_status)
        if [[ -n $monitor_status ]] ;then
            _check="FAIL"
            PRINT_ERR "[ERROR] RAID CARD BMC monitor not disable."
        fi
    fi
}
