123456789101112131415161718192021222324252627282930313233343536 |
- #!/usr/bin/lua
- local sysconfig = require 'gluon.sysconfig'
- local uci = require('luci.model.uci').cursor()
- local util = require 'luci.util'
- local nixio = require 'nixio'
- local platform_info = require 'platform_info'
- uci:delete('network', 'lan')
- uci:delete('network', 'wan')
- uci:section('network', 'interface', 'wan',
- {
- ifname = sysconfig.wan_ifname,
- type = 'bridge',
- proto = 'dhcp',
- }
- )
- if util.contains({'tl-wr1043nd', 'tl-wdr3600', 'tl-wdr4300'}, platform_info.get_board_name()) then
- -- 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)')
- m1 = nixio.bit.bor(tonumber(m1, 16), 0x02)
- m4 = (tonumber(m4, 16)+1) % 0x100
- m6 = (tonumber(m6, 16)+1) % 0x100
- local wanaddr = string.format('%02x:%s:%s:%02x:%s:%02x', m1, m2, m3, m4, m5, m6)
- uci:set('network', 'wan', 'macaddr', wanaddr)
- end
- uci:save('network')
- uci:commit('network')
|