Files
openwrt_packages/autocore-arm/files/generic/ethinfo
2025-11-02 14:26:26 +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))