add ethinfo script

Signed-off-by: sbwml <admin@cooluc.com>
This commit is contained in:
sbwml 2024-12-10 23:28:12 +08:00
parent 7922aec3a0
commit 9d4f357904
2 changed files with 24 additions and 0 deletions

View File

@ -46,6 +46,7 @@ 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/

23
files/generic/ethinfo Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/lua
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
eth_info[#eth_info + 1] = {
device = ifname
}
end
end
table.sort(
eth_info,
function(a, b)
return a.device < b.device
end
)
print(jsonc.stringify(eth_info))