work_sript/01.stress_script/inband_stress_update.sh

88 lines
2.1 KiB
Bash
Raw Permalink Normal View History

#!/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
2024-07-26 17:09:35 +08:00
echo "---------------------------------------------"
#Todo if need check something
2024-07-26 17:09:35 +08:00
ipmitool mc info
if [ $? -ne 0 ];then
2024-07-26 17:09:35 +08:00
echo ">>> BMC Die, script terminated ..."
exit 0
fi
}
start_stress_update(){
cnt=0
use_image=$image2
while true
do
cnt=$(($cnt+1))
2024-07-26 17:09:35 +08:00
echo ">>> start test index $cnt"
pre_check
# select image to use
if [ "$use_image" == "$image1" ];then
use_image=$image2
else
use_image=$image1
fi
2024-07-26 17:09:35 +08:00
echo ">>> Use Image : $use_image"
# start update
2024-07-26 17:09:35 +08:00
$YAFU -cd $use_image -pc
echo ">>> End of update , start sleep 600s ..."
if [ $cnt -le $aim_cnt ];then
sleep $sleep_time
else
2024-07-26 17:09:35 +08:00
echo ">>> Complete stress update, Exit ..."
break
fi
done
}
# ----------------------------------------------------
# The start of script
# ----------------------------------------------------
if [ $# -ne $PARAM_NUM ];then
print_usage
exit 0
fi
start_stress_update