From d08db68df216b789619c6f68b59b9bc953baa56f Mon Sep 17 00:00:00 2001 From: sbwml Date: Tue, 8 Oct 2024 10:17:55 +0800 Subject: [PATCH] remove ethinfo Signed-off-by: sbwml --- Makefile | 4 -- files/generic/29_ethinfo.js | 60 --------------------- files/generic/ethinfo | 49 ----------------- files/generic/luci | 20 ------- files/generic/luci-mod-status-autocore.json | 2 +- 5 files changed, 1 insertion(+), 134 deletions(-) delete mode 100644 files/generic/29_ethinfo.js delete mode 100755 files/generic/ethinfo diff --git a/Makefile b/Makefile index 1a9cf59..ea6e919 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/files/generic/29_ethinfo.js b/files/generic/29_ethinfo.js deleted file mode 100644 index fa89c4a..0000000 --- a/files/generic/29_ethinfo.js +++ /dev/null @@ -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 - ]); - } -}); diff --git a/files/generic/ethinfo b/files/generic/ethinfo deleted file mode 100755 index 7ff7a59..0000000 --- a/files/generic/ethinfo +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/lua --- Copyright (C) 2022 Tianling Shen - -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)) diff --git a/files/generic/luci b/files/generic/luci index 5036dea..4bc5a8d 100755 --- a/files/generic/luci +++ b/files/generic/luci @@ -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')) diff --git a/files/generic/luci-mod-status-autocore.json b/files/generic/luci-mod-status-autocore.json index 4e496d8..8bd4b92 100644 --- a/files/generic/luci-mod-status-autocore.json +++ b/files/generic/luci-mod-status-autocore.json @@ -3,7 +3,7 @@ "description": "Grant access to autocore", "read": { "ubus": { - "luci": [ "getCPUInfo", "getETHInfo", "getTempInfo", "getCPUBench", "getCPUUsage", "getOnlineUsers" ] + "luci": [ "getCPUInfo", "getTempInfo", "getCPUBench", "getCPUUsage", "getOnlineUsers" ] } } }