package/autocore: fix WiFi temp display

Fixed an issue where the home page WIFI temperature would completely disappear (awk operation error) after turning off any WIFI route.
This commit is contained in:
VIKING 2024-10-19 12:39:46 +08:00
parent e8c765190d
commit 907dd78fc1

View File

@ -7,25 +7,25 @@ THERMAL_PATH="/sys/class/thermal"
case "$DISTRIB_TARGET" in
ipq40xx/*|ipq806x/*)
wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/phy*/device/hwmon/hwmon*/temp1_input 2>"/dev/null" | awk '$1=$1')"
wifi_temp="$(cat "$IEEE_PATH"/phy*/device/hwmon/hwmon*/temp1_input 2>"/dev/null" | awk '{printf("%.1f°C ", $0 / 1000)}' | awk '$1=$1')"
;;
mediatek/mt7622)
wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/wl*/hwmon*/temp1_input 2>"/dev/null" | awk '$1=$1')"
wifi_temp="$(cat "$IEEE_PATH"/wl*/hwmon*/temp1_input 2>"/dev/null" | awk '{printf("%.1f°C ", $0 / 1000)}' | awk '$1=$1')"
;;
*)
wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/phy*/hwmon*/temp1_input 2>"/dev/null" | awk '$1=$1')"
wifi_temp="$(cat "$IEEE_PATH"/phy*/hwmon*/temp1_input 2>"/dev/null" | awk '{printf("%.1f°C ", $0 / 1000)}' | awk '$1=$1')"
;;
esac
case "$DISTRIB_TARGET" in
ipq40xx/*)
if [ -e "$IEEE_PATH/phy0/hwmon0/temp1_input" ]; then
mt76_temp="$(awk -F ': ' '{print $2}' "$IEEE_PATH/phy0/hwmon0/temp1_input" 2>"/dev/null")°C"
mt76_temp="$(cat "$IEEE_PATH"/phy0/hwmon0/temp1_input 2>"/dev/null" | awk -F ': ' '{print $2}')°C"
fi
[ -z "$mt76_temp" ] || wifi_temp="${wifi_temp:+$wifi_temp }$mt76_temp"
;;
*)
cpu_temp="$(awk '{printf("%.1f°C", $0 / 1000)}' "$THERMAL_PATH/thermal_zone0/temp" 2>"/dev/null")"
cpu_temp="$(cat "$THERMAL_PATH"/thermal_zone0/temp 2>"/dev/null" | awk '{printf("%.1f°C", $0 / 1000)}')"
;;
esac