diff --git a/package/lean/autocore/Makefile b/package/lean/autocore/Makefile index d0b460558..643e203e9 100644 --- a/package/lean/autocore/Makefile +++ b/package/lean/autocore/Makefile @@ -43,11 +43,15 @@ define Package/autocore-arm/install $(INSTALL_DIR) $(1)/etc $(INSTALL_DATA) ./files/arm/index.htm $(1)/etc/index.htm $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_BIN) ./files/60-autocore-reload-rpcd $(1)/etc/uci-defaults/ $(INSTALL_BIN) ./files/arm/090-cover-index_htm $(1)/etc/uci-defaults/ $(INSTALL_DIR) $(1)/sbin $(INSTALL_BIN) ./files/arm/sbin/cpuinfo $(1)/sbin/cpuinfo $(INSTALL_BIN) ./files/arm/sbin/ethinfo $(1)/sbin/ethinfo $(INSTALL_BIN) ./files/arm/sbin/usage $(1)/sbin/usage + $(INSTALL_BIN) ./files/arm/tempinfo $(1)/sbin/tempinfo + $(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d + $(CP) ./files/luci-mod-status-autocore.json $(1)/usr/share/rpcd/acl.d/ endef define Package/autocore-x86/install @@ -55,8 +59,12 @@ define Package/autocore-x86/install $(INSTALL_BIN) ./files/x86/autocore $(1)/etc/init.d/autocore $(INSTALL_DIR) $(1)/etc $(INSTALL_DATA) ./files/x86/index.htm $(1)/etc/index.htm + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_BIN) ./files/60-autocore-reload-rpcd $(1)/etc/uci-defaults/ $(INSTALL_DIR) $(1)/sbin $(CP) ./files/x86/sbin/* $(1)/sbin + $(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d + $(CP) ./files/luci-mod-status-autocore.json $(1)/usr/share/rpcd/acl.d/ endef $(eval $(call BuildPackage,autocore-arm)) diff --git a/package/lean/autocore/files/60-autocore-reload-rpcd b/package/lean/autocore/files/60-autocore-reload-rpcd new file mode 100755 index 000000000..75e8178bb --- /dev/null +++ b/package/lean/autocore/files/60-autocore-reload-rpcd @@ -0,0 +1,5 @@ +#!/bin/sh + +/etc/init.d/rpcd restart + +exit 0 diff --git a/package/lean/autocore/files/arm/sbin/tempinfo b/package/lean/autocore/files/arm/sbin/tempinfo new file mode 100755 index 000000000..c9fbd6d34 --- /dev/null +++ b/package/lean/autocore/files/arm/sbin/tempinfo @@ -0,0 +1,40 @@ +#!/bin/sh + +. /etc/openwrt_release + +IEEE_PATH="/sys/class/ieee80211" +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')" + ;; +mediatek/mt7622) + wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/wl*/hwmon*/temp1_input 2>"/dev/null" | awk '$1=$1')" + ;; +*) + wifi_temp="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/phy*/hwmon*/temp1_input 2>"/dev/null" | 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" + 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")" + ;; +esac + +if [ -n "$cpu_temp" ] && [ -z "$wifi_temp" ]; then + echo -n "CPU: $cpu_temp" +elif [ -z "$cpu_temp" ] && [ -n "$wifi_temp" ]; then + echo -n "WiFi: $wifi_temp" +elif [ -n "$cpu_temp" ] && [ -n "$wifi_temp" ]; then + echo -n "CPU: $cpu_temp, WiFi: $wifi_temp" +else + echo -n "No temperature info" +fi diff --git a/package/lean/autocore/files/luci-mod-status-autocore.json b/package/lean/autocore/files/luci-mod-status-autocore.json new file mode 100644 index 000000000..5e2330a2d --- /dev/null +++ b/package/lean/autocore/files/luci-mod-status-autocore.json @@ -0,0 +1,10 @@ +{ + "luci-mod-status-autocore": { + "description": "Grant access to autocore", + "read": { + "ubus": { + "luci": [ "getCPUInfo", "getTempInfo" ] + } + } + } +}