90f6881e08
Install a new FW by specifying FW path (mlnx-fw-upgrade.sh /path/to/FW) or use default at '/etc/mlnx/fw-SPC.mfa' Signed-off-by: Stepan Blyschak <stepanb@mellanox.com>
69 lines
1.8 KiB
Django/Jinja
Executable File
69 lines
1.8 KiB
Django/Jinja
Executable File
#!/bin/bash
|
|
|
|
fw_required="{{ MLNX_FW_VERSION }}"
|
|
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"
|
|
query_cmd="mlxfwmanager --query"
|
|
${query_cmd} > /dev/null
|
|
|
|
while [[ (${query_retry_count} -lt ${query_retry_count_max}) && ($? -ne "0") ]]; do
|
|
sleep 1
|
|
query_retry_count=$[${query_retry_count}+1]
|
|
${query_cmd} > /dev/null
|
|
done
|
|
|
|
function upgrade() {
|
|
if [ ! -z "$1" ]; then
|
|
fw_file="$1"
|
|
if [ ! -f "$fw_file" ]; then
|
|
>&2 echo "No such file: $fw_file"
|
|
exit 1
|
|
fi
|
|
|
|
run_or_fail "${query_cmd} -i ${fw_file}" > /tmp/mlnxfwmanager-query.txt
|
|
|
|
# get current firmware version and available version from $fw_file
|
|
fw_info=$(grep FW /tmp/mlnxfwmanager-query.txt)
|
|
fw_current=$(echo $fw_info | cut -f2 -d' ')
|
|
fw_available=$(echo $fw_info | cut -f3 -d' ')
|
|
|
|
fw_required=$fw_available
|
|
else
|
|
run_or_fail "${query_cmd}" > /tmp/mlnxfwmanager-query.txt
|
|
|
|
# get current firmware version and required version
|
|
fw_info=$(grep FW /tmp/mlnxfwmanager-query.txt)
|
|
fw_current=$(echo $fw_info | cut -f2 -d' ')
|
|
fi
|
|
|
|
if [[ -z ${fw_current} ]]; then
|
|
echo "Could not retreive current FW version."
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -z ${fw_required} ]]; then
|
|
echo "Could not retreive required FW version."
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ${fw_current} == ${fw_required} ]]; then
|
|
echo "Mellanox firmware is up to date."
|
|
else
|
|
echo "Mellanox firmware required version is ${fw_required}. Installing compatible version..."
|
|
run_or_fail "mlxfwmanager -i ${fw_file} -u -f -y"
|
|
fi
|
|
}
|
|
|
|
upgrade "$1"
|