add ethinfo
script
Signed-off-by: sbwml <admin@cooluc.com>
This commit is contained in:
parent
7922aec3a0
commit
9d4f357904
1
Makefile
1
Makefile
@ -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
23
files/generic/ethinfo
Executable 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))
|
Loading…
x
Reference in New Issue
Block a user