1 module("luci.controller.luci_ffwizard_leipzig.wizard", package.seeall)
4 entry({"admin", "index", "wizard"}, call("action_wizard"), "Freifunkassistent", 20).i18n="ffwizard-leipzig"
8 function action_wizard()
9 if luci.http.formvalue("ip") then
10 return configure_freifunk()
14 luci.model.uci.foreach("wireless", "wifi-device",
16 table.insert(ifaces, section[".name"])
19 luci.template.render("freifunk/wizard", {ifaces=ifaces})
22 function configure_freifunk()
23 local ip = luci.http.formvalue("ip")
24 local uci = luci.model.uci
26 wireless = uci.load("wireless"),
27 luci_fw = uci.load("luci_fw"),
28 luci_splash = uci.load("luci_splash"),
29 olsr = uci.load("olsr")
32 -- Configure FF-Interface
33 uci.delete("network", "ff")
34 uci.delete("network", "ffdhcp")
36 uci.section("network", "interface", "ff", {
40 netmask = uci.get("freifunk", "community", "mask"),
41 dns = uci.get("freifunk", "community", "dns")
45 uci.delete_all("luci_fw", "routing",
47 return (section.iface == "ff" or section.oface == "ff")
51 uci.section("luci_fw", "routing", nil, {
58 -- Routing from Internal
59 local iface = luci.http.formvalue("frominternal")
60 if iface and iface ~= "" then
61 uci.delete_all("luci_fw", "routing",
63 return (section.iface == iface and section.oface == "ff")
67 uci.section("luci_fw", "routing", nil, {
76 -- Routing to External
77 local iface = luci.http.formvalue("toexternal")
78 if iface and iface ~= "" then
79 uci.delete_all("luci_fw", "routing",
81 return (section.oface == iface and section.iface == "ff")
85 uci.section("luci_fw", "routing", nil, {
95 if luci.http.formvalue("dhcp") then
96 local dhcpnet = uci.get("freifunk", "community", "dhcp"):match("^([0-9]+)")
97 local dhcpip = ip:gsub("^[0-9]+", dhcpnet)
99 uci.section("network", "interface", "ffdhcp", {
101 ifname = "br-ff:dhcp",
103 netmask = uci.get("freifunk", "community", "dhcpmask")
106 uci.delete_all("dhcp", "dhcp",
108 return (section.interface == "ffdhcp")
111 local dhcpbeg = 48 + tonumber(ip:match("[0-9]+$")) * 4
112 uci.section("dhcp", "dhcp", nil, {
113 interface = "ffdhcp",
115 limit = ((dhcpbeg < 252) and 3 or 2),
120 uci.delete_all("luci_splash", "iface",
122 return (section.network == "ffdhcp")
125 if cfg.luci_splash then
126 uci.section("luci_splash", "iface", nil, {
132 uci.delete_all("luci_fw", "routing",
134 return (section.iface == "ffdhcp" or section.oface == "ffdhcp")
138 uci.section("luci_fw", "routing", nil, {
144 local iface = luci.http.formvalue("toexternal")
145 if iface and iface ~= "" then
146 uci.section("luci_fw", "routing", nil, {
156 if luci.http.formvalue("olsr") and cfg.olsr then
157 uci.delete_all("olsr", "Interface")
158 uci.delete_all("olsr", "LoadPlugin")
160 if luci.http.formvalue("shareinet") then
161 uci.section("olsr", "LoadPlugin", "dyn_gw", {
162 Library = "olsrd_dyn_gw.so.0.4"
166 uci.section("olsr", "LoadPlugin", "nameservice", {
167 Library = "olsrd_nameservice.so.0.3",
168 name = ip:gsub("%.", "-"),
169 hosts_file = "/var/etc/hosts",
171 latlon_infile = "/tmp/latlon.txt"
174 uci.section("olsr", "LoadPlugin", "txtinfo", {
175 Library = "olsrd_txtinfo.so.0.1",
179 uci.section("olsr", "Interface", nil, {
181 HelloInterval = "6.0",
182 HelloValidityTime = "108.0",
184 TcValidityTime = "324.0",
185 MidInterval = "18.0",
186 MidValidityTime = "324.0",
187 HnaInterval = "18.0",
188 HnaValidityTime = "108.0"
194 uci.foreach("wireless", "wifi-device",
196 local device = section[".name"]
198 if luci.http.formvalue("wifi."..device) then
199 uci.delete_all("wireless", "wifi-iface",
201 return (section.device == device)
204 uci.tset("wireless", device, {
209 channel = uci.get("freifunk", "community", "channel")
212 uci.section("wireless", "wifi-iface", nil, {
216 ssid = uci.get("freifunk", "community", "essid"),
217 bssid = uci.get("freifunk", "community", "bssid"),
228 luci.http.redirect(luci.dispatcher.build_url("admin", "uci", "changes"))