Use nicer platform match

This commit is contained in:
Matthias Schiffer 2014-07-11 12:11:47 +02:00
parent 6f1777b072
commit 58ced87261
5 changed files with 11 additions and 20 deletions

View File

@ -2,18 +2,14 @@
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local gluon_util = require 'gluon.util' local gluon_util = require 'gluon.util'
local platform = require 'gluon.platform'
local fs = require 'luci.fs' local fs = require 'luci.fs'
local uci = require('luci.model.uci').cursor() local uci = require('luci.model.uci').cursor()
local util = require 'luci.util' local util = require 'luci.util'
local platform_info = require 'platform_info'
if platform.match('ar71xx', 'generic', {'tl-wdr3600', 'tl-wdr4300'}) then
local board_name = platform_info.get_board_name()
if board_name == 'tl-wdr3600' or board_name == 'tl-wdr4300' then
sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy1/macaddress')) sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy1/macaddress'))
else else
sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy0/macaddress')) sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy0/macaddress'))
@ -29,7 +25,7 @@ local lan_ifname = uci:get('network', 'lan', 'ifname')
local wan_ifname = uci:get('network', 'wan', 'ifname') local wan_ifname = uci:get('network', 'wan', 'ifname')
if board_name == 'nanostation-m' then if platform.match('ar71xx', 'generic', {'nanostation-m'}) then
lan_ifname, wan_ifname = wan_ifname, lan_ifname lan_ifname, wan_ifname = wan_ifname, lan_ifname
end end

View File

@ -1,12 +1,12 @@
#!/usr/bin/lua #!/usr/bin/lua
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local platform = require 'gluon.platform'
local uci = require('luci.model.uci').cursor() local uci = require('luci.model.uci').cursor()
local util = require 'luci.util' local util = require 'luci.util'
local nixio = require 'nixio' local nixio = require 'nixio'
local platform_info = require 'platform_info'
uci:delete('network', 'lan') uci:delete('network', 'lan')
@ -21,7 +21,7 @@ uci:section('network', 'interface', 'wan',
) )
if util.contains({'tl-wr1043nd', 'tl-wdr3600', 'tl-wdr4300'}, platform_info.get_board_name()) then if platform.match('ar71xx', 'generic', {'tl-wr1043nd', 'tl-wdr3600', 'tl-wdr4300'}) then
-- fix up duplicate mac addresses -- fix up duplicate mac addresses
local m1, m2, m3, m4, m5, m6 = string.match(sysconfig.primary_mac, '(%x%x):(%x%x):(%x%x):(%x%x):(%x%x):(%x%x)') local m1, m2, m3, m4, m5, m6 = string.match(sysconfig.primary_mac, '(%x%x):(%x%x):(%x%x):(%x%x):(%x%x):(%x%x)')
m1 = nixio.bit.bor(tonumber(m1, 16), 0x02) m1 = nixio.bit.bor(tonumber(m1, 16), 0x02)

View File

@ -2,19 +2,14 @@
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local gluon_util = require 'gluon.util' local gluon_util = require 'gluon.util'
local site = require 'gluon.site_config' local platform = require 'gluon.platform'
local fs = require 'luci.fs' local fs = require 'luci.fs'
local uci = require('luci.model.uci').cursor() local uci = require('luci.model.uci').cursor()
local util = require 'luci.util' local util = require 'luci.util'
local platform_info = require 'platform_info'
if platform.match('ar71xx', 'generic', {'tl-wdr3600', 'tl-wdr4300'}) then
local board_name = platform_info.get_board_name()
if board_name == 'tl-wdr3600' or board_name == 'tl-wdr4300' then
sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy1/macaddress')) sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy1/macaddress'))
else else
sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy0/macaddress')) sysconfig.primary_mac = util.trim(fs.readfile('/sys/class/ieee80211/phy0/macaddress'))

View File

@ -1,15 +1,15 @@
#!/usr/bin/lua #!/usr/bin/lua
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local platform = require 'gluon.platform'
local uci = require('luci.model.uci').cursor() local uci = require('luci.model.uci').cursor()
local util = require 'luci.util' local util = require 'luci.util'
local nixio = require 'nixio' local nixio = require 'nixio'
local platform_info = require 'platform_info'
if util.contains({'tl-wr1043nd', 'tl-wdr3600', 'tl-wdr4300'}, platform_info.get_board_name()) then if platform.match('ar71xx', 'generic', {'tl-wr1043nd', 'tl-wdr3600', 'tl-wdr4300'}) then
-- fix up duplicate mac addresses -- fix up duplicate mac addresses
local m1, m2, m3, m4, m5, m6 = string.match(sysconfig.primary_mac, '(%x%x):(%x%x):(%x%x):(%x%x):(%x%x):(%x%x)') local m1, m2, m3, m4, m5, m6 = string.match(sysconfig.primary_mac, '(%x%x):(%x%x):(%x%x):(%x%x):(%x%x):(%x%x)')
m1 = nixio.bit.bor(tonumber(m1, 16), 0x02) m1 = nixio.bit.bor(tonumber(m1, 16), 0x02)

View File

@ -1,6 +1,6 @@
#!/usr/bin/lua #!/usr/bin/lua
local platform_info = require 'platform_info' local platform = require 'gluon.platform'
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
@ -8,7 +8,7 @@ if sysconfig.setup_ifname then
os.exit(0) os.exit(0)
end end
if platform_info.get_board_name() == 'nanostation-m' then if platform.match('ar71xx', 'generic', {'nanostation-m'}) then
sysconfig.setup_ifname = sysconfig.config_ifname or sysconfig.wan_ifname or sysconfig.lan_ifname sysconfig.setup_ifname = sysconfig.config_ifname or sysconfig.wan_ifname or sysconfig.lan_ifname
else else
sysconfig.setup_ifname = sysconfig.config_ifname or sysconfig.lan_ifname or sysconfig.wan_ifname sysconfig.setup_ifname = sysconfig.config_ifname or sysconfig.lan_ifname or sysconfig.wan_ifname