Add ( script : os_reboot.sh)
This commit is contained in:
parent
263900712b
commit
c4e5fad891
@ -1,4 +1,5 @@
|
||||
# Readme
|
||||
|
||||
## 脚本列表
|
||||
- 带内执行power cycle :[inband_dc_cycle.sh](./inband_dc_cycle.sh)
|
||||
- 带内执行power cycle :[inband_dc_cycle.sh](./inband_dc_cycle.sh)
|
||||
- OS执行reboot :[os_reboot.sh](./os_reboot.sh)
|
||||
72
os_reboot.sh
Normal file
72
os_reboot.sh
Normal file
@ -0,0 +1,72 @@
|
||||
#!/bin/bash
|
||||
|
||||
#### About this script
|
||||
# Brief : This script is used for os reboot
|
||||
# Input Params : 1.Reboot times
|
||||
# Example : ./os_reboot.sh 500 &
|
||||
# Tips : if want to check anything before cpu reboot,
|
||||
# put code into function pre_check(Line:34)
|
||||
|
||||
# ----------------------------------------------------
|
||||
# Varible Defination
|
||||
# ----------------------------------------------------
|
||||
aim_cnt=$1
|
||||
|
||||
PARAM_NUM="1"
|
||||
LOG_FILE="os_reboot.log"
|
||||
LOCAL_CNT_FILE="count.txt"
|
||||
|
||||
# ----------------------------------------------------
|
||||
# Function Defination
|
||||
# ----------------------------------------------------
|
||||
print_usage(){
|
||||
echo ">>>> Script Usage - os_reboot.sh"
|
||||
echo "Format: ./os_reboot.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_os_reboot(){
|
||||
local_cnt=`cat $LOCAL_CNT_FILE`
|
||||
|
||||
if [ $local_cnt -le $aim_cnt ];then
|
||||
echo "Index $local_cnt : will execute reboot" | tee $LOG_FILE
|
||||
|
||||
sleep 1
|
||||
|
||||
local_cnt=$(($local_cnt+1))
|
||||
echo $local_cnt > $LOCAL_CNT_FILE
|
||||
|
||||
reboot
|
||||
fi
|
||||
}
|
||||
|
||||
# ----------------------------------------------------
|
||||
# The start of script
|
||||
# ----------------------------------------------------
|
||||
is_param_legal
|
||||
|
||||
pre_check
|
||||
|
||||
start_os_reboot
|
||||
Loading…
Reference in New Issue
Block a user