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

gluon-core: nicer indentation of /lib/gluon/upgrade/020-interfaces

parent e5cb1257
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/lua
local sysconfig = require 'gluon.sysconfig'
local gluon_util = require 'gluon.util'
-- Are we already set up?
if sysconfig.lan_ifname or sysconfig.wan_ifname then
os.exit(0)
end
local util = require 'gluon.util'
local platform = require 'gluon.platform'
local uci = require('simple-uci').cursor()
if not (sysconfig.lan_ifname or sysconfig.wan_ifname) then
local function iface_exists(name)
return (gluon_util.exec('ip', 'link', 'show', 'dev', (name:gsub('%..*$', ''))) == 0)
end
local function iface_exists(name)
return util.exec('ip', 'link', 'show', 'dev', (name:gsub('%..*$', ''))) == 0
end
local lan_ifname = uci:get('network', 'lan', 'ifname')
local wan_ifname = uci:get('network', 'wan', 'ifname')
if platform.match('ar71xx', 'generic', {'cpe210', 'cpe510', 'wbs210', 'wbs510', 'nanostation-m', 'nanostation-m-xw', 'unifi-outdoor-plus', 'uap-pro', 'unifiac-pro'}) then
lan_ifname, wan_ifname = wan_ifname, lan_ifname
end
local lan_ifname = uci:get('network', 'lan', 'ifname')
local wan_ifname = uci:get('network', 'wan', 'ifname')
if platform.match('ar71xx', 'generic', {
'cpe210',
'cpe510',
'wbs210',
'wbs510',
'nanostation-m',
'nanostation-m-xw',
'unifi-outdoor-plus',
'uap-pro',
'unifiac-pro',
}) then
lan_ifname, wan_ifname = wan_ifname, lan_ifname
end
if wan_ifname and iface_exists(wan_ifname) then
sysconfig.wan_ifname = wan_ifname
sysconfig.lan_ifname = lan_ifname
else
sysconfig.wan_ifname = lan_ifname
end
if wan_ifname and iface_exists(wan_ifname) then
sysconfig.wan_ifname = wan_ifname
sysconfig.lan_ifname = lan_ifname
else
sysconfig.wan_ifname = lan_ifname
end
uci:delete('network', 'lan')
uci:delete('network', 'wan')
uci:delete('network', 'lan')
uci:delete('network', 'wan')
uci:save('network')
end
uci:save('network')
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