refactor(script : nicsensor.sh)Update to version 1.2 Intest Rev8

1.重构if else语句为case语句
This commit is contained in:
marcinlei 2024-11-29 11:41:21 +08:00
parent 9eb8564b6c
commit a3b2c16198

@ -133,7 +133,7 @@ ina3221_ch2_volt="0"
ina3221_ch0_current="0" ina3221_ch0_current="0"
ina3221_ch1_current="0" ina3221_ch1_current="0"
ina3221_ch2_current="0" ina3221_ch2_current="0"
SCRIPT_VERSION="1.2 InTest Rev7" SCRIPT_VERSION="1.2 InTest Rev8"
fru_file_name=$option_data2 fru_file_name=$option_data2
fru_write_size=0 fru_write_size=0
@ -375,20 +375,27 @@ set_configuration(){
format_log_print $INFO "Server Type : $server_type" format_log_print $INFO "Server Type : $server_type"
# 根据服务器型号执行对应的配置策略 # 根据服务器型号执行对应的配置策略
if [ $server_type == "5280m7" ];then case $server_type in
"5280m7")
set_configuration_5280m7 set_configuration_5280m7
elif [ $server_type == "5468m7" ];then ;;
"5468m7")
set_configuration_5468m7 set_configuration_5468m7
elif [ $server_type == "donghu" ];then ;;
"donghu")
set_configuration_donghu set_configuration_donghu
elif [ $server_type == "yichun" ];then ;;
"yichun")
set_configuration_yichun set_configuration_yichun
elif [ $server_type == "qiandaohu" ];then ;;
"qiandaohu")
set_configuration_qiandaohu set_configuration_qiandaohu
else ;;
*)
format_print $ERROR "Error: Unsupport Server Type !!! - $server_type" format_print $ERROR "Error: Unsupport Server Type !!! - $server_type"
exit 1 exit 1
fi ;;
esac
} }
# 初始化调试日志 # 初始化调试日志
@ -916,20 +923,27 @@ start_get_sensor(){
fi fi
# get sensor detail value # get sensor detail value
if [ "$sensor_type" == "emc1413" ];then case $sensor_type in
"emc1413")
process_emc1413 process_emc1413
elif [ "$sensor_type" == "adc128" ];then ;;
"adc128")
process_adc128 process_adc128
elif [ "$sensor_type" == "ina3221" ];then ;;
"ina3221")
process_ina3221 process_ina3221
elif [ "$sensor_type" == "chip" ];then ;;
"chip")
process_chip process_chip
elif [ "$sensor_type" == "fru" ];then ;;
"fru")
process_fru process_fru
else ;;
*)
format_print $ERROR "Unsupport Sensor Type !!!" format_print $ERROR "Unsupport Sensor Type !!!"
print_usage print_usage
fi ;;
esac
} }
# 在 5280m7 上扫描每个pcie slot下的I2C设备 # 在 5280m7 上扫描每个pcie slot下的I2C设备
@ -1033,19 +1047,26 @@ start_detect_device(){
fi fi
format_print $INFO "Detect on server : $server_type" format_print $INFO "Detect on server : $server_type"
if [ $server_type == "5280m7" ];then case $server_type in
"5280m7")
detect_on_5280m7 detect_on_5280m7
elif [ $server_type == "5468m7" ];then ;;
"5468m7")
detect_on_5468m7 detect_on_5468m7
elif [ $server_type == "donghu" ];then ;;
"donghu")
detect_on_donghu detect_on_donghu
elif [ $server_type == "yichun" ];then ;;
"yichun")
detect_on_yichun detect_on_yichun
elif [ $server_type == "qiandaohu" ];then ;;
"qiandaohu")
detect_on_qiandaohu detect_on_qiandaohu
else ;;
format_print $ERROR "Unsupport Server Type !!!" *)
fi format_print $ERROR "Unsupport Server Type - $server_type !!!"
;;
esac
} }
# --------------------------------------------------------- # ---------------------------------------------------------