diff --git a/package/gluon-core/files/lib/gluon/upgrade/010-primary-mac b/package/gluon-core/files/lib/gluon/upgrade/010-primary-mac index aa5e8732..7414941f 100755 --- a/package/gluon-core/files/lib/gluon/upgrade/010-primary-mac +++ b/package/gluon-core/files/lib/gluon/upgrade/010-primary-mac @@ -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