blob: d0cb2f6325904546f9df2d5ae9bcc4b65fe773f7 [file] [log] [blame]
George Hunga0ae66a2020-06-30 10:47:30 +08001#!/bin/bash
2
3MARGIN_TABLE_FILE="/usr/share/read-margin-temp/config-margin.json"
4
5target_num="$(cat $MARGIN_TABLE_FILE | grep '"target"' | wc -l)"
6
7cpu_hwmon="$(ls -la /sys/class/hwmon | grep f0082000 | head -n 1 | tail -n +1 | cut -d '/' -f 11)"
8
9# replace by the real cpu temperature hwmon path in runtime
10if [[ "$cpu_hwmon" != "" ]]
11then
12 sed -i "s/cpu_hwmon/$cpu_hwmon/g" $MARGIN_TABLE_FILE
13fi
14
15# wait target dbus
16for ((i=0; i<$target_num; i++))
17do
18 line_num=$((i+1))
19 path="$(cat $MARGIN_TABLE_FILE | grep '"target"' | head -n ${line_num} | tail -n +${line_num} | cut -d '"' -f 4)"
20 mapper wait $path
21done
22
George Hung027c0552021-03-08 16:45:06 +080023nvmePath="/xyz/openbmc_project/sensors/temperature/nvme"
24nvmeInventoryPath="/xyz/openbmc_project/inventory/system/chassis/motherboard/nvme"
25# Get and Set WCTEMP
26for ((i = 0; i < 16; i++)); do
27 name=WCTemp$(printf "%02d" $i)
28 wcTemp=72000
29 presentState=$(busctl get-property \
30 xyz.openbmc_project.Inventory.Manager \
31 ${nvmeInventoryPath}${i} \
32 xyz.openbmc_project.Inventory.Item \
33 Present | awk '{print $2}')
34
35 if [[ $presentState == "true" ]]; then
36 wcTemp=$(
37 busctl get-property xyz.openbmc_project.nvme.manager \
38 ${nvmePath}${i} \
39 xyz.openbmc_project.Sensor.Threshold.Critical \
40 CriticalHigh | awk '{print $2}'
41 )
42 wcTemp=$((wcTemp * 1000))
43 fi
44
45 sed -i "s/$name/${wcTemp}/g" $MARGIN_TABLE_FILE
46done
47
George Hunga0ae66a2020-06-30 10:47:30 +080048# start read margin temp
49/usr/bin/read-margin-temp &
50
51exit 0