4 local uci = require "luci.model.uci"
7 local update_url = "http://map.berlin.freifunk.net/freifunkmap.php?update=%.15f,%.15f¬e=%s&olsrip=%s"
8 local update_all = ( arg[1] and arg[1] == "all" ) and true or false
11 x:foreach("olsrd", "LoadPlugin", function(s)
12 if s.library == "olsrd_nameservice.so.0.3" then
13 luci.fs.copy (s.latlon_file, "/tmp/ff_mapupdate.latlon")
14 file = io.open("/tmp/ff_mapupdate.latlon")
23 if not ln then break end
24 if update_all and ln:match("^Node%(") then
25 local ip, lat, lon, note = ln:match("Node%('(%S+)',([%d%.]+),([%d%.]+),%d+,'%S+','(%S+)'%)")
29 if ip and lat ~= 0.0 and lon ~= 0.0 and note then
30 note = note:gsub("[^%w%-%.]+", "_")
31 os.execute("wget -qO/dev/null %q" % string.format(update_url, lat, lon, note, ip))
35 elseif ln:match("^Self%(") then
36 local ip, lat, lon, note = ln:match("Self%('(%S+)',([%d%.]+),([%d%.]+),%d+,'%S+','(%S+)'%)")
40 if ip and lat ~= 0.0 and lon ~= 0.0 and note then
41 note = note:gsub("[^%w%-%.]+", "_")
42 os.execute("wget -qO/dev/null %q" % string.format(update_url, lat, lon, note, ip))
48 os.execute("logger -t 'mapupdate' 'Updated %d entries in freifunk map'" % count)