X-Git-Url: http://git.openwrt.org/?p=project%2Fluci.git;a=blobdiff_plain;f=applications%2Fluci-ffwizard-leipzig%2Fluasrc%2Fmodel%2Fcbi%2Fffwizard.lua;fp=applications%2Fluci-ffwizard-leipzig%2Fluasrc%2Fmodel%2Fcbi%2Fffwizard.lua;h=e82353031215309b4735d426b334bfaca915456c;hp=fa88f015070d90f385611e8f7a157ff1055634fe;hb=6ca3b275fc9bd83ccc9a4decf6d04d819f0efcf9;hpb=ee690abb0f482f0fd3f0b744f98b05699c08c8e4 diff --git a/applications/luci-ffwizard-leipzig/luasrc/model/cbi/ffwizard.lua b/applications/luci-ffwizard-leipzig/luasrc/model/cbi/ffwizard.lua index fa88f01507..e823530312 100644 --- a/applications/luci-ffwizard-leipzig/luasrc/model/cbi/ffwizard.lua +++ b/applications/luci-ffwizard-leipzig/luasrc/model/cbi/ffwizard.lua @@ -80,10 +80,15 @@ client = f:field(Flag, "client", "WLAN-DHCP anbieten") client:depends("wifi", "1") client.rmempty = true - olsr = f:field(Flag, "olsr", "OLSR einrichten") olsr.rmempty = true +lat = f:field(Value, "lat", "Latitude") +lat:depends("olsr", "1") + +lon = f:field(Value, "lon", "Longitude") +lon:depends("olsr", "1") + share = f:field(Flag, "sharenet", "Eigenen Internetzugang freigeben") share.rmempty = true @@ -265,6 +270,10 @@ function olsr.write(self, section, value) local community = net:formvalue(section) local external = community and uci:get("freifunk", community, "external") or "" + local latval = tonumber(lat:formvalue(section)) + local lonval = tonumber(lon:formvalue(section)) + + -- Delete old interface uci:delete_all("olsrd", "Interface", {interface=device}) @@ -285,6 +294,29 @@ function olsr.write(self, section, value) interval = "30" }) + -- Delete old nameservice settings + uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_nameservice.so.0.3"}) + + -- Write new nameservice settings + uci:section("olsrd", "LoadPlugin", nil, { + library = "olsrd_nameservice.so.0.3", + latlon_file = "/var/run/latlon.js", + lat = latval and string.format("%.15f", latval) or "", + lon = lonval and string.format("%.15f", lonval) or "" + }) + + -- Save latlon to system too + if latval and lonval then + uci:foreach("system", "system", function(s) + uci:set("system", s[".name"], "latlon", + string.format("%.15f %.15f", latval, lonval)) + end) + else + uci:foreach("system", "system", function(s) + uci:delete("system", s[".name"], "latlon") + end) + end + -- Import hosts uci:foreach("dhcp", "dnsmasq", function(s) uci:set("dhcp", s[".name"], "addnhosts", "/var/etc/hosts.olsr") @@ -305,6 +337,7 @@ function share.write(self, section, value) end uci:save("firewall") uci:save("olsrd") + uci:save("system") end