remove ethinfo

Signed-off-by: sbwml <admin@cooluc.com>
This commit is contained in:
sbwml 2024-10-08 10:17:55 +08:00
parent 2371bd5c34
commit d08db68df2
5 changed files with 1 additions and 134 deletions

View File

@ -46,13 +46,9 @@ 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/29_ethinfo.js $(1)/www/luci-static/resources/view/status/include/
endef
define Package/autocore-arm/install

View File

@ -1,60 +0,0 @@
'use strict';
'require baseclass';
'require rpc';
var callLuciETHInfo = rpc.declare({
object: 'luci',
method: 'getETHInfo',
expect: { '': {} }
});
return L.Class.extend({
title: _('Ethernet Information'),
load: function() {
return Promise.all([
L.resolveDefault(callLuciETHInfo(), {})
]);
},
render: function(data) {
var ethinfo = Array.isArray(data[0].ethinfo) ? data[0].ethinfo : [];
var table = E('table', { 'class': 'table' }, [
E('tr', { 'class': 'tr table-titles' }, [
E('th', { 'class': 'th' }, _('Ethernet Name')),
E('th', { 'class': 'th' }, _('Link Status')),
E('th', { 'class': 'th' }, _('Speed')),
E('th', { 'class': 'th' }, _('Duplex'))
])
]);
cbi_update_table(table, ethinfo.map(function(info) {
var exp1;
var exp2;
if (info.status == "yes")
exp1 = _('Link Up');
else if (info.status == "no")
exp1 = _('Link Down');
if (info.duplex == "Full")
exp2 = _('Full Duplex');
else if (info.duplex == "Half")
exp2 = _('Half Duplex');
else
exp2 = _('-');
return [
info.name,
exp1,
info.speed,
exp2
];
}));
return E([
table
]);
}
});

View File

@ -1,49 +0,0 @@
#!/usr/bin/lua
-- Copyright (C) 2022 Tianling Shen <cnsztl@immortalwrt.org>
local util = require "luci.util"
local jsonc = require "luci.jsonc"
local eth_info = {}
local ifname, stat
for ifname, stat in pairs(util.ubus("network.device", "status")) do
if ifname:match("^(eth%d+)$") == ifname or ifname:match("^(usb%d+)$") or ifname:match("^(lan%d+)$") or ifname:match("wan") == ifname then
local status, speed, duplex
status = stat.carrier and "yes" or "no"
if status == "yes" and stat.speed == nil then
speed = "-"
elseif stat.speed == nil or stat.speed:sub(1, 1) == "-" then
speed = "-"
else
speed = stat.speed:sub(1, -2) .. "Mb/s"
end
if not stat.carrier then
duplex = "-"
elseif stat.speed == nil then
duplex = "-"
elseif stat.speed:sub(-1) == "F" then
duplex = "Full"
else
duplex = "Half"
end
eth_info[#eth_info + 1] = {
name = ifname,
status = status,
speed = speed,
duplex = duplex
}
end
end
table.sort(
eth_info,
function(a, b)
return a.name < b.name
end
)
print(jsonc.stringify(eth_info))

View File

@ -627,26 +627,6 @@ const methods = {
}
},
getETHInfo: {
call: function() {
if (!access('/sbin/ethinfo'))
return {};
const fd = popen('/sbin/ethinfo');
if (fd) {
let ethinfo = fd.read('all');
if (!ethinfo)
ethinfo = '{}';
ethinfo = json(ethinfo);
fd.close();
return { ethinfo: ethinfo };
} else {
return { ethinfo: error() };
}
}
},
getTempInfo: {
call: function() {
if (!access('/sbin/tempinfo'))

View File

@ -3,7 +3,7 @@
"description": "Grant access to autocore",
"read": {
"ubus": {
"luci": [ "getCPUInfo", "getETHInfo", "getTempInfo", "getCPUBench", "getCPUUsage", "getOnlineUsers" ]
"luci": [ "getCPUInfo", "getTempInfo", "getCPUBench", "getCPUUsage", "getOnlineUsers" ]
}
}
}