1#!/bin/bash 2 3# Set mctpi2c link up and assign local address. 4localEid=8 5busNum=9 6maxRetries=5 7retryInterval=1 8 9retry_command() { 10 11 command="$1" 12 retries=0 13 14 while [ $retries -lt $maxRetries ]; do 15 if bash -c "$command"; then 16 return 0 17 else 18 retries=$((retries + 1)) 19 echo "Retry $retries/$maxRetries: Command failed. Retrying in $retryInterval seconds..." 20 sleep $retryInterval 21 fi 22 done 23 24 return 1 25} 26 27# Retry mctp link command 28if ! retry_command "mctp link set mctpi2c${busNum} up"; then 29 echo "Failed to set mctp link after $maxRetries attempts." 30 exit 1 31fi 32 33# Check if local EID is already set 34mctpOutput=$(mctp address show) 35if echo "$mctpOutput" | grep -q "mctpi2c${busNum}"; then 36 echo "mctpi2c${busNum} local EID already set" 37else 38 # Retry mctp addr add command 39 if ! retry_command "mctp addr add ${localEid} dev mctpi2c${busNum}"; then 40 echo "Failed to add mctp address after $maxRetries attempts." 41 exit 1 42 fi 43fi 44echo "mctpi2c${busNum} local EID set to ${localEid}" 45exit 0