diff --git a/package/emortal/autocore/Makefile b/package/emortal/autocore/Makefile index 09f9deab10..606a043cc4 100644 --- a/package/emortal/autocore/Makefile +++ b/package/emortal/autocore/Makefile @@ -36,10 +36,8 @@ endef define Package/autocore/install/Default $(INSTALL_DIR) $(1)/etc - $(CP) ./files/generic/rpcd_10_system.js $(1)/etc/ - $(CP) ./files/generic/rpcd_21_ethinfo.js $(1)/etc/ - $(CP) ./files/generic/rpcd_luci $(1)/etc/ - $(CP) ./files/generic/rpcd_luci-mod-status.json $(1)/etc/ + $(CP) ./files/generic/10_system.js $(1)/etc/rpcd_10_system.js + $(CP) ./files/generic/luci $(1)/etc/rpcd_luci $(INSTALL_DIR) $(1)/etc/uci-defaults $(INSTALL_BIN) ./files/generic/090-cover-index_files $(1)/etc/uci-defaults/ @@ -47,6 +45,12 @@ define Package/autocore/install/Default $(INSTALL_DIR) $(1)/sbin $(INSTALL_BIN) ./files/generic/cpuinfo $(1)/sbin/ $(INSTALL_BIN) ./files/generic/ethinfo $(1)/sbin/ + + $(INSTALL_DIR) $(1)/usr/share/rpcd/acl.d + $(CP) ./files/generic/luci-mod-status-autocore.json $(1)/usr/share/rpcd/acl.d/ + + $(INSTALL_DIR) $(1)/www/luci-static/resources/view/status/include + $(INSTALL_DATA) ./files/generic/21_ethinfo.js $(1)/www/luci-static/resources/view/status/include/ endef define Package/autocore-arm/install @@ -54,7 +58,7 @@ define Package/autocore-arm/install endef define Package/autocore-x86/install - $(call Package/autocore/install/Default) + $(call Package/autocore/install/Default,$(1)) $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) ./files/x86/autocore $(1)/etc/init.d/ diff --git a/package/emortal/autocore/files/generic/090-cover-index_files b/package/emortal/autocore/files/generic/090-cover-index_files index 9d0afd2df0..8480059434 100755 --- a/package/emortal/autocore/files/generic/090-cover-index_files +++ b/package/emortal/autocore/files/generic/090-cover-index_files @@ -2,12 +2,8 @@ [ ! -f '/etc/rpcd_10_system.js' ] || \ mv -f '/etc/rpcd_10_system.js' '/www/luci-static/resources/view/status/include/10_system.js' -[ ! -f '/etc/rpcd_21_ethinfo.js' ] || \ - mv -f '/etc/rpcd_21_ethinfo.js' '/www/luci-static/resources/view/status/include/21_ethinfo.js' [ ! -f '/etc/rpcd_luci' ] || \ mv -f '/etc/rpcd_luci' '/usr/libexec/rpcd/luci' -[ ! -f '/etc/rpcd_luci-mod-status.json' ] || \ - mv -f '/etc/rpcd_luci-mod-status.json' '/usr/share/rpcd/acl.d/luci-mod-status.json' /etc/init.d/rpcd restart exit 0 diff --git a/package/emortal/autocore/files/generic/rpcd_10_system.js b/package/emortal/autocore/files/generic/10_system.js similarity index 94% rename from package/emortal/autocore/files/generic/rpcd_10_system.js rename to package/emortal/autocore/files/generic/10_system.js index 729a648885..c4978ea7fc 100644 --- a/package/emortal/autocore/files/generic/rpcd_10_system.js +++ b/package/emortal/autocore/files/generic/10_system.js @@ -73,8 +73,8 @@ return baseclass.extend({ var fields = [ _('Hostname'), boardinfo.hostname, - _('Model'), boardinfo.model + cpubench.cpubench, - _('Architecture'), cpuinfo.cpuinfo, + _('Model'), boardinfo.model + cpubench, + _('Architecture'), cpuinfo, _('Target Platform'), (L.isObject(boardinfo.release) ? boardinfo.release.target : ''), _('Firmware Version'), (L.isObject(boardinfo.release) ? boardinfo.release.description + ' / ' : '') + (luciversion || ''), _('Kernel Version'), boardinfo.kernel, @@ -85,7 +85,7 @@ return baseclass.extend({ systeminfo.load[1] / 65535.0, systeminfo.load[2] / 65535.0 ) : null, - _('CPU usage (%)'), cpuusage.cpuusage + _('CPU usage (%)'), cpuusage ]; var table = E('table', { 'class': 'table' }); diff --git a/package/emortal/autocore/files/generic/rpcd_21_ethinfo.js b/package/emortal/autocore/files/generic/21_ethinfo.js similarity index 98% rename from package/emortal/autocore/files/generic/rpcd_21_ethinfo.js rename to package/emortal/autocore/files/generic/21_ethinfo.js index a16054822c..fa89c4a2fc 100644 --- a/package/emortal/autocore/files/generic/rpcd_21_ethinfo.js +++ b/package/emortal/autocore/files/generic/21_ethinfo.js @@ -1,4 +1,5 @@ 'use strict'; +'require baseclass'; 'require rpc'; var callLuciETHInfo = rpc.declare({ diff --git a/package/emortal/autocore/files/generic/rpcd_luci b/package/emortal/autocore/files/generic/luci similarity index 97% rename from package/emortal/autocore/files/generic/rpcd_luci rename to package/emortal/autocore/files/generic/luci index ca0cbf1523..bf98824248 100755 --- a/package/emortal/autocore/files/generic/rpcd_luci +++ b/package/emortal/autocore/files/generic/luci @@ -623,9 +623,8 @@ local methods = { getCPUBench = { call = function() local sys = require "luci.sys" - local cpubench = {} + local cpubench = sys.exec("cat /etc/bench.log 2>/dev/null") or "" - cpubench.cpubench = sys.exec("cat /etc/bench.log 2>/dev/null") return cpubench end }, @@ -633,12 +632,10 @@ local methods = { getCPUInfo = { call = function() local sys = require "luci.sys" - local cpuinfo = {} + local cpuinfo = sys.exec("/sbin/cpuinfo") - cpuinfo.cpuinfo = sys.exec("/sbin/cpuinfo") - - if (cpuinfo.cpuinfo == nil) or (cpuinfo.cpuinfo == "") then - cpuinfo.cpuinfo = "2.33 MHz +2.33 C" + if (cpuinfo == nil) or (cpuinfo == "") then + cpuinfo.cpuinfo = "? x ? (2.33MHz, 2.33°C)" end return cpuinfo @@ -648,9 +645,8 @@ local methods = { getCPUUsage = { call = function() local sys = require "luci.sys" - local cpuusage = {} + local cpuusage = sys.exec("top -n1 | awk '/^CPU/ {printf(\"%d%\", 100 - $8)}'") or "6%" - cpuusage.cpuusage = sys.exec("top -n1 | awk '/^CPU/ {printf(\"%d%\", 100 - $8)}'") or "6%" return cpuusage end }, diff --git a/package/emortal/autocore/files/generic/luci-mod-status-autocore.json b/package/emortal/autocore/files/generic/luci-mod-status-autocore.json new file mode 100644 index 0000000000..c9b930e1da --- /dev/null +++ b/package/emortal/autocore/files/generic/luci-mod-status-autocore.json @@ -0,0 +1,10 @@ +{ + "luci-mod-status-autocore": { + "description": "Grant access to autocore", + "read": { + "ubus": { + "luci": [ "getCPUInfo", "getETHInfo", "getTempInfo" ] + } + } + } +} diff --git a/package/emortal/autocore/files/generic/rpcd_luci-mod-status.json b/package/emortal/autocore/files/generic/rpcd_luci-mod-status.json deleted file mode 100644 index 523ce1723d..0000000000 --- a/package/emortal/autocore/files/generic/rpcd_luci-mod-status.json +++ /dev/null @@ -1,146 +0,0 @@ -{ - "luci-mod-status-realtime": { - "description": "Grant access to realtime statistics", - "read": { - "ubus": { - "luci": [ "getConntrackList", "getRealtimeStats", "getCPUBench", "getCPUInfo", "getCPUUsage", "getETHInfo", "getOnlineUsers" ], - "network.rrdns": [ "lookup" ] - } - } - }, - - "luci-mod-status-processes": { - "description": "Grant access to process status", - "read": { - "ubus": { - "luci": [ "getProcessList" ] - } - }, - "write": { - "file": { - "/bin/kill": [ "exec" ] - }, - "ubus": { - "file": [ "exec" ] - } - } - }, - - "luci-mod-status-logs": { - "description": "Grant access to system logs", - "read": { - "cgi-io": [ "exec" ], - "file": { - "/bin/dmesg -r": [ "exec" ], - "/sbin/logread": [ "stat" ], - "/sbin/logread -e ^": [ "exec" ], - "/usr/sbin/logread": [ "stat" ], - "/usr/sbin/logread -e ^": [ "exec" ] - }, - "ubus": { - "file": [ "stat" ] - } - } - }, - - "luci-mod-status-routes": { - "description": "Grant access to routing status", - "read": { - "file": { - "/sbin/ip -[46] neigh show": [ "exec" ], - "/sbin/ip -[46] route show table all": [ "exec" ], - "/sbin/ip -[46] rule show": [ "exec" ] - }, - "ubus": { - "file": [ "exec" ] - } - } - }, - - "luci-mod-status-channel_analysis": { - "description": "Grant access to wireless channel status", - "read": { - "ubus": { - "iwinfo": [ "info", "freqlist" ] - } - } - }, - - "luci-mod-status-firewall": { - "description": "Grant access to firewall status", - "read": { - "cgi-io": [ "exec" ], - "file": { - "/usr/sbin/nft --json list ruleset": [ "exec" ], - "/usr/sbin/iptables --line-numbers -w -nvxL -t *": [ "exec" ], - "/usr/sbin/ip6tables --line-numbers -w -nvxL -t *": [ "exec" ], - "/usr/sbin/ip6tables": [ "list" ] - }, - "ubus": { - "file": [ "stat" ] - } - }, - "write": { - "cgi-io": [ "exec" ], - "file": { - "/etc/init.d/firewall restart": [ "exec" ], - "/usr/sbin/iptables -Z": [ "exec" ], - "/usr/sbin/ip6tables -Z": [ "exec" ] - }, - "ubus": { - "file": [ "exec" ] - } - } - }, - - "luci-mod-status-index": { - "description": "Grant access to main status display", - "read": { - "file": { - "/proc/sys/net/netfilter/nf_conntrack_count": [ "read" ], - "/proc/sys/net/netfilter/nf_conntrack_max": [ "read" ], - "/usr/lib/lua/luci/version.lua": [ "read" ], - "/www/luci-static/resources/view/status/include": [ "list" ] - }, - "ubus": { - "file": [ "list", "read" ], - "system": [ "board", "info" ] - } - }, - "write": { - "uci": [ "dhcp" ] - } - }, - - "luci-mod-status-index-dhcp": { - "description": "Grant access to DHCP status display", - "read": { - "ubus": { - "luci-rpc": [ "getDHCPLeases" ] - } - } - }, - - "luci-mod-status-index-dsl": { - "description": "Grant access to DSL status display", - "read": { - "ubus": { - "dsl": [ "metrics" ] - } - } - }, - - "luci-mod-status-index-wifi": { - "description": "Grant access to wireless status display", - "read": { - "ubus": { - "iwinfo": [ "assoclist" ] - } - }, - "write": { - "ubus": { - "hostapd.*": [ "del_client", "wps_start", "wps_cancel", "wps_status" ] - } - } - } -}