From ea12cb770dfb0b33a67d3309693b012fb261778b Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Fri, 10 Feb 2017 21:27:39 +0100 Subject: [PATCH] gluon-core: nicer indentation of /lib/gluon/upgrade/020-interfaces --- .../luasrc/lib/gluon/upgrade/020-interfaces | 67 ++++++++++++------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces b/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces index c8ef8600..2f951b92 100755 --- a/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces +++ b/package/gluon-core/luasrc/lib/gluon/upgrade/020-interfaces @@ -1,35 +1,50 @@ #!/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 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 - - - uci:delete('network', 'lan') - uci:delete('network', 'wan') - - uci:save('network') +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 + +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:save('network')