sbwml 9d4f357904 add ethinfo script
Signed-off-by: sbwml <admin@cooluc.com>
2024-12-10 23:28:12 +08:00

24 lines
503 B
Lua
Executable File

#!/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))