2024-07-14 23:42:10 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
#### About this script
|
|
|
|
|
# Brief : This script is used for inband dc_cyle
|
|
|
|
|
# Input Params : 1.DC cycle times
|
|
|
|
|
# Example : ./inband_dc_cycle.sh 500 &
|
|
|
|
|
# Tips : if want to check anything before cpu power cycle,
|
|
|
|
|
# put code into function pre_check(Line:34)
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------
|
|
|
|
|
# Varible Defination
|
|
|
|
|
# ----------------------------------------------------
|
|
|
|
|
aim_cnt=$1
|
|
|
|
|
|
|
|
|
|
PARAM_NUM="1"
|
|
|
|
|
LOG_FILE="inband_dc_cycle.log"
|
|
|
|
|
LOCAL_CNT_FILE="count.txt"
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------
|
|
|
|
|
# Function Defination
|
|
|
|
|
# ----------------------------------------------------
|
|
|
|
|
print_usage(){
|
|
|
|
|
echo ">>>> Script Usage - inband_dc_cycle.sh"
|
|
|
|
|
echo "Format: ./inband_dc_cycle.sh [cnt] &"
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-15 16:56:47 +08:00
|
|
|
# is_param_legal(){
|
|
|
|
|
# if [ $# -ne $PARAM_NUM ];then
|
|
|
|
|
# print_usage
|
|
|
|
|
# exit 0
|
|
|
|
|
# fi
|
|
|
|
|
# }
|
2024-07-14 23:42:10 +08:00
|
|
|
|
|
|
|
|
pre_check(){
|
|
|
|
|
# check if local cnt file exist
|
|
|
|
|
if [ -f $LOCAL_CNT_FILE ];then
|
|
|
|
|
echo "Local cnt file exist ..." >> /dev/null
|
|
|
|
|
else
|
2024-07-26 17:09:35 +08:00
|
|
|
echo "Local cnt file doesn't exist, so creat it ..."
|
2024-07-14 23:42:10 +08:00
|
|
|
echo 1 > $LOCAL_CNT_FILE
|
|
|
|
|
fi
|
|
|
|
|
|
2024-07-26 17:09:35 +08:00
|
|
|
echo "---------------------------------------------"
|
2024-07-14 23:42:10 +08:00
|
|
|
|
|
|
|
|
#Todo if need check something
|
|
|
|
|
|
|
|
|
|
sleep 120
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
start_dc_cycle(){
|
|
|
|
|
local_cnt=`cat $LOCAL_CNT_FILE`
|
|
|
|
|
|
|
|
|
|
if [ $local_cnt -le $aim_cnt ];then
|
2024-07-26 17:09:35 +08:00
|
|
|
echo "Index $local_cnt : will execute power cycle"
|
2024-07-14 23:42:10 +08:00
|
|
|
|
|
|
|
|
local_cnt=$(($local_cnt+1))
|
|
|
|
|
echo $local_cnt > $LOCAL_CNT_FILE
|
|
|
|
|
|
|
|
|
|
ipmitool power cycle
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------
|
|
|
|
|
# The start of script
|
|
|
|
|
# ----------------------------------------------------
|
2024-07-15 16:56:47 +08:00
|
|
|
if [ $# -ne $PARAM_NUM ];then
|
|
|
|
|
print_usage
|
|
|
|
|
exit 0
|
|
|
|
|
fi
|
2024-07-14 23:42:10 +08:00
|
|
|
pre_check
|
|
|
|
|
|
|
|
|
|
start_dc_cycle
|