Skip to content
Snippets Groups Projects
Unverified Commit 184cb101 authored by Matthias Schiffer's avatar Matthias Schiffer
Browse files

gluon-core: add single_as_lan option to configure a single ethernet port as LAN instead of WAN

parent e39cbcbd
No related branches found
No related tags found
No related merge requests found
......@@ -70,3 +70,4 @@ end
need_boolean('mesh_on_wan', false)
need_boolean('mesh_on_lan', false)
need_boolean('single_as_lan', false)
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment