Skip to content

Instantly share code, notes, and snippets.

@noslin005
Created August 6, 2020 22:32
Show Gist options
  • Save noslin005/ca15e82d4c812be96b1cd31d8871a6a0 to your computer and use it in GitHub Desktop.
Save noslin005/ca15e82d4c812be96b1cd31d8871a6a0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
echo "Counting HBA SAS3 controllers ..."
sas_ctrl=$(sas3flash -listall | grep -e "^[0-9]"| awk '{print $1}')
output="/tmp/sas.txt"
for ctrl in ${sas_ctrl[@]}; do
ctrl_index=$(echo $ctrl | awk '{print $1}')
echo "Controller ${ctrl_index}: Identifying Model and Firmware ID"
sas3flash -c ${ctrl_index} -list > $output
model=$(awk '/Board Name/ {print $4}' $output)
firmware_mode=$(awk '/Firmware Product ID/ {print $6}' $output | tr -d '()')
echo "Controller ${ctrl_index}: Model = $model"
echo "Controller ${ctrl_index}: Firmware Mode = $firmware_mode"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment