diff --git a/Makefile b/Makefile index ea6e919..8cb2a7f 100644 --- a/Makefile +++ b/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/ diff --git a/files/generic/ethinfo b/files/generic/ethinfo new file mode 100755 index 0000000..1d319f5 --- /dev/null +++ b/files/generic/ethinfo @@ -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))