diff --git a/package/gluon-core/check_site.lua b/package/gluon-core/check_site.lua index 7b0f92a0..61938ce5 100644 --- a/package/gluon-core/check_site.lua +++ b/package/gluon-core/check_site.lua @@ -70,3 +70,4 @@ end need_boolean('mesh_on_wan', false) need_boolean('mesh_on_lan', false) +need_boolean('single_as_lan', false) diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces b/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces index 2f951b92..7ca22d7a 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces @@ -10,17 +10,24 @@ end local util = require 'gluon.util' local platform = require 'gluon.platform' +local site = require 'gluon.site_config' local uci = require('simple-uci').cursor() -local function iface_exists(name) - return util.exec('ip', 'link', 'show', 'dev', (name:gsub('%..*$', ''))) == 0 +local function iface_exists(ifaces) + if not ifaces then return nil end + + for iface in ifaces:gmatch('%S+') do + if util.exec('ip', 'link', 'show', 'dev', (iface:gsub('%..*$', ''))) == 0 then + return ifaces + end + end end -local lan_ifname = uci:get('network', 'lan', 'ifname') -local wan_ifname = uci:get('network', 'wan', 'ifname') +local lan_ifname = iface_exists(uci:get('network', 'lan', 'ifname')) +local wan_ifname = iface_exists(uci:get('network', 'wan', 'ifname')) if platform.match('ar71xx', 'generic', { 'cpe210', @@ -36,11 +43,16 @@ if platform.match('ar71xx', 'generic', { lan_ifname, wan_ifname = wan_ifname, lan_ifname end -if wan_ifname and iface_exists(wan_ifname) then +if wan_ifname and lan_ifname then sysconfig.wan_ifname = wan_ifname sysconfig.lan_ifname = lan_ifname else - sysconfig.wan_ifname = lan_ifname + local single_ifname = lan_ifname or wan_ifname + if site.single_as_lan then + sysconfig.lan_ifname = single_ifname + else + sysconfig.wan_ifname = single_ifname + end end