From a3b2c16198cca98b61205bb66650d5d5bd451e0a Mon Sep 17 00:00:00 2001 From: marcinlei Date: Fri, 29 Nov 2024 11:41:21 +0800 Subject: [PATCH] =?UTF-8?q?refactor(script=20:=20nicsensor.sh)Update=20to?= =?UTF-8?q?=20version=201.2=20Intest=20Rev8=201.=E9=87=8D=E6=9E=84if=20els?= =?UTF-8?q?e=E8=AF=AD=E5=8F=A5=E4=B8=BAcase=E8=AF=AD=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 02.nicsensor/nicsensor.sh | 105 +++++++++++++++++++++++--------------- 1 file changed, 63 insertions(+), 42 deletions(-) diff --git a/02.nicsensor/nicsensor.sh b/02.nicsensor/nicsensor.sh index 567ffd8..7f21929 100644 --- a/02.nicsensor/nicsensor.sh +++ b/02.nicsensor/nicsensor.sh @@ -133,7 +133,7 @@ ina3221_ch2_volt="0" ina3221_ch0_current="0" ina3221_ch1_current="0" ina3221_ch2_current="0" -SCRIPT_VERSION="1.2 InTest Rev7" +SCRIPT_VERSION="1.2 InTest Rev8" fru_file_name=$option_data2 fru_write_size=0 @@ -375,20 +375,27 @@ set_configuration(){ format_log_print $INFO "Server Type : $server_type" # 根据服务器型号执行对应的配置策略 - if [ $server_type == "5280m7" ];then - set_configuration_5280m7 - elif [ $server_type == "5468m7" ];then - set_configuration_5468m7 - elif [ $server_type == "donghu" ];then - set_configuration_donghu - elif [ $server_type == "yichun" ];then - set_configuration_yichun - elif [ $server_type == "qiandaohu" ];then - set_configuration_qiandaohu - else - format_print $ERROR "Error: Unsupport Server Type !!! - $server_type" - exit 1 - fi + case $server_type in + "5280m7") + set_configuration_5280m7 + ;; + "5468m7") + set_configuration_5468m7 + ;; + "donghu") + set_configuration_donghu + ;; + "yichun") + set_configuration_yichun + ;; + "qiandaohu") + set_configuration_qiandaohu + ;; + *) + format_print $ERROR "Error: Unsupport Server Type !!! - $server_type" + exit 1 + ;; + esac } # 初始化调试日志 @@ -916,20 +923,27 @@ start_get_sensor(){ fi # get sensor detail value - if [ "$sensor_type" == "emc1413" ];then - process_emc1413 - elif [ "$sensor_type" == "adc128" ];then - process_adc128 - elif [ "$sensor_type" == "ina3221" ];then - process_ina3221 - elif [ "$sensor_type" == "chip" ];then - process_chip - elif [ "$sensor_type" == "fru" ];then - process_fru - else - format_print $ERROR "Unsupport Sensor Type !!!" - print_usage - fi + case $sensor_type in + "emc1413") + process_emc1413 + ;; + "adc128") + process_adc128 + ;; + "ina3221") + process_ina3221 + ;; + "chip") + process_chip + ;; + "fru") + process_fru + ;; + *) + format_print $ERROR "Unsupport Sensor Type !!!" + print_usage + ;; + esac } # 在 5280m7 上扫描每个pcie slot下的I2C设备 @@ -1033,19 +1047,26 @@ start_detect_device(){ fi format_print $INFO "Detect on server : $server_type" - if [ $server_type == "5280m7" ];then - detect_on_5280m7 - elif [ $server_type == "5468m7" ];then - detect_on_5468m7 - elif [ $server_type == "donghu" ];then - detect_on_donghu - elif [ $server_type == "yichun" ];then - detect_on_yichun - elif [ $server_type == "qiandaohu" ];then - detect_on_qiandaohu - else - format_print $ERROR "Unsupport Server Type !!!" - fi + case $server_type in + "5280m7") + detect_on_5280m7 + ;; + "5468m7") + detect_on_5468m7 + ;; + "donghu") + detect_on_donghu + ;; + "yichun") + detect_on_yichun + ;; + "qiandaohu") + detect_on_qiandaohu + ;; + *) + format_print $ERROR "Unsupport Server Type - $server_type !!!" + ;; + esac } # ---------------------------------------------------------