Merge remote-tracking branch 'origin/mesh-on-lan'

This commit is contained in:
Matthias Schiffer 2015-05-06 23:55:04 +02:00
commit a258092760
7 changed files with 53 additions and 1 deletions

View File

@ -130,6 +130,9 @@ fastd_mesh_vpn
mesh_on_wan : optional mesh_on_wan : optional
Enables the mesh on the WAN port (``true`` or ``false``). Enables the mesh on the WAN port (``true`` or ``false``).
mesh_on_lan : optional
Enables the mesh on the LAN port (``true`` or ``false``).
autoupdater : package autoupdater : package
Configuration for the autoupdater feature of Gluon. Configuration for the autoupdater feature of Gluon.
:: ::

View File

@ -13,6 +13,7 @@ $Id$
]]-- ]]--
local uci = luci.model.uci.cursor() local uci = luci.model.uci.cursor()
local sysconfig = require 'gluon.sysconfig'
local wan = uci:get_all("network", "wan") local wan = uci:get_all("network", "wan")
local wan6 = uci:get_all("network", "wan6") local wan6 = uci:get_all("network", "wan6")
@ -86,6 +87,13 @@ o = s:option(Flag, "mesh_wan", translate("Enable meshing on the WAN interface"))
o.default = uci:get_bool("network", "mesh_wan", "auto") and o.enabled or o.disabled o.default = uci:get_bool("network", "mesh_wan", "auto") and o.enabled or o.disabled
o.rmempty = false o.rmempty = false
if sysconfig.lan_ifname then
o = s:option(Flag, "mesh_lan", translate("Enable meshing on the LAN interface"))
o.default = uci:get_bool("network", "mesh_lan", "auto") and o.enabled or o.disabled
o.rmempty = false
end
function f.handle(self, state, data) function f.handle(self, state, data)
if state == FORM_VALID then if state == FORM_VALID then
uci:set("network", "wan", "proto", data.ipv4) uci:set("network", "wan", "proto", data.ipv4)
@ -110,6 +118,16 @@ function f.handle(self, state, data)
uci:set("network", "mesh_wan", "auto", data.mesh_wan) uci:set("network", "mesh_wan", "auto", data.mesh_wan)
if sysconfig.lan_ifname then
uci:set("network", "mesh_lan", "auto", data.mesh_lan)
if data.mesh_lan == '1' then
uci:set("network", "client", "ifname", "bat0")
else
uci:set("network", "client", "ifname", sysconfig.lan_ifname .. " bat0")
end
end
uci:save("network") uci:save("network")
uci:commit("network") uci:commit("network")

View File

@ -19,6 +19,9 @@ msgstr "Automatisch (RA/DHCPv6)"
msgid "Enable meshing on the WAN interface" msgid "Enable meshing on the WAN interface"
msgstr "Mesh auf dem WAN-Port aktivieren" msgstr "Mesh auf dem WAN-Port aktivieren"
msgid "Enable meshing on the LAN interface"
msgstr "Mesh auf dem LAN-Port aktivieren"
msgid "Static" msgid "Static"
msgstr "Statisch" msgstr "Statisch"

View File

@ -10,6 +10,9 @@ msgstr ""
msgid "Enable meshing on the WAN interface" msgid "Enable meshing on the WAN interface"
msgstr "" msgstr ""
msgid "Enable meshing on the LAN interface"
msgstr ""
msgid "Static" msgid "Static"
msgstr "" msgstr ""

View File

@ -13,3 +13,4 @@ for _, config in ipairs({'wifi24', 'wifi5'}) do
end end
need_boolean('mesh_on_wan', false) need_boolean('mesh_on_wan', false)
need_boolean('mesh_on_lan', false)

View File

@ -2,6 +2,7 @@
local sysconfig = require 'gluon.sysconfig' local sysconfig = require 'gluon.sysconfig'
local sysctl = require 'gluon.sysctl' local sysctl = require 'gluon.sysctl'
local site = require 'gluon.site_config'
local uci = require('luci.model.uci').cursor() local uci = require('luci.model.uci').cursor()
@ -20,7 +21,7 @@ uci:commit('batman-adv')
if not uci:get('network', 'client') then if not uci:get('network', 'client') then
local ifname local ifname
if sysconfig.lan_ifname then if sysconfig.lan_ifname and not site.mesh_on_lan then
ifname = sysconfig.lan_ifname .. ' bat0' ifname = sysconfig.lan_ifname .. ' bat0'
else else
ifname = 'bat0' ifname = 'bat0'

View File

@ -0,0 +1,23 @@
#!/usr/bin/lua
local site = require 'gluon.site_config'
local uci = require 'luci.model.uci'
local util = require 'gluon.util'
local sysconfig = require 'gluon.sysconfig'
local c = uci.cursor()
if sysconfig.lan_ifname then
if not c:get('network', 'mesh_lan') then
c:section('network', 'interface', 'mesh_lan',
{ ifname = sysconfig.lan_ifname
, proto = 'batadv'
, mesh = 'bat0'
, macaddr = util.generate_mac(1, 1)
, auto = site.mesh_on_lan and 1 or 0
})
end
end
c:save('network')
c:commit('network')