2016-12-05 13:12:19 -06:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-08-22 10:08:07 -05:00
|
|
|
fw_required="{{ MLNX_FW_VERSION }}"
|
2016-12-05 13:12:19 -06:00
|
|
|
query_retry_count_max="10"
|
|
|
|
fw_file=/etc/mlnx/fw-SPC.mfa
|
|
|
|
|
|
|
|
run_or_fail() {
|
|
|
|
$1
|
|
|
|
if [[ $? != 0 ]]; then
|
|
|
|
echo $1 failed
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# wait until devices will be available
|
|
|
|
query_retry_count="0"
|
2017-08-22 10:08:07 -05:00
|
|
|
query_cmd="mlxfwmanager --query"
|
2017-08-04 07:05:15 -05:00
|
|
|
${query_cmd} > /dev/null
|
2016-12-05 13:12:19 -06:00
|
|
|
|
|
|
|
while [[ (${query_retry_count} -lt ${query_retry_count_max}) && ($? -ne "0") ]]; do
|
|
|
|
sleep 1
|
|
|
|
query_retry_count=$[${query_retry_count}+1]
|
2017-08-04 07:05:15 -05:00
|
|
|
${query_cmd} > /dev/null
|
2016-12-05 13:12:19 -06:00
|
|
|
done
|
|
|
|
|
2017-08-04 07:05:15 -05:00
|
|
|
run_or_fail "${query_cmd}" > /tmp/mlnxfwmanager-query.txt
|
2016-12-05 13:12:19 -06:00
|
|
|
|
2017-08-04 07:05:15 -05:00
|
|
|
# get current firmware version and required version
|
|
|
|
fw_info=$(grep FW /tmp/mlnxfwmanager-query.txt)
|
|
|
|
fw_current=$(echo $fw_info | cut -f2 -d' ')
|
2016-12-05 13:12:19 -06:00
|
|
|
|
2017-08-04 07:05:15 -05:00
|
|
|
if [[ -z ${fw_current} ]]; then
|
2016-12-05 13:12:19 -06:00
|
|
|
echo "Could not retreive current FW version."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-08-04 07:05:15 -05:00
|
|
|
if [[ -z ${fw_required} ]]; then
|
|
|
|
echo "Could not retreive required FW version."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ${fw_current} == ${fw_required} ]]; then
|
2016-12-05 13:12:19 -06:00
|
|
|
echo "Mellanox firmware is up to date."
|
|
|
|
else
|
2017-08-04 07:05:15 -05:00
|
|
|
echo "Mellanox firmware required version is ${fw_required}. Installing compatible version..."
|
2016-12-05 13:12:19 -06:00
|
|
|
run_or_fail "mlxfwmanager -i ${fw_file} -u -f -y"
|
|
|
|
fi
|