From 2d4ccd7a0c13156009b4871784693839f2cb93f0 Mon Sep 17 00:00:00 2001 From: Missing Date: Mon, 15 Jul 2024 10:44:21 +0800 Subject: [PATCH] Add ( script : inband_ac_cycle.sh) --- Readme.md | 1 + inband_ac_cycle.sh | 74 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 inband_ac_cycle.sh diff --git a/Readme.md b/Readme.md index 09ba6eb..8d7f068 100644 --- a/Readme.md +++ b/Readme.md @@ -3,5 +3,6 @@ ## 脚本列表 - 带内执行power cycle :[inband_dc_cycle.sh](./inband_dc_cycle.sh) - 带外执行power cycle : [outband_dc_cycle.sh](./outband_dc_cycle.sh) +- 带内执行AC cycle : [inband_ac_cycle.sh](./inband_ac_cycle.sh) - OS执行reboot :[os_reboot.sh](./os_reboot.sh) - 使用YAFU带内升级BMC :[inband_stress_update.sh](./inband_stress_update.sh) \ No newline at end of file diff --git a/inband_ac_cycle.sh b/inband_ac_cycle.sh new file mode 100644 index 0000000..abb6402 --- /dev/null +++ b/inband_ac_cycle.sh @@ -0,0 +1,74 @@ +#!/bin/bash + +#### About this script +# Brief : This script is used for inband ac_cyle +# Input Params : 1.AC cycle times +# Example : ./inband_ac_cycle.sh 500 & +# Tips : if want to check anything before machine ac cycle, +# put code into function pre_check(Line:34) + +# ---------------------------------------------------- +# Varible Defination +# ---------------------------------------------------- +aim_cnt=$1 + +PARAM_NUM="1" +LOG_FILE="inband_ac_cycle.log" +LOCAL_CNT_FILE="count.txt" + +# ---------------------------------------------------- +# Function Defination +# ---------------------------------------------------- +print_usage(){ + echo ">>>> Script Usage - inband_ac_cycle.sh" + echo "Format: ./inband_ac_cycle.sh [cnt] &" +} + +is_param_legal(){ + if [ $# -ne $PARAM_NUM ];then + print_usage + exit 0 + fi +} + +pre_check(){ + # check if local cnt file exist + if [ -f $LOCAL_CNT_FILE ];then + echo "Local cnt file exist ..." >> /dev/null + else + echo "Local cnt file doesn't exist, so creat it ..." | tee $LOG_FILE + echo 1 > $LOCAL_CNT_FILE + fi + + echo "---------------------------------------------" | tee $LOG_FILE + + #Todo if need check something + + sleep 120 +} + +start_ac_cycle(){ + local_cnt=`cat $LOCAL_CNT_FILE` + + if [ $local_cnt -le $aim_cnt ];then + echo "Index $local_cnt : will execute machine AC cycle" | tee $LOG_FILE + + local_cnt=$(($local_cnt+1)) + echo $local_cnt > $LOCAL_CNT_FILE + + ipmitool raw 0x3c 0x28 0xff 0xfc + + sleep 10 + + ipmitool raw 0x3c 0x28 0xff 0xfd + fi +} + +# ---------------------------------------------------- +# The start of script +# ---------------------------------------------------- +is_param_legal + +pre_check + +start_ac_cycle \ No newline at end of file