From 88f871c880d58c6d227d535d399ed74288b55ce8 Mon Sep 17 00:00:00 2001 From: leimingsheng Date: Fri, 17 Apr 2026 17:09:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(master)=20update=20to=201.10=20base=20dev?= =?UTF-8?q?=202=201.[=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD]=E8=A7=A3?= =?UTF-8?q?=E8=80=A6=E8=84=9A=E6=9C=AC=E5=8F=82=E6=95=B0=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=8A=9F=E8=83=BD,=20=E8=84=9A=E6=9C=AC=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=85=A8=E9=83=A8=E6=94=BE=E5=88=B0project.config=E4=B8=AD=202?= =?UTF-8?q?.[=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD]=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=AF=B9pmbus=20set=E5=91=BD=E4=BB=A4=E7=9A=84=E6=94=AF?= =?UTF-8?q?=E6=8C=81=203.[=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD]=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0setup.sh,=20=E7=94=A8=E4=BA=8E=E4=B8=80=E9=94=AE?= =?UTF-8?q?=E9=83=A8=E7=BD=B2=E8=84=9A=E6=9C=AC=204.[=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E4=BC=98=E5=8C=96]=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E9=87=8D=E6=96=B0=E5=BD=92=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/change_list.txt | 7 + .../pmbus_cmd_list.sh | 22 ++- stress_test.sh => extension/stress_test.sh | 19 +-- nicsensor.sh | 129 +++++++++++------- project.config | 56 ++++++++ setup.sh | 57 ++++++++ .../nicsensor_v2}/autoauth.sh | 0 .../nicsensor_v2}/format_print.sh | 0 {nicsensor_v2 => tool/nicsensor_v2}/i2c_m6.sh | 0 {nicsensor_v2 => tool/nicsensor_v2}/i2c_m7.sh | 0 .../nicsensor_v2}/nicsensor.sh | 0 .../nicsensor_v2}/platform_5280m7.sh | 0 .../nicsensor_v2}/platform_5688m7.sh | 0 .../nicsensor_v2}/plugin_adc128.sh | 0 .../nicsensor_v2}/plugin_emc1413.sh | 0 .../nicsensor_v2}/plugin_ina3221.sh | 0 .../nicsensor_v2}/plugin_tmp112.sh | 0 .../nicsensor_v2}/plugin_tmp468.sh | 0 {nicsensor_v2 => tool/nicsensor_v2}/readme.md | 0 {test_plugin => tool/test}/check_threhold.sh | 0 {test_plugin => tool/test}/readme.md | 0 21 files changed, 222 insertions(+), 68 deletions(-) rename pmbus_cmd_list.sh => extension/pmbus_cmd_list.sh (88%) rename stress_test.sh => extension/stress_test.sh (92%) create mode 100644 project.config create mode 100644 setup.sh rename {nicsensor_v2 => tool/nicsensor_v2}/autoauth.sh (100%) rename {nicsensor_v2 => tool/nicsensor_v2}/format_print.sh (100%) rename {nicsensor_v2 => tool/nicsensor_v2}/i2c_m6.sh (100%) rename {nicsensor_v2 => tool/nicsensor_v2}/i2c_m7.sh (100%) rename {nicsensor_v2 => tool/nicsensor_v2}/nicsensor.sh (100%) rename {nicsensor_v2 => tool/nicsensor_v2}/platform_5280m7.sh (100%) rename {nicsensor_v2 => tool/nicsensor_v2}/platform_5688m7.sh (100%) rename {nicsensor_v2 => tool/nicsensor_v2}/plugin_adc128.sh (100%) rename {nicsensor_v2 => tool/nicsensor_v2}/plugin_emc1413.sh (100%) rename {nicsensor_v2 => tool/nicsensor_v2}/plugin_ina3221.sh (100%) rename {nicsensor_v2 => tool/nicsensor_v2}/plugin_tmp112.sh (100%) rename {nicsensor_v2 => tool/nicsensor_v2}/plugin_tmp468.sh (100%) rename {nicsensor_v2 => tool/nicsensor_v2}/readme.md (100%) rename {test_plugin => tool/test}/check_threhold.sh (100%) rename {test_plugin => tool/test}/readme.md (100%) diff --git a/docs/change_list.txt b/docs/change_list.txt index f11055f..d6609ec 100644 --- a/docs/change_list.txt +++ b/docs/change_list.txt @@ -1,3 +1,10 @@ +# Script Version 1.11 + #Release Note + 1.[新增功能]解耦脚本参数配置功能, 脚本配置全部放到project.config中 + 2.[新增功能]增加对pmbus set命令的支持 + 3.[新增功能]增加setup.sh, 用于一键部署脚本 + 4.[功能优化]代码结构目录重新归档 + # Script Verison 1.10 Release Note 1.[新增功能]新增适配传感器 ina226, lm95241 diff --git a/pmbus_cmd_list.sh b/extension/pmbus_cmd_list.sh similarity index 88% rename from pmbus_cmd_list.sh rename to extension/pmbus_cmd_list.sh index 46602a2..8219d6c 100644 --- a/pmbus_cmd_list.sh +++ b/extension/pmbus_cmd_list.sh @@ -1,14 +1,12 @@ #!/bin/sh # Desc : This script used to find pmbus code and read size -# Todo : Support PMBUS Setting Function -# Version : 0.1 -# Date : 2025-12-25 # Changelist : 2025-12-25|v0.1 Create this file +# 2026-04-17|v1.1 Add PAGE command support # How to use this pmbus plugin? -# Copy this file to the dir as same as nicsensor.sh -EXTENSION_VERSION="v1.0" +# Follow readme.md file to use this plugin or use setup.sh to install this plugin +EXTENSION_VERSION="v1.1" # --------------------------------------------------------- # Varible Define # --------------------------------------------------------- @@ -28,15 +26,18 @@ PMBUS_RAW=4 pmbus_command_help(){ echo " Extend Function - PMBUS command test" echo " Version : $EXTENSION_VERSION" - echo " 1) Command Format : ./nicsensor.sh [slot] pmbus [slave] [command]" + echo " 1) Command Format : ./nicsensor.sh [slot] pmbus [slave] [command] " echo " 2) Option Detail" echo " - [slot] : 0 1 2 3 4 5 ..." echo " - [slave] : power manage chip slave address , please provide 7 bit address" echo " - [command] : The pmbus command which will set to the power manage chip" + echo " - : The data which will set to the power manage chip, only set operation type is set" echo " 3) E.G. : ./nicsensor.sh pcie1 pmbus 0x60 READ_TEMPERATURE_1" + echo " : ./nicsensor.sh pcie1 pmbus 0x60 PAGE 0x00" echo "" echo " *****************Pmbus Support Command List********************" echo " Command Name Code op_type Read Size " + echo " PAGE 0x00 set Byte " echo " READ_VIN 0x88 get Word " echo " READ_IIN 0x89 get Word " echo " READ_VOUT 0x8b get Word " @@ -52,6 +53,9 @@ pmbus_command_help(){ find_pmbus_hex_code(){ case ${str_cmd} in + "PAGE") + hex_cmd=0x00 + ;; "READ_VIN") hex_cmd=0x88 ;; @@ -88,6 +92,9 @@ find_pmbus_hex_code(){ find_pmbus_operation_type(){ case ${str_cmd} in + "PAGE") + op_type="set" + ;; "READ_VIN") op_type="get" ;; @@ -124,6 +131,9 @@ find_pmbus_operation_type(){ find_pmbus_read_size(){ case ${str_cmd} in + "PAGE") + read_size=$PMBUS_BYTE + ;; "READ_VIN") read_size=$PMBUS_WORD ;; diff --git a/stress_test.sh b/extension/stress_test.sh similarity index 92% rename from stress_test.sh rename to extension/stress_test.sh index c8c4a16..4dad28f 100644 --- a/stress_test.sh +++ b/extension/stress_test.sh @@ -4,7 +4,7 @@ # Detail: This script will stress test the nicsensor by reading the sensor data # and print the result to the console. -EXTENSION_VERSION="v1.0" +EXTENSION_VERSION="v1.0 Base Dev 1" # --------------------------------------------------------- # Varible Define @@ -120,9 +120,9 @@ start_stress_test(){ if [ -f ${CONFIG_NICSENSOR} ]; then config_tool=$(cat ${CONFIG_NICSENSOR}) else - config_tool="nicsensor.sh" + config_tool="/extlog/nicsensor/nicsensor.sh" fi - if [ ! -f "./${config_tool}" ]; then + if [ ! -f "${config_tool}" ]; then echo "Error: ${config_tool} tool not found" echo "Info : Please check the nicsensor tool path and name" return 1 @@ -131,27 +131,27 @@ start_stress_test(){ # option check if [ ! -f ${CONFIG_ROUND} ]; then echo "Error: Round is not set" - echo "Info : Please set the stress test round first, use command: ./nicsensor.sh [slot] stress round [data]" + echo "Info : Please set the stress test round first, use command: ${config_tool} [slot] stress round [data]" return 1 fi if [ ! -f ${CONFIG_INTERVAL} ]; then echo "Error: Interval is not set" - echo "Info : Please set the stress test interval first, use command: ./nicsensor.sh [slot] stress interval [data]" + echo "Info : Please set the stress test interval first, use command: ${config_tool} [slot] stress interval [data]" return 1 fi if [ ! -f ${CONFIG_SLOT} ]; then echo "Error: Slot is not set" - echo "Info : Please set the stress test slot first, use command: ./nicsensor.sh [slot] stress slot [data]" + echo "Info : Please set the stress test slot first, use command: ${config_tool} [slot] stress slot [data]" return 1 fi if [ ! -f ${CONFIG_SENSOR} ]; then echo "Error: Sensor is not set" - echo "Info : Please set the stress test sensor first, use command: ./nicsensor.sh [slot] stress sensor [data]" + echo "Info : Please set the stress test sensor first, use command: ${config_tool} [slot] stress sensor [data]" return 1 fi if [ ! -f ${CONFIG_SLAVE} ]; then echo "Error: Slave is not set" - echo "Info : Please set the stress test slave first, use command: ./nicsensor.sh [slot] stress slave [data]" + echo "Info : Please set the stress test slave first, use command: ${config_tool} [slot] stress slave [data]" return 1 fi @@ -170,9 +170,10 @@ start_stress_test(){ run_count=1 while [ ${run_count} -le ${config_round} ]; do + echo "" timestamp=$(date +"%Y-%m-%dT%H:%M:%S") echo "====== ${timestamp}, Run Count: ${run_count}" - exec_cmd="./${config_tool} ${config_slot} ${config_sensor} ${config_slave}" + exec_cmd="${config_tool} ${config_slot} ${config_sensor} ${config_slave}" ${exec_cmd} sleep ${config_interval} run_count=$((run_count+1)) diff --git a/nicsensor.sh b/nicsensor.sh index 00c5ee1..ecaff78 100755 --- a/nicsensor.sh +++ b/nicsensor.sh @@ -1,65 +1,75 @@ #!/bin/sh set -eo pipefail -SCRIPT_VERSION="1.10" +SCRIPT_VERSION="1.10 Base Dev 2" + +# Load project config file +PROJECT_VARIBLE_CONFIG="/extlog/nicsensor/project.config" +PROJECT_CONFIG_STATUS=0 + +if [ -f $PROJECT_VARIBLE_CONFIG ]; then + . $PROJECT_VARIBLE_CONFIG + PROJECT_CONFIG_STATUS=1 +fi # --------------------------------------------------------- -# Project Feature Varible (Change if need) +# Project Feature Varible +# Use default value if not set # --------------------------------------------------------- # ADC128 Division factor -votage_division_factor_0="1" -votage_division_factor_1="1" -votage_division_factor_2="1" -votage_division_factor_3="0.8" -votage_division_factor_4="0.6" -votage_division_factor_5="0.6" -votage_division_factor_6="0.2326" -votage_division_factor_7="1" +votage_division_factor_0="${votage_division_factor_0:-1}" +votage_division_factor_1="${votage_division_factor_1:-1}" +votage_division_factor_2="${votage_division_factor_2:-1}" +votage_division_factor_3="${votage_division_factor_3:-0.8}" +votage_division_factor_4="${votage_division_factor_4:-0.6}" +votage_division_factor_5="${votage_division_factor_5:-0.6}" +votage_division_factor_6="${votage_division_factor_6:-0.2326}" +votage_division_factor_7="${votage_division_factor_7:-1}" # ADC128 channel name -ADC128_Channel0_name="Channel0" -ADC128_Channel1_name="Channel1" -ADC128_Channel2_name="Channel2" -ADC128_Channel3_name="Channel3" -ADC128_Channel4_name="Channel4" -ADC128_Channel5_name="Channel5" -ADC128_Channel6_name="Channel6" -ADC128_Channel7_name="Channel7" +ADC128_Channel0_name="${ADC128_Channel0_name:-Channel0}" +ADC128_Channel1_name="${ADC128_Channel1_name:-Channel1}" +ADC128_Channel2_name="${ADC128_Channel2_name:-Channel2}" +ADC128_Channel3_name="${ADC128_Channel3_name:-Channel3}" +ADC128_Channel4_name="${ADC128_Channel4_name:-Channel4}" +ADC128_Channel5_name="${ADC128_Channel5_name:-Channel5}" +ADC128_Channel6_name="${ADC128_Channel6_name:-Channel6}" +ADC128_Channel7_name="${ADC128_Channel7_name:-Channel7}" # INA3221 shunt resistor(unit: mohm) -shunt_resistor_0="2" -shunt_resistor_1="2" -shunt_resistor_2="5" +shunt_resistor_0="${shunt_resistor_0:-2}" +shunt_resistor_1="${shunt_resistor_1:-2}" +shunt_resistor_2="${shunt_resistor_2:-5}" # INA3221 channel name -INA3221_Channel0_name="Channel0" -INA3221_Channel1_name="Channel1" -INA3221_Channel2_name="Channel2" +INA3221_Channel0_name="${INA3221_Channel0_name:-Channel0}" +INA3221_Channel1_name="${INA3221_Channel1_name:-Channel1}" +INA3221_Channel2_name="${INA3221_Channel2_name:-Channel2}" # EMC1413 channel name -EMC1413_Channel0_name="Channel0" -EMC1413_Channel1_name="Channel1" -EMC1413_Channel2_name="Channel2" +EMC1413_Channel0_name="${EMC1413_Channel0_name:-Channel0}" +EMC1413_Channel1_name="${EMC1413_Channel1_name:-Channel1}" +EMC1413_Channel2_name="${EMC1413_Channel2_name:-Channel2}" # TMP468 channel name -TMP468_Channel0_name="Local" -TMP468_Channel1_name="Remote1" -TMP468_Channel2_name="Remote2" -TMP468_Channel3_name="Remote3" -TMP468_Channel4_name="Remote4" -TMP468_Channel5_name="Remote5" -TMP468_Channel6_name="Remote6" -TMP468_Channel7_name="Remote7" -TMP468_Channel8_name="Remote8" +TMP468_Channel0_name="${TMP468_Channel0_name:-Local}" +TMP468_Channel1_name="${TMP468_Channel1_name:-Remote1}" +TMP468_Channel2_name="${TMP468_Channel2_name:-Remote2}" +TMP468_Channel3_name="${TMP468_Channel3_name:-Remote3}" +TMP468_Channel4_name="${TMP468_Channel4_name:-Remote4}" +TMP468_Channel5_name="${TMP468_Channel5_name:-Remote5}" +TMP468_Channel6_name="${TMP468_Channel6_name:-Remote6}" +TMP468_Channel7_name="${TMP468_Channel7_name:-Remote7}" +TMP468_Channel8_name="${TMP468_Channel8_name:-Remote8}" # TMP112 sensor name -TMP112_Sensor_name="Temperature" +TMP112_Sensor_name="${TMP112_Sensor_name:-Temperature}" # INA226 channel name -INA226_Channel0_name="Channel0" +INA226_Channel0_name="${INA226_Channel0_name:-Channel0}" # LM95241 channel name -LM95241_Local_name="Local" -LM95241_Remote1_name="Remote1" -LM95241_Remote2_name="Remote2" +LM95241_Local_name="${LM95241_Local_name:-Local}" +LM95241_Remote1_name="${LM95241_Remote1_name:-Remote1}" +LM95241_Remote2_name="${LM95241_Remote2_name:-Remote2}" # --------------------------------------------------------- # Global Settings # --------------------------------------------------------- @@ -161,12 +171,15 @@ pmbus_op="get" hex_pmbus_cmd=0xff hex_pmbus_size=0 CONFIG_DIR="/tmp/nicsensor_config/" + +# Extension Plugin Path +extension_dir="/extlog/nicsensor/extension" +PMBUS_PLUGIN="${extension_dir}/pmbus_cmd_list.sh" +STRESS_PLUGIN="${extension_dir}/stress_test.sh" # --------------------------------------------------------- # Script Function Defination # --------------------------------------------------------- search_plugin_help(){ - PMBUS_PLUGIN="./pmbus_cmd_list.sh" - STRESS_PLUGIN="./stress_test.sh" plugin_flag=0 if [ -e ${PMBUS_PLUGIN} ];then $PMBUS_PLUGIN "help" @@ -558,7 +571,6 @@ extension_preprocess(){ fi # Pmbus Command need pre-process - PMBUS_PLUGIN="./pmbus_cmd_list.sh" if [ -e ${PMBUS_PLUGIN} ];then str_pmbus_cmd=$option_data hex_pmbus_cmd=`$PMBUS_PLUGIN "code" $str_pmbus_cmd` @@ -571,18 +583,17 @@ extension_preprocess(){ hex_pmbus_size=`$PMBUS_PLUGIN "size" $str_pmbus_cmd` pmbus_op=`$PMBUS_PLUGIN "operation" $str_pmbus_cmd` else - fmt_print "console" $ERROR "Can't find pmbus plugin file, please copy pmbus_cmd_list.sh to here!" + fmt_print "console" $ERROR "Can't find pmbus plugin file, please copy pmbus_cmd_list.sh to ${PMBUS_PLUGIN}!" exit 1 fi fi if [ "$Param2" = "stress" ];then - STRESS_PLUGIN="./stress_test.sh" if [ -e ${STRESS_PLUGIN} ];then ${STRESS_PLUGIN} $Param3 $option_data exit 0 else - fmt_print "console" $ERROR "Can't find stress plugin file, please copy stress_test.sh to here!" + fmt_print "console" $ERROR "Can't find stress plugin file, please copy stress_test.sh to ${STRESS_PLUGIN}!" exit 1 fi fi @@ -597,6 +608,10 @@ pre_exec_hook(){ init_debuglog systemtool_check + if [ $PROJECT_CONFIG_STATUS -eq 0 ];then + fmt_print "console" $WARNING "Project config file not found, Will use default config." + fi + if [ "$Param1" = "help" ] && [ $param_num -eq 2 ];then print_usage $Param2 exit 0 @@ -1495,7 +1510,7 @@ process_fru(){ # --------------------------------------------------------- #@Param1 : Operation Type, get|set #@Param2 : Pmbus Command, hex data -#@Param3 : Pmbus reading size, BYTE(1)|WORD(2)|BLOCK(3)|RAW(4) +#@Param3 : Pmbus reading/write size, BYTE(1)|WORD(2)|BLOCK(3)|RAW(4) transfer_pmbus_command(){ if [ "$1" = "get" ];then pmbus_res=`i2ctransfer -y $i2c_bus w1@$chip_slave $2 r$3` @@ -1503,8 +1518,15 @@ transfer_pmbus_command(){ fmt_print "console" $INFO "$option_data ,Command Code:$2" fmt_print "console" $INFO "Result: $pmbus_res" else - fmt_print "console" $WARNING "Not Support Set function in this version : $SCRIPT_VERSION" - fi + # pmbus set command + write_byte=$(($3+1)) + # ./nicsensor.sh pcie1 pmbus 0x60 PAGE 0x00 + # so, option_data2 = 0x00, is the data which will set to the power manage chip + exec_cmd="i2ctransfer -y $i2c_bus w${write_byte}@${chip_slave} $2 ${option_data2}" + pmbus_res=`$exec_cmd` + reset_pca9548 $i2c_bus $pca9548_slave + fmt_print "console" $INFO "$option_data ,Command Code:$2, Setting Data:${option_data2}" + fmt_print "log" $INFO "[PMBUS] Set Command : $exec_cmd" } # Do pmbus test if plugin avalible @@ -1568,9 +1590,10 @@ start_get_sensor(){ "pmbus") process_pmbus ;; - "reserve") - handle_reserve - ;; + # reserve function is temporarily retained for future functional expansion + # "reserve") + # handle_reserve + # ;; *) fmt_print "console" $ERROR "Unsupport Sensor Type !!! - $sensor_type" fmt_print "console" $INFO "Support list: $Support_Sensor_List" diff --git a/project.config b/project.config new file mode 100644 index 0000000..d5150e6 --- /dev/null +++ b/project.config @@ -0,0 +1,56 @@ +# ADC128 Division factor +votage_division_factor_0="1" +votage_division_factor_1="1" +votage_division_factor_2="1" +votage_division_factor_3="0.8" +votage_division_factor_4="0.6" +votage_division_factor_5="0.6" +votage_division_factor_6="0.2326" +votage_division_factor_7="1" + +# ADC128 channel name +ADC128_Channel0_name="Channel0" +ADC128_Channel1_name="Channel1" +ADC128_Channel2_name="Channel2" +ADC128_Channel3_name="Channel3" +ADC128_Channel4_name="Channel4" +ADC128_Channel5_name="Channel5" +ADC128_Channel6_name="Channel6" +ADC128_Channel7_name="Channel7" + +# INA3221 shunt resistor(unit: mohm) +shunt_resistor_0="2" +shunt_resistor_1="2" +shunt_resistor_2="5" + +# INA3221 channel name +INA3221_Channel0_name="Channel0" +INA3221_Channel1_name="Channel1" +INA3221_Channel2_name="Channel2" + +# EMC1413 channel name +EMC1413_Channel0_name="Channel0" +EMC1413_Channel1_name="Channel1" +EMC1413_Channel2_name="Channel2" + +# TMP468 channel name +TMP468_Channel0_name="Local" +TMP468_Channel1_name="Remote1" +TMP468_Channel2_name="Remote2" +TMP468_Channel3_name="Remote3" +TMP468_Channel4_name="Remote4" +TMP468_Channel5_name="Remote5" +TMP468_Channel6_name="Remote6" +TMP468_Channel7_name="Remote7" +TMP468_Channel8_name="Remote8" + +# TMP112 sensor name +TMP112_Sensor_name="Temperature" + +# INA226 channel name +INA226_Channel0_name="Channel0" + +# LM95241 channel name +LM95241_Local_name="Local" +LM95241_Remote1_name="Remote1" +LM95241_Remote2_name="Remote2" \ No newline at end of file diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..c51a3fa --- /dev/null +++ b/setup.sh @@ -0,0 +1,57 @@ +#!/bin/sh + +# Script Description: +# This script is used to auto setup the nicsensor tool and its extensions. + +SCRIPT_VERSION="1.0.0" +SUPPORT_TOOL_VERSION="1.11" + +# Default values +source_extension_dir="./extension" +destination_tool_dir="/extlog/nicsensor" +destination_extension_dir="/extlog/nicsensor/extension" +exec_path="/extlog/nicsensor/nicsensor.sh" + +# PRINT SCRIPT INFO +echo "=== Nicsensor Quick Setup Script! ===" +echo "Setup Tool Version : $SCRIPT_VERSION" +echo "Support nicsensor tool Version : $SUPPORT_TOOL_VERSION" + +# Check if the destination extension directory exists, if not, create it +if [ ! -d "$destination_extension_dir" ]; then + echo "Step 0 : Create directory $destination_extension_dir" + mkdir -p "$destination_extension_dir" +fi + +# Get script Path +script_dir=$(pwd) +source_extension_dir="$script_dir/extension" + +# check if the source extension directory exists, if not, exit +if [ ! -d "$source_extension_dir" ]; then + echo "Error : Source extension directory $source_extension_dir does not exist" + exit 1 +fi + +# copy the extension files to the destination directory +echo "Step 1 : Copy extension files to $destination_extension_dir" +cp -rf "$source_extension_dir"/* "$destination_extension_dir" + +# Add execute permission for extension files +echo "Step 2 : Add execute permission for extension files" +chmod +x "$destination_extension_dir"/* + +# copy the project config to the destination directory +echo "Step 3 : Copy project.config to $destination_tool_dir" +cp -f "./project.config" "$destination_tool_dir" + +# copy the exec file to the destination directory +echo "Step 4 : Copy nicsensor to $exec_path" +cp -f "./nicsensor.sh" "$exec_path" + +# Add execute permission for exec file +echo "Step 5 : Add execute permission for nicsensor" +chmod +x "$exec_path" + + +echo "Complete auto setup nicsensor tool and its extensions." diff --git a/nicsensor_v2/autoauth.sh b/tool/nicsensor_v2/autoauth.sh similarity index 100% rename from nicsensor_v2/autoauth.sh rename to tool/nicsensor_v2/autoauth.sh diff --git a/nicsensor_v2/format_print.sh b/tool/nicsensor_v2/format_print.sh similarity index 100% rename from nicsensor_v2/format_print.sh rename to tool/nicsensor_v2/format_print.sh diff --git a/nicsensor_v2/i2c_m6.sh b/tool/nicsensor_v2/i2c_m6.sh similarity index 100% rename from nicsensor_v2/i2c_m6.sh rename to tool/nicsensor_v2/i2c_m6.sh diff --git a/nicsensor_v2/i2c_m7.sh b/tool/nicsensor_v2/i2c_m7.sh similarity index 100% rename from nicsensor_v2/i2c_m7.sh rename to tool/nicsensor_v2/i2c_m7.sh diff --git a/nicsensor_v2/nicsensor.sh b/tool/nicsensor_v2/nicsensor.sh similarity index 100% rename from nicsensor_v2/nicsensor.sh rename to tool/nicsensor_v2/nicsensor.sh diff --git a/nicsensor_v2/platform_5280m7.sh b/tool/nicsensor_v2/platform_5280m7.sh similarity index 100% rename from nicsensor_v2/platform_5280m7.sh rename to tool/nicsensor_v2/platform_5280m7.sh diff --git a/nicsensor_v2/platform_5688m7.sh b/tool/nicsensor_v2/platform_5688m7.sh similarity index 100% rename from nicsensor_v2/platform_5688m7.sh rename to tool/nicsensor_v2/platform_5688m7.sh diff --git a/nicsensor_v2/plugin_adc128.sh b/tool/nicsensor_v2/plugin_adc128.sh similarity index 100% rename from nicsensor_v2/plugin_adc128.sh rename to tool/nicsensor_v2/plugin_adc128.sh diff --git a/nicsensor_v2/plugin_emc1413.sh b/tool/nicsensor_v2/plugin_emc1413.sh similarity index 100% rename from nicsensor_v2/plugin_emc1413.sh rename to tool/nicsensor_v2/plugin_emc1413.sh diff --git a/nicsensor_v2/plugin_ina3221.sh b/tool/nicsensor_v2/plugin_ina3221.sh similarity index 100% rename from nicsensor_v2/plugin_ina3221.sh rename to tool/nicsensor_v2/plugin_ina3221.sh diff --git a/nicsensor_v2/plugin_tmp112.sh b/tool/nicsensor_v2/plugin_tmp112.sh similarity index 100% rename from nicsensor_v2/plugin_tmp112.sh rename to tool/nicsensor_v2/plugin_tmp112.sh diff --git a/nicsensor_v2/plugin_tmp468.sh b/tool/nicsensor_v2/plugin_tmp468.sh similarity index 100% rename from nicsensor_v2/plugin_tmp468.sh rename to tool/nicsensor_v2/plugin_tmp468.sh diff --git a/nicsensor_v2/readme.md b/tool/nicsensor_v2/readme.md similarity index 100% rename from nicsensor_v2/readme.md rename to tool/nicsensor_v2/readme.md diff --git a/test_plugin/check_threhold.sh b/tool/test/check_threhold.sh similarity index 100% rename from test_plugin/check_threhold.sh rename to tool/test/check_threhold.sh diff --git a/test_plugin/readme.md b/tool/test/readme.md similarity index 100% rename from test_plugin/readme.md rename to tool/test/readme.md