summaryrefslogtreecommitdiffhomepage
path: root/applications/luci-ffwizard-leipzig/luasrc
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2009-05-24 19:28:04 +0000
committerJo-Philipp Wich <jow@openwrt.org>2009-05-24 19:28:04 +0000
commit6ca3b275fc9bd83ccc9a4decf6d04d819f0efcf9 (patch)
treea971d885ecee5b0a5b4871f4d54e4ba3870d6869 /applications/luci-ffwizard-leipzig/luasrc
parentee690abb0f482f0fd3f0b744f98b05699c08c8e4 (diff)
modules/freifunk: implement map update for GlobalMap
applications/luci-ffwizard-leipzig: add lat and lon fields
Diffstat (limited to 'applications/luci-ffwizard-leipzig/luasrc')
-rw-r--r--applications/luci-ffwizard-leipzig/luasrc/model/cbi/ffwizard.lua35
1 files changed, 34 insertions, 1 deletions
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