autocore: minor cleanup

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
(cherry picked from commit 42e2aaf2b30fa6a5f3b8357a103712faef81814e)
This commit is contained in:
Tianling Shen 2022-03-26 19:01:32 +08:00
parent 8bb9ae62d6
commit 543c8e7a28
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
7 changed files with 28 additions and 165 deletions

View File

@ -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/

View File

@ -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

View File

@ -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' });

View File

@ -1,4 +1,5 @@
'use strict';
'require baseclass';
'require rpc';
var callLuciETHInfo = rpc.declare({

View File

@ -618,9 +618,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
},
@ -628,12 +627,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
@ -643,9 +640,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
},

View File

@ -0,0 +1,10 @@
{
"luci-mod-status-autocore": {
"description": "Grant access to autocore",
"read": {
"ubus": {
"luci": [ "getCPUInfo", "getETHInfo", "getTempInfo" ]
}
}
}
}

View File

@ -1,144 +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 the system route status",
"read": {
"file": {
"/sbin/ip -[46] neigh show": [ "exec" ],
"/sbin/ip -[46] route show table all": [ "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/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" ]
}
}
}
}