gluon-core: fall back to eth0 for the primary MAC address when there is no WLAN device
This commit is contained in:
parent
2dea903120
commit
c45a0bcdc1
@ -1,16 +1,34 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
|
||||
|
||||
if sysconfig.primary_mac then
|
||||
os.exit(0)
|
||||
end
|
||||
|
||||
|
||||
local platform = require 'gluon.platform'
|
||||
|
||||
local fs = require 'luci.fs'
|
||||
local util = require 'luci.util'
|
||||
|
||||
|
||||
if not sysconfig.primary_mac then
|
||||
if platform.match('ar71xx', 'generic', {'tl-wdr3600', 'tl-wdr4300'}) then
|
||||
sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy1/macaddress'))
|
||||
else
|
||||
sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy0/macaddress'))
|
||||
local try_files = {
|
||||
'/sys/class/ieee80211/phy0/macaddress',
|
||||
'/sys/class/net/eth0/address',
|
||||
}
|
||||
|
||||
if platform.match('ar71xx', 'generic', {'tl-wdr3600', 'tl-wdr4300'}) then
|
||||
table.insert(try_files, 1, '/sys/class/ieee80211/phy1/macaddress')
|
||||
end
|
||||
|
||||
|
||||
for _, file in ipairs(try_files) do
|
||||
local addr = fs.readfile(file)
|
||||
|
||||
if addr then
|
||||
sysconfig.primary_mac = util.trim(addr)
|
||||
break
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user