mirror of
https://github.com/hanwckf/immortalwrt-mt798x.git
synced 2025-01-09 02:43:53 +08:00
autocore: reduce grep call
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org> (cherry picked from commit 7897839f5157a611d04063a111fc9f70995461bc)
This commit is contained in:
parent
be0d1b2827
commit
c771bf9891
@ -3,10 +3,6 @@
|
|||||||
IEEE_PATH="/sys/class/ieee80211"
|
IEEE_PATH="/sys/class/ieee80211"
|
||||||
THERMAL_PATH="/sys/class/thermal"
|
THERMAL_PATH="/sys/class/thermal"
|
||||||
|
|
||||||
if [ -e "$IEEE_PATH/phy0/hwmon0/temp1_input" ]; then
|
|
||||||
mt76_temp=" $(awk -F ': ' '{print $2}' "$IEEE_PATH/phy0/hwmon0/temp1_input")°C"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if grep -Eq "ipq40xx|ipq806x" "/etc/openwrt_release"; then
|
if grep -Eq "ipq40xx|ipq806x" "/etc/openwrt_release"; then
|
||||||
wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/phy*/device/hwmon/hwmon*/temp1_input | awk '$1=$1')"
|
wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/phy*/device/hwmon/hwmon*/temp1_input | awk '$1=$1')"
|
||||||
else
|
else
|
||||||
@ -14,6 +10,10 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if grep -q "ipq40xx" "/etc/openwrt_release"; then
|
if grep -q "ipq40xx" "/etc/openwrt_release"; then
|
||||||
|
if [ -e "$IEEE_PATH/phy0/hwmon0/temp1_input" ]; then
|
||||||
|
mt76_temp=" $(awk -F ': ' '{print $2}' "$IEEE_PATH/phy0/hwmon0/temp1_input")°C"
|
||||||
|
fi
|
||||||
|
|
||||||
echo -n "WiFi:${mt76_temp} ${wifi_temp}"
|
echo -n "WiFi:${mt76_temp} ${wifi_temp}"
|
||||||
else
|
else
|
||||||
cpu_temp="$(awk '{printf("%.1f°C", $0 / 1000)}' "$THERMAL_PATH/thermal_zone0/temp")"
|
cpu_temp="$(awk '{printf("%.1f°C", $0 / 1000)}' "$THERMAL_PATH/thermal_zone0/temp")"
|
||||||
|
@ -6,7 +6,7 @@ CPUINFO_PATH="/proc/cpuinfo"
|
|||||||
CPUFREQ_PATH="/sys/devices/system/cpu/cpufreq"
|
CPUFREQ_PATH="/sys/devices/system/cpu/cpufreq"
|
||||||
THERMAL_PATH="/sys/class/thermal"
|
THERMAL_PATH="/sys/class/thermal"
|
||||||
|
|
||||||
cpu_arch="$(grep "model name" "$CPUINFO_PATH" | head -n1 | awk -F ': ' '{print $2}' | xargs)"
|
cpu_arch="$(awk -F ': ' '/model name/ {print $2}' "$CPUINFO_PATH" | head -n1)"
|
||||||
[ -n "${cpu_arch}" ] || cpu_arch="?"
|
[ -n "${cpu_arch}" ] || cpu_arch="?"
|
||||||
|
|
||||||
case "$DISTRIB_TARGET" in
|
case "$DISTRIB_TARGET" in
|
||||||
@ -22,9 +22,9 @@ case "$DISTRIB_TARGET" in
|
|||||||
"bcm53xx"/*)
|
"bcm53xx"/*)
|
||||||
cpu_freq="$(nvram get clkfreq | awk -F ',' '{print $1}')MHz" ;;
|
cpu_freq="$(nvram get clkfreq | awk -F ',' '{print $1}')MHz" ;;
|
||||||
"mvebu"/*)
|
"mvebu"/*)
|
||||||
cpu_freq="$(grep "BogoMIPS" "$CPUINFO_PATH" | sed -n "1p" | awk -F ': ' '{print $2}')MHz" ;;
|
cpu_freq="$(awk -F ': ' '/BogoMIPS/ {print $2}' "$CPUINFO_PATH" | head -n1)MHz" ;;
|
||||||
"x86"/*)
|
"x86"/*)
|
||||||
cpu_freq="$(grep "MHz" "$CPUINFO_PATH" | head -n1 | awk -F ': ' '{print $2}')MHz"
|
cpu_freq="$(awk -F ': ' '/MHz/ {print $2}' "$CPUINFO_PATH" | head -n1)MHz"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
[ ! -e "$CPUFREQ_PATH/policy0/cpuinfo_cur_freq" ] || \
|
[ ! -e "$CPUFREQ_PATH/policy0/cpuinfo_cur_freq" ] || \
|
||||||
@ -41,7 +41,7 @@ case "$DISTRIB_TARGET" in
|
|||||||
# Intel
|
# Intel
|
||||||
cpu_temp="$(sensors "coretemp-*" 2>"/dev/null" | grep -E "(Package id |Core )" | grep -Eo "\+[0-9.]*°C" | head -n1 | tr -d "+")"
|
cpu_temp="$(sensors "coretemp-*" 2>"/dev/null" | grep -E "(Package id |Core )" | grep -Eo "\+[0-9.]*°C" | head -n1 | tr -d "+")"
|
||||||
# AMD
|
# AMD
|
||||||
[ -n "${cpu_temp}" ] || cpu_temp="$(sensors "k*temp-*" 2>"/dev/null" | grep "Tdie" | head -n1 | awk '{print $2}' | tr -d "+")"
|
[ -n "${cpu_temp}" ] || cpu_temp="$(sensors "k*temp-*" 2>"/dev/null" | awk '/Tdie/ {print $2}' | head -n1 | tr -d "+")"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
[ ! -e "$THERMAL_PATH/thermal_zone0/temp" ] || \
|
[ ! -e "$THERMAL_PATH/thermal_zone0/temp" ] || \
|
||||||
|
@ -22,7 +22,7 @@ start() {
|
|||||||
uci set network.@globals[0].packet_steering="1"
|
uci set network.@globals[0].packet_steering="1"
|
||||||
uci commit network
|
uci commit network
|
||||||
|
|
||||||
for i in $(ip address | grep -E 'eth[0-9]+' | awk -F ': ' '{print $2}' | xargs)
|
for i in $(ip address | awk -F ': ' '/eth[0-9]+/ {print $2}' | xargs)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ethtool -K "$i" rx-checksum on
|
ethtool -K "$i" rx-checksum on
|
||||||
|
Loading…
x
Reference in New Issue
Block a user