ansible-devops/scripts/mellanox-fwupdate.sh

31 lines
1002 B
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
cd /opt/
mst start
# 检查必要命令
command -v ibdev2netdev >/dev/null || { echo "错误ibdev2netdev命令未找到"; exit 1; }
command -v flint >/dev/null || { echo "错误flint命令未找到"; exit 1; }
# 固件文件定义
FW_FILE="fw-ConnectX7-rel-28_43_2566-MCX755106AS-HEA_Ax-UEFI-14.37.13-FlexBoot-3.7.500.signed.bin"
[ -f "$FW_FILE" ] || { echo "错误:固件文件 $FW_FILE 不存在"; exit 1; }
# 设备过滤和处理
ibdev2netdev -v | grep -Ev 'Umbriel|bond' | awk '{print $2}' | while read -r device; do
# 提取最后一位数字
last_digit=${device##*_}
# 检查是否为数字且为偶数
if [[ "$last_digit" =~ ^[0-9]+$ ]] && [ $((last_digit % 2)) -eq 0 ]; then
echo "正在更新双数设备: $device"
if ! flint -d "$device" -y -i "$FW_FILE" b; then
echo "警告:设备 $device 更新失败"
fi
else
echo "跳过非双数设备: $device"
fi
done
echo "固件更新操作完成"