feat(master : nicsensor)添加功能: 根据boardid自动匹配服务器型号

This commit is contained in:
leimingsheng 2025-06-20 15:39:03 +08:00
parent 1e2f32dce3
commit 6eacac1f1a

@ -59,7 +59,7 @@ fru_offset="0x00 0x00"
Support_Sensor_List="emc1413, adc128, ina3221, tmp468, tmp112" Support_Sensor_List="emc1413, adc128, ina3221, tmp468, tmp112"
Support_Server_List="5280m7, 5468m7, 5688m7, donghu, yichun, qiandaohu" Support_Server_List="5280m7, 5468m7, 5688m7, donghu, yichun, qiandaohu"
# Which server will use this script # Which server will use this script
server_type="5280m7" server_type="default"
# --------------------------------------------------------- # ---------------------------------------------------------
# Common Varible (Don't Change) # Common Varible (Don't Change)
@ -264,6 +264,30 @@ parse_nic_slot(){
format_log_print $INFO "Slot Num : $slot_number" format_log_print $INFO "Slot Num : $slot_number"
} }
# According to boardid, parse server_type
try_get_server_type(){
if [ -e "/tmp/ns_servertype" ];then
server_type=`cat /tmp/ns_servertype`
else
boardid=`cat /proc/cmdline | awk -F'=' '/boardid=/{print $8; exit}'`
if [ $boardid -eq 130 ];then
server_type="5280m7"
elif [ $boardid -eq 150 ];then
server_type="5468m7"
elif [ $boardid -eq 152 ];then
server_type="5688m7"
else
format_print $ERROR "Invalid boardid value: $boardid"
format_print $ERROR "Can't specify server type by general method"
format_print $INFO "Please modify server_type in script manually!"
exit 1
fi
echo $server_type > /tmp/ns_servertype
fi
}
init_debuglog(){ init_debuglog(){
# only save one running log # only save one running log
if [ -e $log ];then if [ -e $log ];then
@ -343,6 +367,11 @@ switch_pca9548_channel(){
pre_exec_hook(){ pre_exec_hook(){
init_debuglog init_debuglog
# check server_type if is default
if [ "$server_type" = "default" ];then
try_get_server_type
fi
# is param legel? # is param legel?
if [ "$sensor_type" = "chip" ];then if [ "$sensor_type" = "chip" ];then
if [ $param_num -le 3 ];then if [ $param_num -le 3 ];then