refactor(master : nicsensor) 整理 配置检查 和 调试日志初始化为同一个接口使用
新接口:pre_exec_hook
This commit is contained in:
parent
3301d9fdf7
commit
d3ad01482a
25
nicsensor.sh
25
nicsensor.sh
@ -232,15 +232,6 @@ reset_pca9548(){
|
||||
i2ctransfer -y $1 w1@$2 0x00
|
||||
}
|
||||
|
||||
# script self test
|
||||
conf_pre_check(){
|
||||
# check DEBUG_MODE value
|
||||
if [ $DEBUG_MODE -ne 0 ] && [ $DEBUG_MODE -ne 1 ];then
|
||||
format_print $ERROR "Invalid conf value, DEBUG_MODE: $DEBUG_MODE"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
set_configuration_5280m7(){
|
||||
|
||||
# set pca9641 address && I2C BUS
|
||||
@ -558,9 +549,13 @@ init_debuglog(){
|
||||
res_date=`date +%Y-%m-%dT%H:%M:%S`
|
||||
format_log_print $INFO "Start Time : $res_date"
|
||||
format_log_print $INFO "Script Version : $SCRIPT_VERSION"
|
||||
format_log_print $INFO "Debug Mode : $DEBUG_MODE"
|
||||
format_log_print $INFO "Disable Detect : $DISABLE_DETECT"
|
||||
|
||||
if [ $DEBUG_MODE -ne 0 ];then
|
||||
format_log_print $WARNING "Enable debug mode : $DEBUG_MODE"
|
||||
if [ $nic_slot == "detect" ];then
|
||||
format_log_print $INFO "Operation Tpye : i2c detect"
|
||||
else
|
||||
format_log_print $INFO "Operation Tpye : read sensor"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -615,6 +610,10 @@ switch_pca9548_channel(){
|
||||
fi
|
||||
}
|
||||
|
||||
# pre execute hook function
|
||||
pre_exec_hook(){
|
||||
init_debuglog
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------
|
||||
# Chip EMC1413
|
||||
@ -1437,7 +1436,7 @@ start_detect_device(){
|
||||
# Start Execute Script
|
||||
# ---------------------------------------------------------
|
||||
|
||||
conf_pre_check
|
||||
pre_exec_hook
|
||||
|
||||
if [ "$1" == "version" ];then
|
||||
echo "Script Version : $SCRIPT_VERSION"
|
||||
@ -1469,8 +1468,6 @@ if [ "$1" == "detect" ];then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
init_debuglog
|
||||
|
||||
# if the action is fru write, need pre-process fru data
|
||||
if [ "$sensor_type" == "fru" ];then
|
||||
if [ "$option_data" == "write" ];then
|
||||
|
||||
Loading…
Reference in New Issue
Block a user