2024-07-15 09:12:15 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
#### About this script
|
|
|
|
|
# Brief : This script is used for inband bmc update by yafuflash
|
|
|
|
|
# Input Params : 1.update times
|
|
|
|
|
# Example : ./inband_stress_update 200 ./image1 ./image2 &
|
|
|
|
|
# Tips : if want to check anything before stress update,
|
|
|
|
|
# put code into function pre_check(Line:37)
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------
|
|
|
|
|
# Varible Defination
|
|
|
|
|
# ----------------------------------------------------
|
|
|
|
|
aim_cnt=$1
|
|
|
|
|
image1=$2
|
|
|
|
|
image2=$3
|
|
|
|
|
|
|
|
|
|
PARAM_NUM="3"
|
|
|
|
|
YAFU="./Yafuflash"
|
|
|
|
|
LOG_FILE="./inband_stress_update.log"
|
|
|
|
|
sleep_time=600
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------
|
|
|
|
|
# Function Defination
|
|
|
|
|
# ----------------------------------------------------
|
|
|
|
|
print_usage(){
|
|
|
|
|
echo ">>> Script Usage - inband_stress_update.sh"
|
|
|
|
|
echo "Format : ./inband_stress_update.sh [cnt] [image1] [image2]"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
is_param_legal(){
|
|
|
|
|
if [ $# -ne $PARAM_NUM ];then
|
|
|
|
|
print_usage
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pre_check(){
|
|
|
|
|
# check if local cnt file exist
|
|
|
|
|
echo "---------------------------------------------" | tee $LOG_FILE
|
|
|
|
|
|
|
|
|
|
#Todo if need check something
|
|
|
|
|
ipmitool mc info | tee $LOG_FILE
|
|
|
|
|
if [ $? -ne 0 ];then
|
|
|
|
|
echo ">>> BMC Die, script terminated ..." | tee $LOG_FILE
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
start_stress_update(){
|
|
|
|
|
cnt=0
|
|
|
|
|
use_image=$image2
|
|
|
|
|
while true
|
|
|
|
|
do
|
|
|
|
|
cnt=$(($cnt+1))
|
|
|
|
|
echo ">>> start test index $cnt" | tee $LOG_FILE
|
|
|
|
|
|
|
|
|
|
pre_check
|
|
|
|
|
|
|
|
|
|
# select image to use
|
|
|
|
|
if [ "$use_image" == "$image1" ];then
|
|
|
|
|
use_image=$image2
|
|
|
|
|
else
|
|
|
|
|
use_image=$image1
|
|
|
|
|
fi
|
|
|
|
|
echo ">>> Use Image : $use_image" | tee $LOG_FILE
|
|
|
|
|
|
|
|
|
|
# start update
|
|
|
|
|
$YAFU -cd $use_image -pc | tee $LOG_FILE
|
|
|
|
|
echo ">>> End of update , start sleep 600s ..." | tee $LOG_FILE
|
|
|
|
|
|
|
|
|
|
if [ $cnt -le $aim_cnt ];then
|
|
|
|
|
sleep $sleep_time
|
|
|
|
|
else
|
|
|
|
|
echo ">>> Complete stress update, Exit ..." | tee $LOG_FILE
|
2024-07-15 10:25:25 +08:00
|
|
|
break
|
2024-07-15 09:12:15 +08:00
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------
|
|
|
|
|
# The start of script
|
|
|
|
|
# ----------------------------------------------------
|
|
|
|
|
is_param_legal
|
|
|
|
|
|
|
|
|
|
start_stress_update
|