gluon-core: only restore WAN proto on upgrade (#2576)

Only restore the netifd proto for the WAN bridge in case the upgrade is
done from an older Gluon version.

For DSL targets, OpenWrt defaults the WAN proto to pppoe, while Gluon
uses the Ethernet ports for WAN. When unconditionally preserving the WAN
proto, pppoe is carried over to Gluon's network config.

Signed-off-by: David Bauer <mail@david-bauer.net>
This commit is contained in:
David Bauer 2022-07-06 22:19:55 +02:00 committed by GitHub
parent 39f9bf7ac3
commit c06bdd6cfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,8 @@
#!/usr/bin/lua #!/usr/bin/lua
local uci = require('simple-uci').cursor() local uci = require('simple-uci').cursor()
local sysconfig = require 'gluon.sysconfig'
local util = require 'gluon.util' local util = require 'gluon.util'
local wan = uci:get_all('network_gluon-old', 'wan') or {} local wan = uci:get_all('network_gluon-old', 'wan') or {}
@ -13,8 +15,15 @@ uci:section('network', 'interface', 'loopback', {
netmask = '255.0.0.0', netmask = '255.0.0.0',
}) })
local wan_proto = 'dhcp'
if sysconfig.gluon_version and wan.proto ~= nil then
-- Only restore WAN proto in case this is an upgrade
wan_proto = wan.proto
end
uci:section('network', 'interface', 'wan', { uci:section('network', 'interface', 'wan', {
proto = wan.proto or 'dhcp', proto = wan_proto,
ipaddr = wan.ipaddr, ipaddr = wan.ipaddr,
netmask = wan.netmask, netmask = wan.netmask,
gateway = wan.gateway, gateway = wan.gateway,