gluon-mesh-batman-adv-core: don't break network configuration on upgrades with mesh_on_lan=true
This commit is contained in:
		
							parent
							
								
									a42db7a71f
								
							
						
					
					
						commit
						317478e2b7
					
				| @ -1,23 +1,32 @@ | |||||||
| #!/usr/bin/lua | #!/usr/bin/lua | ||||||
| 
 | 
 | ||||||
| local site = require 'gluon.site_config' | local site = require 'gluon.site_config' | ||||||
| local uci = require 'luci.model.uci' |  | ||||||
| local util = require 'gluon.util' | local util = require 'gluon.util' | ||||||
| local sysconfig = require 'gluon.sysconfig' | local sysconfig = require 'gluon.sysconfig' | ||||||
| 
 | 
 | ||||||
| local c = uci.cursor() | local uci = require('luci.model.uci').cursor() | ||||||
|  | local lutil = require 'luci.util' | ||||||
| 
 | 
 | ||||||
| if sysconfig.lan_ifname then | if sysconfig.lan_ifname and not uci:get('network', 'mesh_lan') then | ||||||
|   if not c:get('network', 'mesh_lan') then |   local enable = site.mesh_on_lan | ||||||
|     c:section('network', 'interface', 'mesh_lan', | 
 | ||||||
|  |   if enable then | ||||||
|  |     local interfaces = uci:get('network', 'client', 'ifname') | ||||||
|  | 
 | ||||||
|  |     if interfaces and lutil.contains(interfaces:split(' '), sysconfig.lan_ifname) then | ||||||
|  |       enable = false | ||||||
|  |     end | ||||||
|  |   end | ||||||
|  | 
 | ||||||
|  |   uci:section('network', 'interface', 'mesh_lan', | ||||||
|               { ifname  = sysconfig.lan_ifname |               { ifname  = sysconfig.lan_ifname | ||||||
|               , proto   = 'batadv' |               , proto   = 'batadv' | ||||||
|               , mesh    = 'bat0' |               , mesh    = 'bat0' | ||||||
|               , macaddr = util.generate_mac(1, 1) |               , macaddr = util.generate_mac(1, 1) | ||||||
|               , auto    = site.mesh_on_lan and 1 or 0 |               , auto    = enable and 1 or 0 | ||||||
|   }) |   }) | ||||||
|   end | 
 | ||||||
|  |   uci:save('network') | ||||||
|  |   uci:commit('network') | ||||||
| end | end | ||||||
| 
 | 
 | ||||||
| c:save('network') |  | ||||||
| c:commit('network') |  | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user