George Hung | a0ae66a | 2020-06-30 10:47:30 +0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | MARGIN_TABLE_FILE="/usr/share/read-margin-temp/config-margin.json" |
| 4 | |
| 5 | target_num="$(cat $MARGIN_TABLE_FILE | grep '"target"' | wc -l)" |
| 6 | |
| 7 | cpu_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 |
| 10 | if [[ "$cpu_hwmon" != "" ]] |
| 11 | then |
| 12 | sed -i "s/cpu_hwmon/$cpu_hwmon/g" $MARGIN_TABLE_FILE |
| 13 | fi |
| 14 | |
| 15 | # wait target dbus |
| 16 | for ((i=0; i<$target_num; i++)) |
| 17 | do |
| 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 |
| 21 | done |
| 22 | |
George Hung | 027c055 | 2021-03-08 16:45:06 +0800 | [diff] [blame] | 23 | nvmePath="/xyz/openbmc_project/sensors/temperature/nvme" |
| 24 | nvmeInventoryPath="/xyz/openbmc_project/inventory/system/chassis/motherboard/nvme" |
| 25 | # Get and Set WCTEMP |
| 26 | for ((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 |
| 46 | done |
| 47 | |
George Hung | a0ae66a | 2020-06-30 10:47:30 +0800 | [diff] [blame] | 48 | # start read margin temp |
| 49 | /usr/bin/read-margin-temp & |
| 50 | |
| 51 | exit 0 |