applications/ffwizard: Massive changes to the ffwizard to make it more generic. Also...
authorManuel Munz <freifunk@somakoma.de>
Tue, 25 Jan 2011 21:04:57 +0000 (21:04 +0000)
committerManuel Munz <freifunk@somakoma.de>
Tue, 25 Jan 2011 21:04:57 +0000 (21:04 +0000)
65 files changed:
applications/luci-ffwizard-leipzig/Makefile [deleted file]
applications/luci-ffwizard-leipzig/luasrc/controller/ffwizard.lua [deleted file]
applications/luci-ffwizard-leipzig/luasrc/model/cbi/ffwizard.lua [deleted file]
applications/luci-ffwizard-leipzig/luasrc/tools/ffwizard.lua [deleted file]
applications/luci-ffwizard/luasrc/controller/ffwizard.lua
applications/luci-ffwizard/luasrc/model/cbi/ffwizard.lua [deleted file]
applications/luci-ffwizard/luasrc/model/cbi/freifunk/ffwizard.lua [new file with mode: 0644]
applications/luci-ffwizard/luasrc/view/freifunk/ffwizard_error.htm [new file with mode: 0644]
applications/luci-ffwizard/root/etc/uci-defaults/device-defaults
contrib/package/luci/Makefile
modules/freifunk/luasrc/controller/freifunk/freifunk.lua
modules/freifunk/luasrc/model/cbi/freifunk/basics.lua [new file with mode: 0644]
modules/freifunk/luasrc/model/cbi/freifunk/contact.lua
modules/freifunk/luasrc/model/cbi/freifunk/freifunk.lua [deleted file]
modules/freifunk/luasrc/model/cbi/freifunk/profile.lua [new file with mode: 0644]
modules/freifunk/luasrc/model/cbi/freifunk/profile_expert.lua [new file with mode: 0644]
modules/freifunk/luasrc/view/freifunk/adminindex.htm [new file with mode: 0644]
modules/freifunk/luasrc/view/freifunk/contact.htm
modules/freifunk/luasrc/view/freifunk/index.htm
modules/freifunk/root/etc/config/freifunk
modules/freifunk/root/etc/config/freifunk_augsburg [deleted file]
modules/freifunk/root/etc/config/freifunk_bergischesland [deleted file]
modules/freifunk/root/etc/config/freifunk_berlin [deleted file]
modules/freifunk/root/etc/config/freifunk_dresden [deleted file]
modules/freifunk/root/etc/config/freifunk_duesseldorf [deleted file]
modules/freifunk/root/etc/config/freifunk_hamburg [deleted file]
modules/freifunk/root/etc/config/freifunk_hannover [deleted file]
modules/freifunk/root/etc/config/freifunk_jena [deleted file]
modules/freifunk/root/etc/config/freifunk_kiberpipa [deleted file]
modules/freifunk/root/etc/config/freifunk_mainz [deleted file]
modules/freifunk/root/etc/config/freifunk_marburg [deleted file]
modules/freifunk/root/etc/config/freifunk_neuss [deleted file]
modules/freifunk/root/etc/config/freifunk_oldenburg [deleted file]
modules/freifunk/root/etc/config/freifunk_potsdam [deleted file]
modules/freifunk/root/etc/config/freifunk_rosbach [deleted file]
modules/freifunk/root/etc/config/freifunk_seefeld [deleted file]
modules/freifunk/root/etc/config/freifunk_wlanljubljana [deleted file]
modules/freifunk/root/etc/config/openwireless_bern [deleted file]
modules/freifunk/root/etc/config/profile_-custom [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_augsburg [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_bensheim [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_bergischesland [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_berlin [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_dresden [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_duesseldorf [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_halle [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_hamburg [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_hannover [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_heppenheim [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_jena [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_kiberpipa [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_l59 [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_leipzig [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_mainz [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_marburg [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_neuss [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_oldenburg [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_openwireless_bern [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_pberg [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_piraten_dresden [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_potsdam [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_rosbach [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_seefeld [new file with mode: 0644]
modules/freifunk/root/etc/config/profile_wlanljubljana [new file with mode: 0644]
themes/freifunk-generic/luasrc/view/themes/freifunk-generic/header.htm

diff --git a/applications/luci-ffwizard-leipzig/Makefile b/applications/luci-ffwizard-leipzig/Makefile
deleted file mode 100644 (file)
index a4f7c76..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-PO = 
-
-include ../../build/config.mk
-include ../../build/module.mk
diff --git a/applications/luci-ffwizard-leipzig/luasrc/controller/ffwizard.lua b/applications/luci-ffwizard-leipzig/luasrc/controller/ffwizard.lua
deleted file mode 100644 (file)
index 9a9f883..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
---[[
-LuCI - Lua Configuration Interface
-
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
-]]--
-
-module "luci.controller.ffwizard"
-
-function index()
-       entry({"admin", "freifunk", "ffwizard"}, form("ffwizard"), "Freifunkassistent", 50)
-end
\ No newline at end of file
diff --git a/applications/luci-ffwizard-leipzig/luasrc/model/cbi/ffwizard.lua b/applications/luci-ffwizard-leipzig/luasrc/model/cbi/ffwizard.lua
deleted file mode 100644 (file)
index 780316c..0000000
+++ /dev/null
@@ -1,493 +0,0 @@
---[[
-LuCI - Lua Configuration Interface
-
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
-]]--
-
-
-local uci = require "luci.model.uci".cursor()
-local tools = require "luci.tools.ffwizard"
-local util = require "luci.util"
-local sys = require "luci.sys"
-local ip = require "luci.ip"
-
-local function mksubnet(community, meship)
-       local subnet_prefix = tonumber(uci:get("freifunk", community, "splash_prefix")) or 27
-       local pool_network = uci:get("freifunk", community, "splash_network") or "10.104.0.0/16"
-       local pool = luci.ip.IPv4(pool_network)
-
-       if pool then
-               local hosts_per_subnet = 2^(32 - subnet_prefix)
-               local number_of_subnets = (2^pool:prefix())/hosts_per_subnet
-
-               local seed1, seed2 = meship:match("(%d+)%.(%d+)$")
-               math.randomseed(seed1 * seed2)
-
-               local subnet = pool:add(hosts_per_subnet * math.random(number_of_subnets))
-
-               local subnet_ipaddr = subnet:network(subnet_prefix):add(1):string()
-               local subnet_netmask = subnet:mask(subnet_prefix):string()
-
-               return subnet_ipaddr, subnet_netmask
-       end
-end
-
-
--------------------- View --------------------
-f = SimpleForm("ffwizward", "Freifunkassistent",
- "Dieser Assistent unterstüzt bei der Einrichtung des Routers für das Freifunknetz.")
-
-
-dev = f:field(ListValue, "device", "WLAN-Gerät")
-uci:foreach("wireless", "wifi-device",
-       function(section)
-               dev:value(section[".name"])
-       end)
-
-
-main = f:field(Flag, "wifi", "Freifunkzugang einrichten")
-
-net = f:field(Value, "net", "Freifunk Community", "Mesh Netzbereich")
-net.rmempty = true
-net:depends("wifi", "1")
-uci:foreach("freifunk", "community", function(s)
-       net:value(s[".name"], "%s (%s)" % {s.name, s.mesh_network or "?"})
-end)
-
-function net.cfgvalue(self, section)
-       return uci:get("freifunk", "wizard", "net")
-end
-function net.write(self, section, value)
-       uci:set("freifunk", "wizard", "net", value)
-       uci:save("freifunk")
-end
-
-meship = f:field(Value, "meship", "Mesh IP Adresse", "Netzweit eindeutige Identifikation")
-meship.rmempty = true
-meship:depends("wifi", "1")
-function meship.cfgvalue(self, section)
-       return uci:get("freifunk", "wizard", "meship")
-end
-function meship.write(self, section, value)
-       uci:set("freifunk", "wizard", "meship", value)
-       uci:save("freifunk")
-end
-function meship.validate(self, value)
-       local x = ip.IPv4(value)
-       return ( x and x:prefix() == 32 ) and x:string() or ""
-end
-
-client = f:field(Flag, "client", "WLAN-DHCP anbieten")
-client:depends("wifi", "1")
-client.rmempty = false
-function client.cfgvalue(self, section)
-       return uci:get("freifunk", "wizard", "dhcp_splash") or "0"
-end
-
-olsr = f:field(Flag, "olsr", "OLSR einrichten")
-olsr.rmempty = true
-
-lat = f:field(Value, "lat", "Latitude")
-lat:depends("olsr", "1")
-function lat.cfgvalue(self, section)
-       return uci:get("freifunk", "wizard", "latitude")
-end
-function lat.write(self, section, value)
-       uci:set("freifunk", "wizard", "latitude", value)
-       uci:save("freifunk")
-end
-
-lon = f:field(Value, "lon", "Longitude")
-lon:depends("olsr", "1")
-function lon.cfgvalue(self, section)
-       return uci:get("freifunk", "wizard", "longitude")
-end
-function lon.write(self, section, value)
-       uci:set("freifunk", "wizard", "longitude", value)
-       uci:save("freifunk")
-end
-
-share = f:field(Flag, "sharenet", "Eigenen Internetzugang freigeben")
-share.rmempty = true
-
-wansec = f:field(Flag, "wansec", "WAN-Zugriff auf Gateway beschränken")
-wansec.rmempty = false
-wansec:depends("sharenet", "1")
-function wansec.cfgvalue(self, section)
-       return uci:get("freifunk", "wizard", "wan_security")
-end
-function wansec.write(self, section, value)
-       uci:set("freifunk", "wizard", "wan_security", value)
-       uci:save("freifunk")
-end
-
--------------------- Control --------------------
-function f.handle(self, state, data)
-       if state == FORM_VALID then
-               luci.http.redirect(luci.dispatcher.build_url("admin", "uci", "changes"))
-               return false
-       elseif state == FORM_INVALID then
-               self.errmessage = "Ungültige Eingabe: Bitte die Formularfelder auf Fehler prüfen."
-       end
-       return true
-end
-
-local function _strip_internals(tbl)
-       tbl = tbl or {}
-       for k, v in pairs(tbl) do
-               if k:sub(1, 1) == "." then
-                       tbl[k] = nil
-               end
-       end
-       return tbl
-end
-
--- Configure Freifunk checked
-function main.write(self, section, value)
-       if value == "0" then
-               return
-       end
-
-       local device = dev:formvalue(section)
-       local node_ip, external
-
-       -- Collect IP-Address
-       local community = net:formvalue(section)
-
-       -- Invalidate fields
-       if not community then
-               net.tag_missing[section] = true
-       else
-               external = uci:get("freifunk", community, "external") or ""
-               network = ip.IPv4(uci:get("freifunk", community, "mesh_network") or "104.0.0.0/8")
-               node_ip = meship:formvalue(section) and ip.IPv4(meship:formvalue(section))
-
-               if not node_ip or not network or not network:contains(node_ip) then
-                       meship.tag_missing[section] = true
-                       node_ip = nil
-               end
-       end
-
-       if not node_ip then return end
-
-
-       -- Cleanup
-       tools.wifi_delete_ifaces(device)
-       tools.network_remove_interface(device)
-       tools.firewall_zone_remove_interface("freifunk", device)
-
-       -- Tune community settings
-       if community and uci:get("freifunk", community) then
-               uci:tset("freifunk", "community", uci:get_all("freifunk", community))
-       end
-
-       -- Tune wifi device
-       local devconfig = uci:get_all("freifunk", "wifi_device")
-       util.update(devconfig, uci:get_all(external, "wifi_device") or {})
-       uci:tset("wireless", device, devconfig)
-
-       -- Create wifi iface
-       local ifconfig = uci:get_all("freifunk", "wifi_iface")
-       util.update(ifconfig, uci:get_all(external, "wifi_iface") or {})
-       ifconfig.device = device
-       ifconfig.network = device
-       ifconfig.ssid = uci:get("freifunk", community, "ssid")
-       uci:section("wireless", "wifi-iface", nil, ifconfig)
-
-       -- Save wifi
-       uci:save("wireless")
-
-       -- Create firewall zone and add default rules (first time)
-       local newzone = tools.firewall_create_zone("freifunk", "REJECT", "ACCEPT", "REJECT", true)
-       if newzone then
-               uci:foreach("freifunk", "fw_forwarding", function(section)
-                       uci:section("firewall", "forwarding", nil, section)
-               end)
-               uci:foreach(external, "fw_forwarding", function(section)
-                       uci:section("firewall", "forwarding", nil, section)
-               end)
-
-               uci:foreach("freifunk", "fw_rule", function(section)
-                       uci:section("firewall", "rule", nil, section)
-               end)
-               uci:foreach(external, "fw_rule", function(section)
-                       uci:section("firewall", "rule", nil, section)
-               end)
-       end
-
-       -- Enforce firewall include
-       local has_include = false
-       uci:foreach("firewall", "include",
-               function(section)
-                       if section.path == "/etc/firewall.freifunk" then
-                               has_include = true
-                       end
-               end)
-
-       if not has_include then
-               uci:section("firewall", "include", nil,
-                       { path = "/etc/firewall.freifunk" })
-       end
-
-       -- Allow state: invalid packets
-       uci:foreach("firewall", "defaults",
-               function(section)
-                       uci:set("firewall", section[".name"], "drop_invalid", "0")
-               end)
-
-       -- Prepare advanced config
-       local has_advanced = false
-       uci:foreach("firewall", "advanced",
-               function(section) has_advanced = true end)
-
-       if not has_advanced then
-               uci:section("firewall", "advanced", nil,
-                       { tcp_ecn = "0", ip_conntrack_max = "8192", tcp_westwood = "1" })
-       end
-
-       uci:save("firewall")
-
-
-       -- Create network interface
-       local netconfig = uci:get_all("freifunk", "interface")
-       util.update(netconfig, uci:get_all(external, "interface") or {})
-       netconfig.proto = "static"
-       netconfig.ipaddr = node_ip:string()
-       uci:section("network", "interface", device, netconfig)
-
-       uci:save("network")
-
-       tools.firewall_zone_add_interface("freifunk", device)
-
-
-       local new_hostname = node_ip:string():gsub("%.", "-")
-       local old_hostname = sys.hostname()
-
-       uci:foreach("system", "system",
-               function(s)
-                       -- Make crond silent
-                       uci:set("system", s['.name'], "cronloglevel", "10")
-
-                       -- Set hostname
-                       if old_hostname == "OpenWrt" or old_hostname:match("^%d+-%d+-%d+-%d+$") then
-                               uci:set("system", s['.name'], "hostname", new_hostname)
-                               sys.hostname(new_hostname)
-                       end
-               end)
-
-       uci:save("system")
-end
-
-
-function olsr.write(self, section, value)
-       if value == "0" then
-               return
-       end
-
-
-       local device = dev:formvalue(section)
-
-       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})
-
-       -- Write new interface
-       local olsrbase = uci:get_all("freifunk", "olsr_interface")
-       util.update(olsrbase, uci:get_all(external, "olsr_interface") or {})
-       olsrbase.interface = device
-       olsrbase.ignore    = "0"
-       uci:section("olsrd", "Interface", nil, olsrbase)
-
-       -- Delete old watchdog settings
-       uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_watchdog.so.0.1"})
-
-       -- Write new watchdog settings
-       uci:section("olsrd", "LoadPlugin", nil, {
-               library  = "olsrd_watchdog.so.0.1",
-               file     = "/var/run/olsrd.watchdog",
-               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",
-               suffix      = ".olsr",
-               hosts_file  = "/var/etc/hosts.olsr",
-               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")
-       end)
-
-       -- Make sure that OLSR is enabled
-       sys.exec("/etc/init.d/olsrd enable")
-
-       uci:save("olsrd")
-       uci:save("dhcp")
-end
-
-
-function share.write(self, section, value)
-       uci:delete_all("firewall", "forwarding", {src="freifunk", dest="wan"})
-       uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_dyn_gw_plain.so.0.4"})
-       uci:foreach("firewall", "zone",
-               function(s)             
-                       if s.name == "wan" then
-                               uci:delete("firewall", s['.name'], "local_restrict")
-                               return false
-                       end
-               end)
-
-       if value == "1" then
-               uci:section("firewall", "forwarding", nil, {src="freifunk", dest="wan"})
-               uci:section("olsrd", "LoadPlugin", nil, {library="olsrd_dyn_gw_plain.so.0.4"})
-
-               if wansec:formvalue(section) == "1" then
-                       uci:foreach("firewall", "zone",
-                               function(s)             
-                                       if s.name == "wan" then
-                                               uci:set("firewall", s['.name'], "local_restrict", "1")
-                                               return false
-                                       end
-                               end)
-               end
-       end
-
-       uci:save("firewall")
-       uci:save("olsrd")
-       uci:save("system")
-end
-
-
-function client.write(self, section, value)
-       if value == "0" then
-               uci:delete("freifunk", "wizard", "dhcp_splash")
-               uci:save("freifunk")
-               return
-       end
-
-       local device = dev:formvalue(section)
-
-       -- Collect IP-Address
-       local node_ip = meship:formvalue(section)
-
-       if not node_ip then return end
-
-       local community = net:formvalue(section)
-       local external  = community and uci:get("freifunk", community, "external") or ""
-       local splash_ip, splash_mask = mksubnet(community, node_ip)
-
-       -- Delete old alias
-       uci:delete("network", device .. "dhcp")
-
-       -- Create alias
-       local aliasbase = uci:get_all("freifunk", "alias")
-       util.update(aliasbase, uci:get_all(external, "alias") or {})
-       aliasbase.interface = device
-       aliasbase.ipaddr = splash_ip
-       aliasbase.netmask = splash_mask
-       aliasbase.proto = "static"
-       uci:section("network", "alias", device .. "dhcp", aliasbase)
-       uci:save("network")
-
-
-       -- Create dhcp
-       local dhcpbase = uci:get_all("freifunk", "dhcp")
-       util.update(dhcpbase, uci:get_all(external, "dhcp") or {})
-       dhcpbase.interface = device .. "dhcp"
-       dhcpbase.start = dhcpbeg
-       dhcpbase.limit = limit
-       dhcpbase.force = 1
-
-       uci:section("dhcp", "dhcp", device .. "dhcp", dhcpbase)
-       uci:save("dhcp")
-
-       uci:delete_all("firewall", "rule", {
-               src="freifunk",
-               proto="udp",
-               dest_port="53"
-       })
-       uci:section("firewall", "rule", nil, {
-               src="freifunk",
-               proto="udp",
-               dest_port="53",
-               target="ACCEPT"
-       })
-       uci:delete_all("firewall", "rule", {
-               src="freifunk",
-               proto="udp",
-               src_port="68",
-               dest_port="67"
-       })
-       uci:section("firewall", "rule", nil, {
-               src="freifunk",
-               proto="udp",
-               src_port="68",
-               dest_port="67",
-               target="ACCEPT"
-       })
-       uci:delete_all("firewall", "rule", {
-               src="freifunk",
-               proto="tcp",
-               dest_port="8082",
-       })
-       uci:section("firewall", "rule", nil, {
-               src="freifunk",
-               proto="tcp",
-               dest_port="8082",
-               target="ACCEPT"
-       })
-
-       uci:save("firewall")
-
-       -- Delete old splash
-       uci:delete_all("luci_splash", "iface", {network=device.."dhcp", zone="freifunk"})
-
-       -- Register splash
-       uci:section("luci_splash", "iface", nil, {network=device.."dhcp", zone="freifunk"})
-       uci:save("luci_splash")
-       
-       -- Make sure that luci_splash is enabled
-       sys.exec("/etc/init.d/luci_splash enable")
-
-       -- Remember state
-       uci:set("freifunk", "wizard", "dhcp_splash", "1")
-       uci:save("freifunk")
-end
-
-return f
diff --git a/applications/luci-ffwizard-leipzig/luasrc/tools/ffwizard.lua b/applications/luci-ffwizard-leipzig/luasrc/tools/ffwizard.lua
deleted file mode 100644 (file)
index 217cd44..0000000
+++ /dev/null
@@ -1,149 +0,0 @@
---[[
-LuCI - Lua Configuration Interface
-
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
-]]--
-
-local uci = require "luci.model.uci"
-local util = require "luci.util"
-local table = require "table"
-
-local type = type
-
-module "luci.tools.ffwizard"
-
--- Deletes all references of a wifi device
-function wifi_delete_ifaces(device)
-       local cursor = uci.cursor()
-       cursor:delete_all("wireless", "wifi-iface", {device=device})
-       cursor:save("wireless")
-end
-
--- Deletes a network interface and all occurences of it in firewall zones and dhcp
-function network_remove_interface(iface)
-       local cursor = uci.cursor()
-
-       if not cursor:delete("network", iface) then
-               return false
-       end
-
-       local aliases = {iface}
-       cursor:foreach("network", "alias",
-               function(section)
-                       if section.interface == iface then
-                               table.insert(aliases, section[".name"])
-                       end
-               end)
-
-       -- Delete Aliases and Routes
-       cursor:delete_all("network", "route", {interface=iface})
-       cursor:delete_all("network", "alias", {interface=iface})
-
-       -- Delete DHCP sections
-       cursor:delete_all("dhcp", "dhcp",
-                function(section)
-                       return util.contains(aliases, section.interface)
-                end)
-
-       -- Remove OLSR sections
-       cursor:delete_all("olsrd", "Interface", {Interface=iface})
-
-       -- Remove Splash sections
-       cursor:delete_all("luci-splash", "iface", {network=iface})
-
-       cursor:save("network")
-       cursor:save("olsr")
-       cursor:save("dhcp")
-       cursor:save("luci-splash")
-end
-
--- Creates a firewall zone
-function firewall_create_zone(zone, input, output, forward, masq)
-       local cursor = uci.cursor()
-       if not firewall_find_zone(zone) then
-               local stat = cursor:section("firewall", "zone", nil, {
-                       input = input,
-                       output = output,
-                       forward = forward,
-                       masq = masq and "1",
-                       name = zone
-               })
-               cursor:save("firewall")
-               return stat
-       end
-end
-
--- Adds interface to zone, creates zone on-demand
-function firewall_zone_add_interface(name, interface)
-       local cursor = uci.cursor()
-       local zone = firewall_find_zone(name)
-       local net = cursor:get("firewall", zone, "network")
-       local old = net or (cursor:get("network", name) and name)
-       cursor:set("firewall", zone, "network", (old and old .. " " or "") .. interface)
-       cursor:save("firewall")
-end
-
--- Removes interface from zone
-function firewall_zone_remove_interface(name, interface)
-       local cursor = uci.cursor()
-       local zone = firewall_find_zone(name)
-       if zone then
-               local net = cursor:get("firewall", zone, "network")
-               local new = remove_list_entry(net, interface)
-               if new then
-                       if #new > 0 then
-                               cursor:set("firewall", zone, "network", new)
-                       else
-                               cursor:delete("firewall", zone, "network")
-                       end
-                       cursor:save("firewall")
-               end
-       end
-end
-
-
--- Finds the firewall zone with given name
-function firewall_find_zone(name)
-       local find
-
-       uci.cursor():foreach("firewall", "zone",
-               function (section)
-                       if section.name == name then
-                               find = section[".name"]
-                       end
-               end)
-
-       return find
-end
-
-
-
--- Helpers --
-
--- Removes a listentry, handles real and pseduo lists transparently
-function remove_list_entry(value, entry)
-       if type(value) == "nil" then
-               return nil
-       end
-
-       local result = type(value) == "table" and value or util.split(value, " ")
-       local key = util.contains(result, entry)
-
-       while key do
-               table.remove(result, key)
-               key = util.contains(result, entry)
-       end
-
-       result = type(value) == "table" and result or table.concat(result, " ")
-       return result ~= value and result
-end
index 428962d..5ad48ee 100644 (file)
@@ -18,6 +18,10 @@ $Id$
 module "luci.controller.ffwizard"
 
 function index()
-       entry({"admin", "freifunk", "ffwizard"}, form("ffwizard"), "Freifunkassistent", 1)
-       assign({"mini", "freifunk", "ffwizard"}, {"admin", "freifunk", "ffwizard"}, "Freifunkassistent", 1)
-end
\ No newline at end of file
+       entry({"admin", "freifunk", "ffwizard"}, form("freifunk/ffwizard"), "Freifunkassistent", 40)
+       assign({"mini", "freifunk", "ffwizard"}, {"admin", "freifunk", "ffwizard"}, "Freifunkassistent", 40)
+       
+       entry({"admin", "freifunk", "ffwizard_error"}, template("freifunk/ffwizard_error"))
+       assign({"mini", "freifunk", "ffwizard_error"}, {"admin", "freifunk", "ffwizard_error"})
+end
+
diff --git a/applications/luci-ffwizard/luasrc/model/cbi/ffwizard.lua b/applications/luci-ffwizard/luasrc/model/cbi/ffwizard.lua
deleted file mode 100644 (file)
index 47118d1..0000000
+++ /dev/null
@@ -1,1459 +0,0 @@
---[[
-LuCI - Lua Configuration Interface
-
-Copyright 2008 Steven Barth <steven@midlink.org>
-Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
-Copyright 2011 Patrick Grimm <patrick@pberg.freifunk.net>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-
-]]--
-
-
-local uci = require "luci.model.uci".cursor()
-local uci_state = require "luci.model.uci".cursor_state()
-local tools = require "luci.tools.ffwizard"
-local util = require "luci.util"
-local sys = require "luci.sys"
-local ip = require "luci.ip"
-local fs  = require "nixio.fs"
-
-local has_pptp  = fs.access("/usr/sbin/pptp")
-local has_pppoe = fs.glob("/usr/lib/pppd/*/rp-pppoe.so")()
-local has_l2gvpn  = fs.access("/usr/sbin/node")
-local has_radvd  = fs.access("/etc/config/radvd")
-local has_rom  = fs.access("/rom/etc")
-local has_autoipv6  = fs.access("/usr/bin/auto-ipv6")
-local has_qos  = fs.access("/etc/init.d/qos")
-local has_ipv6 = fs.access("/proc/sys/net/ipv6")
-local has_hb = fs.access("/sbin/heartbeat")
-
-luci.i18n.loadc("freifunk")
-
-function get_mac(ix)
-       if string.find(ix, "radio") then
-               ix = string.gsub(ix,"radio", 'wlan')
-       end
-       local mac = fs.readfile("/sys/class/net/" .. ix .. "/address")
-       if not mac then
-               mac = luci.util.exec("ifconfig " .. ix)
-               mac = mac and mac:match(" ([A-F0-9:]+)%s*\n")
-       else
-               mac = mac:sub(1,17)
-       end
-       if mac and #mac > 0 then
-               return mac:lower()
-       end
-       return "?"
-end
-function get_ula(imac)
-       if string.len(imac) == 17 then
-               local mac1 = string.sub(imac,4,8)
-               local mac2 = string.sub(imac,10,14)
-               local mac3 = string.sub(imac,16,17)
-               return 'fdca:ffee:babe::02'..mac1..'ff:fe'..mac2..mac3..'/64'
-       end
-       return "?"
-end
-
-
--------------------- View --------------------
-f = SimpleForm("ffwizward", "Freifunkassistent",
- "Dieser Assistent unterstützt Sie bei der Einrichtung des Routers für das Freifunknetz.")
-
--- if password is not set or default then force the user to set a new one
-if sys.exec("diff /rom/etc/passwd /etc/passwd") == "" then
-       pw1 = f:field(Value, "pw1", translate("password"))
-       pw1.password = true
-       pw1.rmempty = false
-
-       pw2 = f:field(Value, "pw2", translate("confirmation"))
-       pw2.password = true
-       pw2.rmempty = false
-
-       function pw2.validate(self, value, section)
-               return pw1:formvalue(section) == value and value
-       end
-end
-
-net = f:field(ListValue, "net", "Freifunk Community", "Nutzen Sie die Einstellungen der Freifunk Gemeinschaft in ihrer Nachbarschaft.")
-net.rmempty = false
-net.optional = false
-uci:foreach("freifunk", "community", function(s)
-       net:value(s[".name"], "%s (%s)" % {s.name, s.mesh_network or "?"})
-end)
-function net.cfgvalue(self, section)
-       return uci:get("freifunk", "wizard", "net")
-end
-function net.write(self, section, value)
-       uci:set("freifunk", "wizard", "net", value)
-       uci:save("freifunk")
-end
-net_lat = f:field(ListValue, "net_lat", "", "")
-net_lat:depends("net", "0")
-net_lon = f:field(ListValue, "net_lon", "", "")
-net_lon:depends("net", "0")
-
-uci:foreach("freifunk", "community", function(s)
-       if s.latitude then
-               net_lat:value(s[".name"], "%s" % {s.latitude or "?"})
-       end
-       if s.longitude then
-               net_lon:value(s[".name"], "%s" % {s.longitude or "?"})
-       end
-end)
-
--- hostname
-hostname = f:field(Value, "hostname", "Knoten Name", "Geben Sie Ihrem Freifunk Router einen Namen. Wenn Sie dieses Feld leer lassen, wird der Name automatisch aus der Mesh IP generiert.")
-hostname.rmempty = true
-hostname.optional = false
-function hostname.cfgvalue(self, section)
-       return sys.hostname()
-end
-function hostname.write(self, section, value)
-       uci:set("freifunk", "wizard", "hostname", value)
-       uci:save("freifunk")
-end
-function hostname.validate(self, value)
-       if (#value > 24) or string.find(value, "[^%w%.%-]") or string.find(string.sub(value, value:len()), "[%.%-]") or string.find(string.sub(value, 1), "[%.%-]") then
-               return
-       else
-               return value
-       end
-end
-
--- location
-location = f:field(Value, "location", "Standort", "Geben Sie den Standort ihres Gerätes an")
-location.rmempty = false
-location.optional = false
-function location.cfgvalue(self, section)
-       return uci:get("freifunk", "contact", "location")
-end
-function location.write(self, section, value)
-       uci:set("freifunk", "contact", "location", value)
-       uci:save("freifunk")
-end
-
--- mail
-mail = f:field(Value, "mail", "E-Mail", "Bitte hinterlegen Sie eine Kontaktadresse.")
-mail.rmempty = false
-mail.optional = false
-function mail.cfgvalue(self, section)
-       return uci:get("freifunk", "contact", "mail")
-end
-function mail.write(self, section, value)
-       uci:set("freifunk", "contact", "mail", value)
-       uci:save("freifunk")
-end
--- main netconfig
-main = f:field(Flag, "netconfig", "Netzwerk einrichten", "Setzen Sie den Haken, wenn Sie Ihr Freifunk Netzwerk einrichten wollen.")
-uci:foreach("wireless", "wifi-device",
-       function(section)
-               local device = section[".name"]
-               local dev = f:field(Flag, "device_" .. device , "<b>Drahtloses Netzwerk \"" .. device:upper() .. "\"</b> ", "Konfigurieren Sie Ihre drahtlose " .. device:upper() .. "Schnittstelle (WLAN).")
-                       dev:depends("netconfig", "1")
-                       dev.rmempty = false
-                       function dev.cfgvalue(self, section)
-                               return uci:get("freifunk", "wizard", "device_" .. device)
-                       end
-                       function dev.write(self, sec, value)
-                               if value then
-                                       uci:set("freifunk", "wizard", "device_" .. device, value)
-                                       uci:save("freifunk")
-                               end
-                       end
-               local chan = f:field(ListValue, "chan_" .. device, device:upper() .. "  Freifunk Kanal einrichten", "Ihr Gerät und benachbarte Freifunk Knoten müssen auf demselben Kanal senden. Je nach Gerätetyp können Sie zwischen verschiedenen 2,4Ghz und 5Ghz Kanälen auswählen.")
-                       chan:depends("device_" .. device, "1")
-                       chan.rmempty = true
-                       function chan.cfgvalue(self, section)
-                               return uci:get("freifunk", "wizard", "chan_" .. device)
-                       end
-
-                       chan:value('default')
-                       for _, f in ipairs(sys.wifi.channels(device)) do
-                               if not f.restricted then
-                                       chan:value(f.channel)
-                               end
-                       end
-
-                       function chan.write(self, sec, value)
-                               if value then
-                                       uci:set("freifunk", "wizard", "chan_" .. device, value)
-                                       uci:save("freifunk")
-                               end
-                       end
-
-                       local meship = f:field(Value, "meship_" .. device, device:upper() .. "  Mesh IP Adresse einrichten", "Ihre Mesh IP Adresse erhalten Sie von der Freifunk Gemeinschaft in Ihrer Nachbarschaft. Es ist eine netzweit eindeutige Identifikation, z.B. 104.1.1.1.")
-                       meship:depends("device_" .. device, "1")
-                       meship.rmempty = true
-                       function meship.cfgvalue(self, section)
-                               return uci:get("freifunk", "wizard", "meship_" .. device)
-                       end
-                       function meship.validate(self, value)
-                               local x = ip.IPv4(value)
-                               return ( x and x:prefix() == 32 ) and x:string() or ""
-                       end
-                       function meship.write(self, sec, value)
-                               uci:set("freifunk", "wizard", "meship_" .. device, value)
-                               local new_ip = ip.IPv4(value)
-                               if new_ip then
-                                       local new_hostname = new_ip:string():gsub("%.", "-")
-                                       uci:set("freifunk", "wizard", "hostname", new_hostname)
-                                       uci:save("freifunk")
-                               end
-                       end
-               if has_ipv6 then
-                       local meship6 = f:field(Value, "meship6_" .. device, device:upper() .. "  Mesh IPv6 Adresse einrichten", "Ihre Mesh IP Adresse wird automatisch berechnet")
-                       meship6:depends("device_" .. device, "1")
-                       meship6.rmempty = true
-                       function meship6.cfgvalue(self, section)
-                               return get_ula(get_mac(device))
-                       end
-               end
-       
-               local client = f:field(Flag, "client_" .. device, device:upper() .. "  DHCP anbieten", "DHCP weist verbundenen Benutzern automatisch eine Adresse zu. Diese Option sollten Sie unbedingt aktivieren, wenn Sie Nutzer an der drahtlosen Schnittstelle erwarten.")
-                       client:depends("device_" .. device, "1")
-                       client.rmempty = false
-                       function client.cfgvalue(self, section)
-                               return uci:get("freifunk", "wizard", "client_" .. device)
-                       end
-                       function client.write(self, sec, value)
-                               uci:set("freifunk", "wizard", "client_" .. device, value)
-                               uci:save("freifunk")
-                       end
-               local dhcpmesh = f:field(Value, "dhcpmesh_" .. device, device:upper() .. "  Mesh DHCP anbieten", "Bestimmen Sie den Adressbereich aus dem Ihre Nutzer IP Adressen erhalten. Es wird empfohlen einen Adressbereich aus Ihrer lokalen Freifunk Gemeinschaft zu nutzen. Der Adressbereich ist ein netzweit eindeutiger Netzbereich. z.B. 104.1.2.1/28")
-                       dhcpmesh:depends("client_" .. device, "1")
-                       dhcpmesh.rmempty = true
-                       function dhcpmesh.cfgvalue(self, section)
-                               return uci:get("freifunk", "wizard", "dhcpmesh_" .. device)
-                       end
-                       function dhcpmesh.validate(self, value)
-                               local x = ip.IPv4(value)
-                               return ( x and x:minhost()) and x:string() or ""
-                       end
-                       function dhcpmesh.write(self, sec, value)
-                               uci:set("freifunk", "wizard", "dhcpmesh_" .. device, value)
-                               uci:save("freifunk")
-                       end
-               local hwtype = section.type
-               if hwtype == "atheros" then
-                       local vap = f:field(Flag, "vap_" .. device , "Virtueller Drahtloser Zugangspunkt", "Konfigurieren Sie Ihren Virtuellen AP")
-                       vap:depends("client_" .. device, "1")
-                       vap.rmempty = false
-                       function vap.cfgvalue(self, section)
-                               return uci:get("freifunk", "wizard", "vap_" .. device)
-                       end
-                       function vap.write(self, sec, value)
-                               uci:set("freifunk", "wizard", "vap_" .. device, value)
-                               uci:save("freifunk")
-                       end
-               end
-       end)
-
-uci:foreach("network", "interface",
-       function(section)
-               local device = section[".name"]
-               local ifname = uci_state:get("network",device,"ifname")
-               if device ~= "loopback" and not string.find(device, "gvpn")  and not string.find(device, "wifi") and not string.find(device, "wl") and not string.find(device, "wlan") and not string.find(device, "wireless") and not string.find(device, "radio") then
-                       dev = f:field(Flag, "device_" .. device , "<b>Drahtgebundenes Netzwerk \"" .. device:upper() .. "\"</b>", "Konfigurieren Sie Ihre drahtgebunde " .. device:upper() .. " Schnittstelle (LAN).")
-                               dev:depends("netconfig", "1")
-                               dev.rmempty = false
-                               function dev.cfgvalue(self, section)
-                                       return uci:get("freifunk", "wizard", "device_" .. device)
-                               end
-                               function dev.write(self, sec, value)
-                                       uci:set("freifunk", "wizard", "device_" .. device, value)
-                                       uci:save("freifunk")
-                               end
-                       meship = f:field(Value, "meship_" .. device, device:upper() .. "  Mesh IP Adresse einrichten", "Ihre Mesh IP Adresse erhalten Sie von der Freifunk Gemeinschaft in Ihrer Nachbarschaft. Es ist eine netzweit eindeutige Identifikation, z.B. 104.1.1.1.")
-                               meship:depends("device_" .. device, "1")
-                               meship.rmempty = true
-                               function meship.cfgvalue(self, section)
-                                       return uci:get("freifunk", "wizard", "meship_" .. device)
-                               end
-                               function meship.validate(self, value)
-                                       local x = ip.IPv4(value)
-                                       return ( x and x:prefix() == 32 ) and x:string() or ""
-                               end
-                               function meship.write(self, sec, value)
-                                       uci:set("freifunk", "wizard", "meship_" .. device, value)
-                               end
-                       if has_ipv6 then
-                               meship6 = f:field(Value, "meship6_" .. device, device:upper() .. "  Mesh IPv6 Adresse einrichten", "Ihre Mesh IP Adresse wird automatisch berechnet")
-                               meship6:depends("device_" .. device, "1")
-                               meship6.rmempty = true
-                               function meship6.cfgvalue(self, section)
-                                       return get_ula(get_mac(ifname))
-                               end
-                       end
-
-                       client = f:field(Flag, "client_" .. device, device:upper() .. "  DHCP anbieten","DHCP weist verbundenen Benutzern automatisch eine Adresse zu. Diese Option sollten Sie unbedingt aktivieren, wenn Sie Nutzer an der drahtlosen Schnittstelle erwarten.")
-                               client:depends("device_" .. device, "1")
-                               client.rmempty = false
-                               function client.cfgvalue(self, section)
-                                       return uci:get("freifunk", "wizard", "client_" .. device)
-                               end
-                               function client.write(self, sec, value)
-                                       uci:set("freifunk", "wizard", "client_" .. device, value)
-                                       uci:save("freifunk")
-                               end
-                       dhcpmesh = f:field(Value, "dhcpmesh_" .. device, device:upper() .. "  Mesh DHCP anbieten ", "Bestimmen Sie den Adressbereich aus dem Ihre Nutzer IP Adressen erhalten. Es wird empfohlen einen Adressbereich aus Ihrer lokalen Freifunk Gemeinschaft zu nutzen. Der Adressbereich ist ein netzweit eindeutiger Netzbereich. z.B. 104.1.2.1/28")
-                               dhcpmesh:depends("client_" .. device, "1")
-                               dhcpmesh.rmempty = true
-                               function dhcpmesh.cfgvalue(self, section)
-                                       return uci:get("freifunk", "wizard", "dhcpmesh_" .. device)
-                               end
-                               function dhcpmesh.validate(self, value)
-                                       local x = ip.IPv4(value)
-                                       return ( x and x:prefix() <= 30 and x:minhost()) and x:string() or ""
-                               end
-                               function dhcpmesh.write(self, sec, value)
-                                       uci:set("freifunk", "wizard", "dhcpmesh_" .. device, value)
-                                       uci:save("freifunk")
-                               end
-               end
-       end)
-
-
-local syslat = uci:get("freifunk", "wizard", "latitude") or 52
-local syslon = uci:get("freifunk", "wizard", "longitude") or 10
-uci:foreach("system", "system", function(s)
-               if s.latitude then
-                       syslat = s.latitude
-               end
-               if s.longitude then
-                       syslon = s.longitude
-               end
-end)
-uci:foreach("olsrd", "LoadPlugin", function(s)
-       if s.library == "olsrd_nameservice.so.0.3" then
-               if s.lat then
-                       syslat = s.lat
-               end
-               if s.lon then
-                       syslon = s.lon
-               end
-       end
-end)
-
-lat = f:field(Value, "lat", "geographischer Breitengrad", "Setzen Sie den Breitengrad (Latitude) Ihres Geräts.")
-lat:depends("netconfig", "1")
-function lat.cfgvalue(self, section)
-       return syslat
-end
-function lat.write(self, section, value)
-       uci:set("freifunk", "wizard", "latitude", value)
-       uci:save("freifunk")
-end
-
-lon = f:field(Value, "lon", "geograpischer Längengrad", "Setzen Sie den Längengrad (Longitude) Ihres Geräts.")
-lon:depends("netconfig", "1")
-function lon.cfgvalue(self, section)
-       return syslon
-end
-function lon.write(self, section, value)
-       uci:set("freifunk", "wizard", "longitude", value)
-       uci:save("freifunk")
-end
-
---[[
-*Opens an OpenStreetMap iframe or popup
-*Makes use of resources/OSMLatLon.htm and htdocs/resources/osm.js
-(is that the right place for files like these?)
-]]--
-
-local class = util.class
-
-OpenStreetMapLonLat = class(AbstractValue)
-
-function OpenStreetMapLonLat.__init__(self, ...)
-       AbstractValue.__init__(self, ...)
-       self.template = "cbi/osmll_value"
-       self.latfield = nil
-       self.lonfield = nil
-       self.centerlat = ""
-       self.centerlon = ""
-       self.zoom = "0"
-       self.width = "100%" --popups will ignore the %-symbol, "100%" is interpreted as "100"
-       self.height = "600"
-       self.popup = false
-       self.displaytext="OpenStreetMap" --text on button, that loads and displays the OSMap
-       self.hidetext="X" -- text on button, that hides OSMap
-end
-
-osm = f:field(OpenStreetMapLonLat, "latlon", "Geokoordinaten mit OpenStreetMap ermitteln:", "Klicken Sie auf Ihren Standort in der Karte. Diese Karte funktioniert nur, wenn das Gerät bereits eine Verbindung zum Internet hat.")
-osm:depends("netconfig", "1")
-osm.latfield = "lat"
-osm.lonfield = "lon"
-osm.centerlat = syslat
-osm.centerlon = syslon
-osm.width = "100%"
-osm.height = "600"
-osm.popup = false
-syslatlengh = string.len(syslat)
-if syslatlengh > 7 then
-       osm.zoom = "15"
-elseif syslatlengh > 5 then
-       osm.zoom = "12"
-else
-       osm.zoom = "6"
-end
-osm.displaytext="OpenStreetMap anzeigen"
-osm.hidetext="OpenStreetMap verbergen"
-
-share = f:field(Flag, "sharenet", "Eigenen Internetzugang freigeben", "Geben Sie Ihren Internetzugang im Freifunknetz frei.")
-share.rmempty = false
-share:depends("netconfig", "1")
-function share.cfgvalue(self, section)
-       return uci:get("freifunk", "wizard", "share")
-end
-function share.write(self, section, value)
-       uci:set("freifunk", "wizard", "share", value)
-       uci:save("freifunk")
-end
-
-wanproto = f:field(ListValue, "wanproto", "Protokoll des Internetzugangs", "Geben Sie das Protokol an ueber das eine Internet verbindung hergestellt werden kann.")
-wanproto:depends("sharenet", "1")
-wanproto:value("static", translate("manual", "manual"))
-wanproto:value("dhcp", translate("automatic", "automatic"))
-if has_pppoe then wanproto:value("pppoe", "PPPoE") end
-if has_pptp  then wanproto:value("pptp",  "PPTP")  end
-function wanproto.cfgvalue(self, section)
-       return uci:get("network", "wan", "proto") or "dhcp"
-end
-function wanproto.write(self, section, value)
-       uci:set("network", "wan", "proto", value)
-       uci:save("network")
-end
-wanip = f:field(Value, "wanipaddr", translate("ipaddress"))
-wanip:depends("wanproto", "static")
-function wanip.cfgvalue(self, section)
-       return uci:get("network", "wan", "ipaddr")
-end
-function wanip.write(self, section, value)
-       uci:set("network", "wan", "ipaddr", value)
-       uci:save("network")
-end
-wannm = f:field(Value, "wannetmask", translate("netmask"))
-wannm:depends("wanproto", "static")
-function wannm.cfgvalue(self, section)
-       return uci:get("network", "wan", "netmask")
-end
-function wannm.write(self, section, value)
-       uci:set("network", "wan", "netmask", value)
-       uci:save("network")
-end
-wangw = f:field(Value, "wangateway", translate("gateway"))
-wangw:depends("wanproto", "static")
-wangw.rmempty = true
-function wangw.cfgvalue(self, section)
-       return uci:get("network", "wan", "gateway")
-end
-function wangw.write(self, section, value)
-       uci:set("network", "wan", "gateway", value)
-       uci:save("network")
-end
-wandns = f:field(Value, "wandns", translate("dnsserver"))
-wandns:depends("wanproto", "static")
-wandns.rmempty = true
-function wandns.cfgvalue(self, section)
-       return uci:get("network", "wan", "dns")
-end
-function wandns.write(self, section, value)
-       uci:set("network", "wan", "dns", value)
-       uci:save("network")
-end
-wanusr = f:field(Value, "wanusername", translate("username"))
-wanusr:depends("wanproto", "pppoe")
-wanusr:depends("wanproto", "pptp")
-function wanusr.cfgvalue(self, section)
-       return uci:get("network", "wan", "username")
-end
-function wanusr.write(self, section, value)
-       uci:set("network", "wan", "username", value)
-       uci:save("network")
-end
-wanpwd = f:field(Value, "wanpassword", translate("password"))
-wanpwd.password = true
-wanpwd:depends("wanproto", "pppoe")
-wanpwd:depends("wanproto", "pptp")
-function wanpwd.cfgvalue(self, section)
-       return uci:get("network", "wan", "password")
-end
-function wanpwd.write(self, section, value)
-       uci:set("network", "wan", "password", value)
-       uci:save("network")
-end
-
-wansec = f:field(Flag, "wansec", "WAN-Zugriff auf Gateway beschränken", "Verbieten Sie Zugriffe auf Ihr lokales Netzwerk aus dem Freifunknetz.")
-wansec.rmempty = false
-wansec:depends("wanproto", "static")
-wansec:depends("wanproto", "dhcp")
-function wansec.cfgvalue(self, section)
-       return uci:get("freifunk", "wizard", "wan_security")
-end
-function wansec.write(self, section, value)
-       uci:set("freifunk", "wizard", "wan_security", value)
-       uci:save("freifunk")
-end
-if has_qos then
-       wanqosdown = f:field(Value, "wanqosdown", "Download Bandbreite begrenzen", "kb/s")
-       wanqosdown:depends("sharenet", "1")
-       function wanqosdown.cfgvalue(self, section)
-               return uci:get("qos", "wan", "download")
-       end
-       function wanqosdown.write(self, section, value)
-               uci:set("qos", "wan", "download", value)
-               uci:save("qos")
-       end
-       wanqosup = f:field(Value, "wanqosup", "Upload Bandbreite begrenzen", "kb/s")
-       wanqosup:depends("sharenet", "1")
-       function wanqosup.cfgvalue(self, section)
-               return uci:get("qos", "wan", "upload")
-       end
-       function wanqosup.write(self, section, value)
-               uci:set("qos", "wan", "upload", value)
-               uci:save("qos")
-       end
-end
-
-if has_l2gvpn then
-       gvpn = f:field(Flag, "gvpn", "Freifunk Internet Tunnel", "Verbinden Sie ihren Router ueber das Internet mit anderen Freifunknetzen.")
-       gvpn.rmempty = false
-       gvpn:depends("sharenet", "1")
-       function gvpn.cfgvalue(self, section)
-               return uci:get("freifunk", "wizard", "gvpn")
-       end
-       function gvpn.write(self, section, value)
-               uci:set("freifunk", "wizard", "gvpn", value)
-               uci:save("freifunk")
-       end
-       gvpnip = f:field(Value, "gvpnipaddr", translate("ipaddress"))
-       gvpnip:depends("gvpn", "1")
-       function gvpnip.cfgvalue(self, section)
-               return uci:get("l2gvpn", "bbb", "ip") or uci:get("network", "gvpn", "ipaddr")
-       end
-       function gvpnip.validate(self, value)
-               local x = ip.IPv4(value)
-               return ( x and x:prefix() == 32 ) and x:string() or ""
-       end
-end
-
-if has_hb then
-       hb = f:field(Flag, "hb", "Heartbeat aktivieren","Dem Gerät erlauben anonyme Statistiken zu Ã¼bertragen. (empfohlen)")
-       hb.rmempty = false
-       hb:depends("netconfig", "1")
-       function hb.cfgvalue(self, section)
-               return uci:get("freifunk", "wizard", "hb")
-       end
-       function hb.write(self, section, value)
-               uci:set("freifunk", "wizard", "hb", value)
-               uci:save("freifunk")
-       end
-end
-
--------------------- Control --------------------
-function f.handle(self, state, data)
-       if state == FORM_VALID then
-               local debug = uci:get("freifunk", "wizard", "debug")
-               if debug == "1" then
-                       if data.pw1 then
-                               local stat = luci.sys.user.setpasswd("root", data.pw1) == 0
-                               if stat then
-                                       f.message = translate("a_s_changepw_changed")
-                               else
-                                       f.errmessage = translate("unknownerror")
-                               end
-                       end
-                       data.pw1 = nil
-                       data.pw2 = nil
-                       luci.http.redirect(luci.dispatcher.build_url(unpack(luci.dispatcher.context.requested.path), "system", "system"))
-               else
-                       if data.pw1 then
-                               local stat = luci.sys.user.setpasswd("root", data.pw1) == 0
-                       end
-                       data.pw1 = nil
-                       data.pw2 = nil
-                       uci:commit("freifunk")
-                       uci:commit("wireless")
-                       uci:commit("network")
-                       uci:commit("dhcp")
-                       uci:commit("luci_splash")
-                       uci:commit("firewall")
-                       uci:commit("system")
-                       uci:commit("uhttpd")
-                       uci:commit("olsrd")
-                       uci:commit("manager")
-                       if has_autoipv6 then
-                               uci:commit("autoipv6")
-                       end
-                       if has_qos then
-                               uci:commit("qos")
-                       end
-                       if has_l2gvpn then
-                               uci:commit("l2gvpn")
-                       end
-                       if has_radvd then
-                               uci:commit("radvd")
-                       end
-
-                       sys.exec("for s in network dnsmasq luci_splash firewall uhttpd olsrd radvd l2gvpn; do [ -x /etc/init.d/$s ] && /etc/init.d/$s restart;done > /dev/null &")
-                       luci.http.redirect(luci.dispatcher.build_url(luci.dispatcher.context.path[1], "freifunk", "ffwizard"))
-               end
-               return false
-       elseif state == FORM_INVALID then
-               self.errmessage = "Ungültige Eingabe: Bitte die Formularfelder auf Fehler prüfen."
-       end
-       return true
-end
-
-local function _strip_internals(tbl)
-       tbl = tbl or {}
-       for k, v in pairs(tbl) do
-               if k:sub(1, 1) == "." then
-                       tbl[k] = nil
-               end
-       end
-       return tbl
-end
--- Configure Freifunk checked
-function main.write(self, section, value)
-       if value == "0" then
-               uci:set("freifunk", "wizard", "netconfig", "0")
-               uci:save("freifunk")
-               return
-       end
-       -- Collect IP-Address
-       local community = net:formvalue(section)
-       suffix = uci:get("freifunk", community, "suffix") or "olsr"
-
-       -- Invalidate fields
-       if not community then
-               net.tag_missing[section] = true
-               return
-       end
-
-       uci:set("freifunk", "wizard", "netconfig", "1")
-       uci:save("freifunk")
-
-       local external
-       external = uci:get("freifunk", community, "external") or ""
-
-       local netname = "wireless"
-       local network
-       network = ip.IPv4(uci:get("freifunk", community, "mesh_network") or "104.0.0.0/8")
-
-       -- Tune community settings
-       if community and uci:get("freifunk", community) then
-               uci:tset("freifunk", "community", uci:get_all("freifunk", community))
-       end
-
-       -- Cleanup
-       uci:delete_all("firewall","zone", {name="freifunk"})
-       uci:delete_all("firewall","forwarding", {dest="freifunk"})
-       uci:delete_all("firewall","forwarding", {src="freifunk"})
-       uci:delete_all("firewall","rule", {dest="freifunk"})
-       uci:delete_all("firewall","rule", {src="freifunk"})
-       uci:save("firewall")
-       -- Create firewall zone and add default rules (first time)
-       --                    firewall_create_zone("name"    , "input" , "output", "forward ", Masqurade)
-       local newzone = tools.firewall_create_zone("freifunk", "ACCEPT", "ACCEPT", "REJECT"  , true)
-       if newzone then
-               uci:foreach("freifunk", "fw_forwarding", function(section)
-                       uci:section("firewall", "forwarding", nil, section)
-               end)
-               uci:foreach(external, "fw_forwarding", function(section)
-                       uci:section("firewall", "forwarding", nil, section)
-               end)
-
-               uci:foreach("freifunk", "fw_rule", function(section)
-                       uci:section("firewall", "rule", nil, section)
-               end)
-               uci:foreach(external, "fw_rule", function(section)
-                       uci:section("firewall", "rule", nil, section)
-               end)
-       end
-       uci:save("firewall")
-       if has_hb then
-               uci:delete("manager", "heartbeat", "interface")
-               uci:save("manager")
-       end
-       -- Delete olsrdv4
-       uci:delete_all("olsrd", "olsrd")
-       local olsrbase
-       olsrbase = uci:get_all("freifunk", "olsrd") or {}
-       util.update(olsrbase, uci:get_all(external, "olsrd") or {})
-       if has_ipv6 then
-               olsrbase.IpVersion='6and4'
-       else
-               olsrbase.IpVersion='4'
-       end
-       uci:section("olsrd", "olsrd", nil, olsrbase)
-       -- Delete olsrdv4 old p2pd settings
-       uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_mdns.so.1.0.0"})
-       uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_p2pd.so.0.1.0"})
-       -- Write olsrdv4 new p2pd settings
-       uci:section("olsrd", "LoadPlugin", nil, {
-               library     = "olsrd_p2pd.so.0.1.0",
-               P2pdTtl     = 10,
-               UdpDestPort = "224.0.0.251 5353",
-               ignore      = 1,
-       })
-       -- Delete http plugin
-       uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_httpinfo.so.0.1"})
-
-       -- Delete olsrdv4 old interface
-       uci:delete_all("olsrd", "Interface")
-       uci:delete_all("olsrd", "Hna4")
-       -- Create wireless ip4/ip6 and firewall config
-       uci:foreach("wireless", "wifi-device",
-       function(sec)
-               local device = sec[".name"]
-               if not luci.http.formvalue("cbid.ffwizward.1.device_" .. device) then
-                       return
-               end
-               node_ip = luci.http.formvalue("cbid.ffwizward.1.meship_" .. device) and ip.IPv4(luci.http.formvalue("cbid.ffwizward.1.meship_" .. device))
-               if has_ipv6 then
-                       node_ip6 = luci.http.formvalue("cbid.ffwizward.1.meship6_" .. device) and ip.IPv6(luci.http.formvalue("cbid.ffwizward.1.meship6_" .. device))
-               end
-               if not node_ip or not network or not network:contains(node_ip) then
-                       meship.tag_missing[section] = true
-                       node_ip = nil
-                       return
-               end
-               -- rename the wireless interface s/wifi/wireless/
-               local nif
-               if string.find(device, "wifi") then
-                       nif = string.gsub(device,"wifi", netname)
-               elseif string.find(device, "wl") then
-                       nif = string.gsub(device,"wl", netname)
-               elseif string.find(device, "wlan") then
-                       nif = string.gsub(device,"wlan", netname)
-               elseif string.find(device, "radio") then
-                       nif = string.gsub(device,"radio", netname)
-               end
-               -- Cleanup
-               tools.wifi_delete_ifaces(device)
-               -- tools.network_remove_interface(device)
-               uci:delete("network", device .. "dhcp")
-               uci:delete("network", device)
-               tools.firewall_zone_remove_interface("freifunk", device)
-               -- tools.network_remove_interface(nif)
-               uci:delete("network", nif .. "dhcp")
-               uci:delete("network", nif)
-               tools.firewall_zone_remove_interface("freifunk", nif)
-               -- Delete old dhcp
-               uci:delete("dhcp", device)
-               uci:delete("dhcp", device .. "dhcp")
-               uci:delete("dhcp", nif)
-               uci:delete("dhcp", nif .. "dhcp")
-               -- Delete old splash
-               uci:delete_all("luci_splash", "iface", {network=device.."dhcp", zone="freifunk"})
-               uci:delete_all("luci_splash", "iface", {network=nif.."dhcp", zone="freifunk"})
-               -- Delete old radvd
-               if has_radvd then
-                       uci:delete_all("radvd", "interface", {interface=nif.."dhcp"})
-                       uci:delete_all("radvd", "interface", {interface=nif})
-                       uci:delete_all("radvd", "prefix", {interface=nif.."dhcp"})
-                       uci:delete_all("radvd", "prefix", {interface=nif})
-               end
-               -- New Config
-               -- Tune wifi device
-               local ssid = uci:get("freifunk", community, "ssid") or "olsr.freifunk.net"
-               local devconfig = uci:get_all("freifunk", "wifi_device")
-               util.update(devconfig, uci:get_all(external, "wifi_device") or {})
-               local channel = luci.http.formvalue("cbid.ffwizward.1.chan_" .. device)
-               local hwmode = "11bg"
-               local bssid = uci:get_all(external, "wifi_iface", "bssid") or "02:CA:FF:EE:BA:BE"
-               local mrate = 5500
-               -- set bssid, see https://kifuse02.pberg.freifunk.net/moin/channel-bssid-essid for schema
-               if channel and channel ~= "default" then
-                       if devconfig.channel ~= channel then
-                               devconfig.channel = channel
-                               local chan = tonumber(channel)
-                               if chan >= 0 and chan < 10 then
-                                       bssid = channel .. "2:CA:FF:EE:BA:BE"
-                               elseif chan == 10 then 
-                                       bssid = "02:CA:FF:EE:BA:BE" 
-                               elseif chan >= 11 and chan <= 14 then
-                                       bssid = string.format("%X",channel) .. "2:CA:FF:EE:BA:BE"
-                               elseif chan >= 36 and chan <= 64 then
-                                       hwmode = "11a"
-                                       mrate = ""
-                                       outdoor = 0
-                                       bssid = "00:" .. channel ..":CA:FF:EE:EE"
-                               elseif chan >= 100 and chan <= 140 then
-                                       hwmode = "11a"
-                                       mrate = ""
-                                       outdoor = 1
-                                       bssid = "01:" .. string.sub(channel, 2) .. ":CA:FF:EE:EE"
-                               end
-                               devconfig.hwmode = hwmode
-                               devconfig.outdoor = outdoor
-                       end
-                       ssid = ssid .. " - ch" .. channel
-               end
-               uci:tset("wireless", device, devconfig)
-               -- Create wifi iface
-               local ifconfig = uci:get_all("freifunk", "wifi_iface")
-               util.update(ifconfig, uci:get_all(external, "wifi_iface") or {})
-               ifconfig.device = device
-               ifconfig.network = nif
-               ifconfig.ssid = ssid
-               ifconfig.bssid = bssid
-               ifconfig.encryption="none"
-               -- Read Preset 
-               local netconfig = uci:get_all("freifunk", "interface")
-               util.update(netconfig, uci:get_all(external, "interface") or {})
-               netconfig.proto = "static"
-               netconfig.ipaddr = node_ip:string()
-               if has_ipv6 then
-                       netconfig.ip6addr = node_ip6:string()
-               end
-               uci:section("network", "interface", nif, netconfig)
-               if has_radvd then
-                       uci:section("radvd", "interface", nil, {
-                               interface          =nif,
-                               AdvSendAdvert      =1,
-                               AdvManagedFlag     =0,
-                               AdvOtherConfigFlag =0,
-                               ignore             =0
-                       })
-                       uci:section("radvd", "prefix", nil, {
-                               interface          =nif,
-                               AdvOnLink          =1,
-                               AdvAutonomous      =1,
-                               AdvRouterAddr      =0,
-                               ignore             =0,
-                       })
-                       uci:save("radvd")
-               end
-               local new_hostname = node_ip:string():gsub("%.", "-")
-               uci:set("freifunk", "wizard", "hostname", new_hostname)
-               uci:save("freifunk")
-               tools.firewall_zone_add_interface("freifunk", nif)
-               uci:save("firewall")
-               -- Write new olsrv4 interface
-               local olsrifbase = uci:get_all("freifunk", "olsr_interface")
-               util.update(olsrifbase, uci:get_all(external, "olsr_interface") or {})
-               olsrifbase.interface = nif
-               olsrifbase.ignore    = "0"
-               uci:section("olsrd", "Interface", nil, olsrifbase)
-               -- Collect MESH DHCP IP NET
-               local client = luci.http.formvalue("cbid.ffwizward.1.client_" .. device)
-               if client then
-                       local dhcpmeshnet = luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device) and ip.IPv4(luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device))
-                       if has_hb then
-                               local ifacelist = uci:get_list("manager", "heartbeat", "interface") or {}
-                               table.insert(ifacelist,nif .. "dhcp")
-                               uci:set_list("manager", "heartbeat", "interface", ifacelist)
-                               uci:save("manager")
-                       end
-                       if dhcpmeshnet then
-                               if not dhcpmeshnet:minhost() or not dhcpmeshnet:mask() then
-                                       dhcpmesh.tag_missing[section] = true
-                                       dhcpmeshnet = nil
-                                       return
-                               end
-                               dhcp_ip = dhcpmeshnet:minhost():string()
-                               dhcp_mask = dhcpmeshnet:mask():string()
-                               dhcp_network = dhcpmeshnet:network():string()
-                               uci:section("olsrd", "Hna4", nil, {
-                                       netmask  = dhcp_mask,
-                                       netaddr  = dhcp_network
-                               })
-                               uci:foreach("olsrd", "LoadPlugin",
-                                       function(s)             
-                                               if s.library == "olsrd_p2pd.so.0.1.0" then
-                                                       uci:set("olsrd", s['.name'], "ignore", "0")
-                                                       local nonolsr = uci:get("olsrd", s['.name'], "NonOlsrIf") or ""
-                                                       vap = luci.http.formvalue("cbid.ffwizward.1.vap_" .. device)
-                                                       if vap then
-                                                               nonolsr = nif.."dhcp "..nonolsr
-                                                       else
-                                                               nonolsr = nif.." "..nonolsr
-                                                       end
-                                                       uci:set("olsrd", s['.name'], "NonOlsrIf", nonolsr)
-                                               end
-                                       end)
-                       else
-                               local subnet_prefix = tonumber(uci:get("freifunk", community, "splash_prefix")) or 27
-                               local pool_network = uci:get("freifunk", community, "splash_network") or "10.104.0.0/16"
-                               local pool = luci.ip.IPv4(pool_network)
-                               local ip = tostring(node_ip)
-                               if pool and ip then
-                                       local hosts_per_subnet = 2^(32 - subnet_prefix)
-                                       local number_of_subnets = (2^pool:prefix())/hosts_per_subnet
-                                       local seed1, seed2 = ip:match("(%d+)%.(%d+)$")
-                                       if seed1 and seed2 then
-                                               math.randomseed(seed1 * seed2)
-                                       end
-                                       local subnet = pool:add(hosts_per_subnet * math.random(number_of_subnets))
-                                       dhcp_ip = subnet:network(subnet_prefix):add(1):string()
-                                       dhcp_mask = subnet:mask(subnet_prefix):string()
-                               end
-                       end
-                       if dhcp_ip and dhcp_mask then
-                               -- Create alias
-                               local aliasbase = uci:get_all("freifunk", "alias")
-                               util.update(aliasbase, uci:get_all(external, "alias") or {})
-                               aliasbase.ipaddr = dhcp_ip
-                               aliasbase.netmask = dhcp_mask
-                               aliasbase.proto = "static"
-                               vap = luci.http.formvalue("cbid.ffwizward.1.vap_" .. device)
-                               if vap then
-                                       uci:section("network", "interface", nif .. "dhcp", aliasbase)
-                                       uci:section("wireless", "wifi-iface", nil, {
-                                               device     =device,
-                                               mode       ="ap",
-                                               encryption ="none",
-                                               network    =nif .. "dhcp",
-                                               ssid       ="AP-" .. ssid
-                                       })
-                                       if has_radvd then
-                                               uci:section("radvd", "interface", nil, {
-                                                       interface          =nif .. "dhcp",
-                                                       AdvSendAdvert      =1,
-                                                       AdvManagedFlag     =0,
-                                                       AdvOtherConfigFlag =0,
-                                                       ignore             =0
-                                               })
-                                               uci:section("radvd", "prefix", nil, {
-                                                       interface          =nif .. "dhcp",
-                                                       AdvOnLink          =1,
-                                                       AdvAutonomous      =1,
-                                                       AdvRouterAddr      =0,
-                                                       ignore             =0
-                                               })
-                                               uci:save("radvd")
-                                       end
-                                       tools.firewall_zone_add_interface("freifunk", nif .. "dhcp")
-                                       uci:save("wireless")
-                                       ifconfig.mcast_rate = nil
-                                       ifconfig.encryption="none"
-                               else
-                                       aliasbase.interface = nif
-                                       uci:section("network", "alias", nif .. "dhcp", aliasbase)
-                               end
-                               -- Create dhcp
-                               local dhcpbase = uci:get_all("freifunk", "dhcp")
-                               util.update(dhcpbase, uci:get_all(external, "dhcp") or {})
-                               dhcpbase.interface = nif .. "dhcp"
-                               dhcpbase.force = 1
-                               uci:section("dhcp", "dhcp", nif .. "dhcp", dhcpbase)
-                               uci:set_list("dhcp", nif .. "dhcp", "dhcp_option", "119,olsr")
-                               -- Create firewall settings
-                               uci:delete_all("firewall", "rule", {
-                                       src="freifunk",
-                                       proto="udp",
-                                       dest_port="53"
-                               })
-                               uci:section("firewall", "rule", nil, {
-                                       src="freifunk",
-                                       proto="udp",
-                                       dest_port="53",
-                                       target="ACCEPT"
-                               })
-                               uci:delete_all("firewall", "rule", {
-                                       src="freifunk",
-                                       proto="udp",
-                                       src_port="68",
-                                       dest_port="67"
-                               })
-                               uci:section("firewall", "rule", nil, {
-                                       src="freifunk",
-                                       proto="udp",
-                                       src_port="68",
-                                       dest_port="67",
-                                       target="ACCEPT"
-                               })
-                               uci:delete_all("firewall", "rule", {
-                                       src="freifunk",
-                                       proto="tcp",
-                                       dest_port="8082",
-                               })
-                               uci:section("firewall", "rule", nil, {
-                                       src="freifunk",
-                                       proto="tcp",
-                                       dest_port="8082",
-                                       target="ACCEPT"
-                               })
-                               -- Register splash
-                               uci:section("luci_splash", "iface", nil, {network=nif.."dhcp", zone="freifunk"})
-                               uci:save("luci_splash")
-                               -- Make sure that luci_splash is enabled
-                               sys.init.enable("luci_splash")
-                       end
-               else
-                       -- Delete old splash
-                       uci:delete_all("luci_splash", "iface", {network=device.."dhcp", zone="freifunk"})
-               end
-               --Write Ad-Hoc wifi section after AP wifi section
-               uci:section("wireless", "wifi-iface", nil, ifconfig)
-               uci:save("network")
-               uci:save("wireless")
-               uci:save("network")
-               uci:save("firewall")
-               uci:save("dhcp")
-       end)
-       -- Create wired ip and firewall config
-       uci:foreach("network", "interface",
-               function(sec)
-               local device = sec[".name"]
-               if not luci.http.formvalue("cbid.ffwizward.1.device_" .. device) then
-                       return
-               end
-               if device ~= "loopback" and not string.find(device, "wifi") and not string.find(device, "wl") and not string.find(device, "wlan") and not string.find(device, "wireless") and not string.find(device, "radio") then
-                       local node_ip
-                       node_ip = luci.http.formvalue("cbid.ffwizward.1.meship_" .. device) and ip.IPv4(luci.http.formvalue("cbid.ffwizward.1.meship_" .. device))
-                       if has_ipv6 then
-                               node_ip6 = luci.http.formvalue("cbid.ffwizward.1.meship6_" .. device) and ip.IPv6(luci.http.formvalue("cbid.ffwizward.1.meship6_" .. device))
-                       end
-                       if not node_ip or not network or not network:contains(node_ip) then
-                               meship.tag_missing[section] = true
-                               node_ip = nil
-                               return
-                       end
-                       -- Cleanup
-                       tools.firewall_zone_remove_interface(device, device)
-                       uci:delete_all("firewall","zone", {name=device})
-                       uci:delete_all("firewall","forwarding", {src=device})
-                       uci:delete_all("firewall","forwarding", {dest=device})
-                       uci:delete("network", device .. "dhcp")
-                       -- Delete old dhcp
-                       uci:delete("dhcp", device)
-                       uci:delete("dhcp", device .. "dhcp")
-                       -- Delete old splash
-                       uci:delete_all("luci_splash", "iface", {network=device.."dhcp", zone="freifunk"})
-                       if has_radvd then
-                               uci:delete_all("radvd", "interface", {interface=device.."dhcp"})
-                               uci:delete_all("radvd", "interface", {interface=device})
-                               uci:delete_all("radvd", "prefix", {interface=device.."dhcp"})
-                               uci:delete_all("radvd", "prefix", {interface=device})
-                       end
-                       -- New Config
-                       local netconfig = uci:get_all("freifunk", "interface")
-                       util.update(netconfig, uci:get_all(external, "interface") or {})
-                       netconfig.proto = "static"
-                       netconfig.ipaddr = node_ip:string()
-                       if has_ipv6 then
-                               netconfig.ip6addr = node_ip6:string()
-                       end
-                       uci:section("network", "interface", device, netconfig)
-                       uci:save("network")
-                       if has_radvd then
-                               uci:section("radvd", "interface", nil, {
-                                       interface          =device,
-                                       AdvSendAdvert      =1,
-                                       AdvManagedFlag     =0,
-                                       AdvOtherConfigFlag =0,
-                                       ignore             =0
-                               })
-                               uci:section("radvd", "prefix", nil, {
-                                       interface          =device,
-                                       AdvOnLink          =1,
-                                       AdvAutonomous      =1,
-                                       AdvRouterAddr      =0,
-                                       ignore             =0,
-                               })
-                               uci:save("radvd")
-                       end
-                       local new_hostname = node_ip:string():gsub("%.", "-")
-                       uci:set("freifunk", "wizard", "hostname", new_hostname)
-                       uci:save("freifunk")
-                       tools.firewall_zone_add_interface("freifunk", device)
-                       uci:save("firewall")
-                       -- Write new olsrv4 interface
-                       local olsrifbase = uci:get_all("freifunk", "olsr_interface")
-                       util.update(olsrifbase, uci:get_all(external, "olsr_interface") or {})
-                       olsrifbase.interface = device
-                       olsrifbase.ignore    = "0"
-                       uci:section("olsrd", "Interface", nil, olsrifbase)
-                       olsrifbase.Mode = 'ether'
-                       -- Collect MESH DHCP IP NET
-                       local client = luci.http.formvalue("cbid.ffwizward.1.client_" .. device)
-                       if client then
-                               local dhcpmeshnet = luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device) and ip.IPv4(luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device))
-                               if has_hb then
-                                       local ifacelist = uci:get_list("manager", "heartbeat", "interface") or {}
-                                       table.insert(ifacelist,device .. "dhcp")
-                                       uci:set_list("manager", "heartbeat", "interface", ifacelist)
-                                       uci:save("manager")
-                               end
-                               if dhcpmeshnet then
-                                       if not dhcpmeshnet:minhost() or not dhcpmeshnet:mask() then
-                                               dhcpmesh.tag_missing[section] = true
-                                               dhcpmeshnet = nil
-                                               return
-                                       end
-                                       dhcp_ip = dhcpmeshnet:minhost():string()
-                                       dhcp_mask = dhcpmeshnet:mask():string()
-                                       dhcp_network = dhcpmeshnet:network():string()
-                                       uci:section("olsrd", "Hna4", nil, {
-                                               netmask  = dhcp_mask,
-                                               netaddr  = dhcp_network
-                                       })
-                                       uci:foreach("olsrd", "LoadPlugin",
-                                               function(s)             
-                                                       if s.library == "olsrd_p2pd.so.0.1.0" then
-                                                               uci:set("olsrd", s['.name'], "ignore", "0")
-                                                               local nonolsr = uci:get("olsrd", s['.name'], "NonOlsrIf") or ""
-                                                               uci:set("olsrd", s['.name'], "NonOlsrIf", device .." ".. nonolsr)
-                                                       end
-                                               end)
-                               else
-                                       local subnet_prefix = tonumber(uci:get("freifunk", community, "splash_prefix")) or 27
-                                       local pool_network = uci:get("freifunk", community, "splash_network") or "10.104.0.0/16"
-                                       local pool = luci.ip.IPv4(pool_network)
-                                       local ip = tostring(node_ip)
-                                       if pool and ip then
-                                               local hosts_per_subnet = 2^(32 - subnet_prefix)
-                                               local number_of_subnets = (2^pool:prefix())/hosts_per_subnet
-                                               local seed1, seed2 = ip:match("(%d+)%.(%d+)$")
-                                               if seed1 and seed2 then
-                                                       math.randomseed(seed1 * seed2)
-                                               end
-                                               local subnet = pool:add(hosts_per_subnet * math.random(number_of_subnets))
-                                               dhcp_ip = subnet:network(subnet_prefix):add(1):string()
-                                               dhcp_mask = subnet:mask(subnet_prefix):string()
-                                       end
-                               end
-                               if dhcp_ip and dhcp_mask then
-                                       -- Create alias
-                                       local aliasbase = uci:get_all("freifunk", "alias")
-                                       util.update(aliasbase, uci:get_all(external, "alias") or {})
-                                       aliasbase.interface = device
-                                       aliasbase.ipaddr = dhcp_ip
-                                       aliasbase.netmask = dhcp_mask
-                                       aliasbase.proto = "static"
-                                       uci:section("network", "alias", device .. "dhcp", aliasbase)
-                                       -- Create dhcp
-                                       local dhcpbase = uci:get_all("freifunk", "dhcp")
-                                       util.update(dhcpbase, uci:get_all(external, "dhcp") or {})
-                                       dhcpbase.interface = device .. "dhcp"
-                                       dhcpbase.force = 1
-                                       uci:section("dhcp", "dhcp", device .. "dhcp", dhcpbase)
-                                       uci:set_list("dhcp", device .. "dhcp", "dhcp_option", "119,olsr")
-                                       -- Create firewall settings
-                                       uci:delete_all("firewall", "rule", {
-                                               src="freifunk",
-                                               proto="udp",
-                                               dest_port="53"
-                                       })
-                                       uci:section("firewall", "rule", nil, {
-                                               src="freifunk",
-                                               proto="udp",
-                                               dest_port="53",
-                                               target="ACCEPT"
-                                       })
-                                       uci:delete_all("firewall", "rule", {
-                                               src="freifunk",
-                                               proto="udp",
-                                               src_port="68",
-                                               dest_port="67"
-                                       })
-                                       uci:section("firewall", "rule", nil, {
-                                               src="freifunk",
-                                               proto="udp",
-                                               src_port="68",
-                                               dest_port="67",
-                                               target="ACCEPT"
-                                       })
-                                       uci:delete_all("firewall", "rule", {
-                                               src="freifunk",
-                                               proto="tcp",
-                                               dest_port="8082",
-                                       })
-                                       uci:section("firewall", "rule", nil, {
-                                               src="freifunk",
-                                               proto="tcp",
-                                               dest_port="8082",
-                                               target="ACCEPT"
-                                       })
-                                       -- Register splash
-                                       uci:section("luci_splash", "iface", nil, {network=device.."dhcp", zone="freifunk"})
-                                       uci:save("luci_splash")
-                                       -- Make sure that luci_splash is enabled
-                                       sys.init.enable("luci_splash")
-                               end
-                       end
-                       uci:save("wireless")
-                       uci:save("network")
-                       uci:save("firewall")
-                       uci:save("dhcp")
-               end
-       end)
-       --enable radvd
-       if has_radvd then
-               sys.init.enable("radvd")
-       end
-       -- Enforce firewall include
-       local has_include = false
-       uci:foreach("firewall", "include",
-               function(section)
-                       if section.path == "/etc/firewall.freifunk" then
-                               has_include = true
-                       end
-               end)
-
-       if not has_include then
-               uci:section("firewall", "include", nil,
-                       { path = "/etc/firewall.freifunk" })
-       end
-       -- Allow state: invalid packets
-       uci:foreach("firewall", "defaults",
-               function(section)
-                       uci:set("firewall", section[".name"], "drop_invalid", "0")
-               end)
-
-       -- Prepare advanced config
-       local has_advanced = false
-       uci:foreach("firewall", "advanced",
-               function(section) has_advanced = true end)
-
-       if not has_advanced then
-               uci:section("firewall", "advanced", nil,
-                       { tcp_ecn = "0", ip_conntrack_max = "8192", tcp_westwood = "1" })
-       end
-       uci:save("wireless")
-       uci:save("network")
-       uci:save("firewall")
-       uci:save("dhcp")
-
-       local new_hostname = uci:get("freifunk", "wizard", "hostname")
-       local old_hostname = sys.hostname()
-
-       if has_hb then
-               local dhcphb = hb:formvalue(section)
-               if dhcphb then
-                       uci:set("manager", "heartbeat", "enabled", "1")
-                       -- Make sure that heartbeat is enabled
-                       sys.init.enable("machash")
-               else
-                       uci:set("manager", "heartbeat", "enabled", "0")
-                       -- Make sure that heartbeat is enabled
-                       sys.init.disable("machash")
-               end
-               uci:save("manager")
-       end
-
-       local custom_hostname = hostname:formvalue(section)
-       uci:foreach("system", "system",
-               function(s)
-                       -- Make crond silent
-                       uci:set("system", s['.name'], "cronloglevel", "10")
-                       -- Make set timzone and zonename
-                       uci:set("system", s['.name'], "zonename", "Europe/Berlin")
-                       uci:set("system", s['.name'], "timezone", 'CET-1CEST,M3.5.0,M10.5.0/3')
-                       -- Set hostname
-                       if custom_hostname then
-                               uci:set("system", s['.name'], "hostname", custom_hostname)
-                               sys.hostname(custom_hostname)
-                       else
-                               if new_hostname then
-                                       if old_hostname == "OpenWrt" or old_hostname:match("^%d+-%d+-%d+-%d+$") then
-                                               uci:set("system", s['.name'], "hostname", new_hostname)
-                                               sys.hostname(new_hostname)
-                                       end
-                               end
-                       end
-               end)
-
-       -- Create time rdate_servers
-       local rdate = uci:get_all("freifunk", "time")
-       uci:delete_all("system", "time")
-       uci:section("system", "time", "rdate_servers", rdate)
-       rdate.server = rdate.rdate_servers
-       rdate.rdate_servers = ""
-       uci:delete_all("system", "rdate", nil)
-       uci:section("system", "rdate", nil, rdate)
-       uci:save("system")
-
-       -- Create http splash port 8082
-       uci:set_list("uhttpd","main","listen_http",{"80"})
-       uci:set_list("uhttpd","main","listen_https",{"443"})
-       uci:save("uhttpd")
-
-       -- Read geos
-       local latval = tonumber(lat:formvalue(section))
-       local lonval = tonumber(lon:formvalue(section))
-
-       -- 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))
-                       uci:set("system", s[".name"], "latitude",string.format("%.15f", latval))
-                       uci:set("system", s[".name"], "longitude",string.format("%.15f", lonval))
-               end)
-       else
-               uci:foreach("system", "system", function(s)
-                       uci:delete("system", s[".name"], "latlon")
-                       uci:delete("system", s[".name"], "latitude")
-                       uci:delete("system", s[".name"], "longitude")
-               end)
-       end
-       -- Delete old watchdog settings
-       uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_watchdog.so.0.1"})
-       -- Write new watchdog settings
-       uci:section("olsrd", "LoadPlugin", nil, {
-               library  = "olsrd_watchdog.so.0.1",
-               file     = "/var/run/olsrd.watchdog",
-               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",
-               suffix      = "." .. suffix ,
-               hosts_file  = "/var/etc/hosts.olsr",
-               latlon_file = "/var/run/latlon.js",
-               lat         = latval and string.format("%.15f", latval) or "",
-               lon         = lonval and string.format("%.15f", lonval) or "",
-               services_file = "/var/etc/services.olsr"
-       })
-
-       -- Import hosts and set domain
-       uci:foreach("dhcp", "dnsmasq", function(s)
-               uci:set_list("dhcp", s[".name"], "addnhosts", "/var/etc/hosts.olsr")
-               uci:set("dhcp", s[".name"], "local", "/" .. suffix .. "/")
-               uci:set("dhcp", s[".name"], "domain", suffix)
-       end)
-
-       -- Make sure that OLSR is enabled
-       sys.init.enable("olsrd")
-
-       uci:save("olsrd")
-       uci:save("dhcp")
-       -- Import hosts and set domain
-       if has_ipv6 then
-               uci:foreach("dhcp", "dnsmasq", function(s)
-                       uci:set_list("dhcp", s[".name"], "addnhosts", {"/var/etc/hosts.olsr","/var/etc/hosts.olsr.ipv6"})
-               end)
-       else
-               uci:foreach("dhcp", "dnsmasq", function(s)
-                       uci:set_list("dhcp", s[".name"], "addnhosts", "/var/etc/hosts.olsr")
-               end)
-       end
-
-       uci:save("dhcp")
-
-       -- Internet sharing
-       local share_value = share:formvalue(section)
-       if share_value == "1" then
-               uci:set("freifunk", "wizard", "netconfig", "1")
-               uci:section("firewall", "forwarding", nil, {src="freifunk", dest="wan"})
-
-               if has_autoipv6 then
-                       -- Set autoipv6 tunnel mode
-                       uci:set("autoipv6", "olsr_node", "enable", "0")
-                       uci:set("autoipv6", "tunnel", "enable", "1")
-                       uci:save("autoipv6")
-               end
-
-               -- Delete/Disable gateway plugin
-               uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_dyn_gw.so.0.5"})
-               uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_dyn_gw_plain.so.0.4"})
-               -- Enable gateway_plain plugin
-               uci:section("olsrd", "LoadPlugin", nil, {library="olsrd_dyn_gw_plain.so.0.4"})
-               sys.exec("chmod +x /etc/init.d/freifunk-p2pblock")
-               sys.init.enable("freifunk-p2pblock")
-               sys.init.enable("qos")
-               sys.exec('grep wan /etc/crontabs/root >/dev/null || echo "0 6 * * *     ifup wan" >> /etc/crontabs/root')
-
-               if wansec:formvalue(section) == "1" then
-                       uci:foreach("firewall", "zone",
-                               function(s)             
-                                       if s.name == "wan" then
-                                               uci:set("firewall", s['.name'], "local_restrict", "1")
-                                               return false
-                                       end
-                               end)
-               end
-       else
-               uci:set("freifunk", "wizard", "netconfig", "0")
-               uci:save("freifunk")
-               if has_autoipv6 then
-                       -- Set autoipv6 olsrd mode
-                       uci:set("autoipv6", "olsr_node", "enable", "1")
-                       uci:set("autoipv6", "tunnel", "enable", "0")
-                       uci:save("autoipv6")
-               end
-               -- Delete gateway plugins
-               uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_dyn_gw.so.0.5"})
-               uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_dyn_gw_plain.so.0.4"})
-               -- Disable gateway_plain plugin
-               uci:section("olsrd", "LoadPlugin", nil, {
-                       library     = "olsrd_dyn_gw_plain.so.0.4",
-                       ignore      = 1,
-               })
-               sys.init.disable("freifunk-p2pblock")
-               sys.init.disable("qos")
-               sys.exec("chmod -x /etc/init.d/freifunk-p2pblock")
-               uci:delete_all("firewall", "forwarding", {src="freifunk", dest="wan"})
-               uci:foreach("firewall", "zone",
-                       function(s)             
-                               if s.name == "wan" then
-                                       uci:delete("firewall", s['.name'], "local_restrict")
-                                       return false
-                               end
-                       end)
-       end
-       -- Write gvpn dummy interface
-       if has_l2gvpn then
-               if gvpn then
-                       local vpn = gvpn:formvalue(section)
-                       if vpn then
-                               uci:delete_all("l2gvpn", "l2gvpn")
-                               uci:delete_all("l2gvpn", "node")
-                               uci:delete_all("l2gvpn", "supernode")
-                               -- Write olsr tunnel interface options
-                               local olsr_gvpnifbase = uci:get_all("freifunk", "olsr_gvpninterface")
-                               util.update(olsr_gvpnifbase, uci:get_all(external, "olsr_gvpninterface") or {})
-                               uci:section("olsrd", "Interface", nil, olsr_gvpnifbase)
-                               local vpnip = gvpnip:formvalue(section)
-                               local gvpnif = uci:get_all("freifunk", "gvpn_node")
-                               util.update(gvpnif, uci:get_all(external, "gvpn_node") or {})
-                               if gvpnif and gvpnif.tundev and vpnip then
-                                       uci:section("network", "interface", gvpnif.tundev, {
-                                               ifname  =gvpnif.tundev ,
-                                               proto   ="static" ,
-                                               ipaddr  =vpnip ,
-                                               netmask =gvpnif.subnet or "255.255.255.192" ,
-                                       })
-                                       gvpnif.ip=""
-                                       gvpnif.subnet=""
-                                       gvpnif.up=""
-                                       gvpnif.down=""
-                                       gvpnif.mac="00:00:48:"..string.format("%X",string.gsub( vpnip, ".*%." , "" ))..":00:00"
-                                       tools.firewall_zone_add_interface("freifunk", gvpnif.tundev)
-                                       uci:section("l2gvpn", "node" , gvpnif.community , gvpnif)
-                                       uci:save("network")
-                                       uci:save("l2gvpn")
-                                       uci:save("firewall")
-                                       uci:save("olsrd")
-                                       sys.init.enable("l2gvpn")
-                               end
-                       else
-                               -- Disable l2gvpn
-                               sys.exec("/etc/init.d/l2gvpn stop")
-                               sys.init.disable("l2gvpn")
-                       end
-               end
-       end
-
-       uci:save("freifunk")
-       uci:save("firewall")
-       uci:save("olsrd")
-       uci:save("system")
-end
-
-return f
-
diff --git a/applications/luci-ffwizard/luasrc/model/cbi/freifunk/ffwizard.lua b/applications/luci-ffwizard/luasrc/model/cbi/freifunk/ffwizard.lua
new file mode 100644 (file)
index 0000000..3047ec3
--- /dev/null
@@ -0,0 +1,1282 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+Copyright 2011 Patrick Grimm <patrick@pberg.freifunk.net>
+Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+]]--
+
+
+local uci = require "luci.model.uci".cursor()
+local uci_state = require "luci.model.uci".cursor_state()
+local tools = require "luci.tools.ffwizard"
+local util = require "luci.util"
+local sys = require "luci.sys"
+local ip = require "luci.ip"
+local fs  = require "nixio.fs"
+
+local has_pptp  = fs.access("/usr/sbin/pptp")
+local has_pppoe = fs.glob("/usr/lib/pppd/*/rp-pppoe.so")()
+local has_l2gvpn  = fs.access("/usr/sbin/node")
+local has_radvd  = fs.access("/etc/config/radvd")
+local has_rom  = fs.access("/rom/etc")
+local has_autoipv6  = fs.access("/usr/bin/auto-ipv6")
+local has_qos  = fs.access("/etc/init.d/qos")
+local has_ipv6 = fs.access("/proc/sys/net/ipv6")
+local has_hb = fs.access("/sbin/heartbeat")
+local community = "profile_" .. (uci:get("freifunk", "community", "name") or "na")
+local lat = uci:get_first("system", "system", "latitude")
+local lon = uci:get_first("system", "system", "longitude")
+local suffix = uci:get_first(community, "community", "suffix") or "olsr"
+
+luci.i18n.loadc("freifunk")
+
+-- Check if all necessary variables are available
+if not (community ~= "profile_na" and lat and lon) then
+       luci.http.redirect(luci.dispatcher.build_url(unpack(luci.dispatcher.context.requested.path), "freifunk", "ffwizard_error"))
+       return
+end
+
+function get_mac(ix)
+       if string.find(ix, "radio") then
+               ix = string.gsub(ix,"radio", 'wlan')
+       end
+       local mac = fs.readfile("/sys/class/net/" .. ix .. "/address")
+       if not mac then
+               mac = luci.util.exec("ifconfig " .. ix)
+               mac = mac and mac:match(" ([A-F0-9:]+)%s*\n")
+       else
+               mac = mac:sub(1,17)
+       end
+       if mac and #mac > 0 then
+               return mac:lower()
+       end
+       return "?"
+end
+
+function get_ula(imac)
+       if string.len(imac) == 17 then
+               local mac1 = string.sub(imac,4,8)
+               local mac2 = string.sub(imac,10,14)
+               local mac3 = string.sub(imac,16,17)
+               return 'fdca:ffee:babe::02'..mac1..'ff:fe'..mac2..mac3..'/64'
+       end
+       return "?"
+end
+
+function gen_dhcp_range(n)
+       local subnet_prefix = tonumber(uci:get_first(community, "community", "splash_prefix")) or 27
+       local pool_network = uci:get_first(community, "community", "splash_network") or "10.104.0.0/16"
+       local pool = luci.ip.IPv4(pool_network)
+       local ip = tostring(n)
+       if pool and ip then
+               local hosts_per_subnet = 2^(32 - subnet_prefix)
+               local number_of_subnets = (2^pool:prefix())/hosts_per_subnet
+               local seed1, seed2 = ip:match("(%d+)%.(%d+)$")
+               if seed1 and seed2 then
+                       math.randomseed((seed1+1)*(seed2+1))
+               end
+               local subnet = pool:add(hosts_per_subnet * math.random(number_of_subnets))
+               dhcp_ip = subnet:network(subnet_prefix):add(1):string()
+               dhcp_mask = subnet:mask(subnet_prefix):string()
+       end
+       return "?"
+end
+
+function hbconf(dev)
+       if has_hb then
+               local ifacelist = uci:get_list("manager", "heartbeat", "interface") or {}
+               table.insert(ifacelist,dev .. "dhcp")
+               uci:set_list("manager", "heartbeat", "interface", ifacelist)
+               uci:save("manager")
+       end
+end
+
+-------------------- View --------------------
+f = SimpleForm("ffwizward", "Freifunkassistent",
+ "Dieser Assistent unterstützt Sie bei der Einrichtung des Routers für das Freifunknetz.")
+
+-- if password is not set or default then force the user to set a new one
+if sys.exec("diff /rom/etc/passwd /etc/passwd") == "" then
+       pw1 = f:field(Value, "pw1", translate("password"))
+       pw1.password = true
+       pw1.rmempty = false
+
+       pw2 = f:field(Value, "pw2", translate("confirmation"))
+       pw2.password = true
+       pw2.rmempty = false
+
+       function pw2.validate(self, value, section)
+               return pw1:formvalue(section) == value and value
+       end
+end
+
+-- main netconfig
+
+local cc = uci:get(community, "wifi_device", "country") or "DE"
+
+main = f:field(Flag, "netconfig", "Netzwerk einrichten", "Setzen Sie den Haken, wenn Sie Ihr Freifunk Netzwerk einrichten wollen.")
+uci:foreach("wireless", "wifi-device",
+       function(section)
+               local device = section[".name"]
+               local hwtype = section.type
+
+               local syscc  = uci:get("wireless", device, "country")
+               if not syscc then
+                       if hwtype == "atheros" then
+                               cc = sys.exec("grep -i '" .. cc .. "' /lib/wifi/cc_translate.txt |cut -d ' ' -f 2") or 0
+                               sys.exec("echo " .. cc .. " > /proc/sys/dev/" .. device .. "/countrycode")
+                       elseif hwtype == "mac80211" then
+                               sys.exec("iw reg set " .. cc)
+                       elseif hwtype == "broadcom" then
+                               -- verify that ot works!
+                               sys.exec ("wlc country " .. cc)
+                       end
+               else
+                       cc = syscc
+               end
+
+               local dev = f:field(Flag, "device_" .. device , "<b>Drahtloses Netzwerk \"" .. device:upper() .. "\"</b> ", "Konfigurieren Sie Ihre drahtlose " .. device:upper() .. "Schnittstelle (WLAN).")
+                       dev:depends("netconfig", "1")
+                       dev.rmempty = false
+                       function dev.cfgvalue(self, section)
+                               return uci:get("freifunk", "wizard", "device_" .. device)
+                       end
+                       function dev.write(self, sec, value)
+                               if value then
+                                       uci:set("freifunk", "wizard", "device_" .. device, value)
+                                       uci:save("freifunk")
+                               end
+                       end
+               local chan = f:field(ListValue, "chan_" .. device, device:upper() .. "  Freifunk Kanal einrichten", "Ihr Gerät und benachbarte Freifunk Knoten müssen auf demselben Kanal senden. Je nach Gerätetyp können Sie zwischen verschiedenen 2,4Ghz und 5Ghz Kanälen auswählen.")
+                       chan:depends("device_" .. device, "1")
+                       chan.rmempty = true
+                       function chan.cfgvalue(self, section)
+                               return uci:get("freifunk", "wizard", "chan_" .. device)
+                       end
+
+                       chan:value('default')
+                       for _, f in ipairs(sys.wifi.channels(device)) do
+                               if not f.restricted then
+                                       chan:value(f.channel)
+                               end
+                       end
+
+                       function chan.write(self, sec, value)
+                               if value then
+                                       uci:set("freifunk", "wizard", "chan_" .. device, value)
+                                       uci:save("freifunk")
+                               end
+                       end
+
+               local meship = f:field(Value, "meship_" .. device, device:upper() .. "  Mesh IP Adresse einrichten", "Ihre Mesh IP Adresse erhalten Sie von der Freifunk Gemeinschaft in Ihrer Nachbarschaft. Es ist eine netzweit eindeutige Identifikation, z.B. 104.1.1.1.")
+                       meship:depends("device_" .. device, "1")
+                       meship.rmempty = true
+                       function meship.cfgvalue(self, section)
+                               return uci:get("freifunk", "wizard", "meship_" .. device)
+                       end
+                       function meship.validate(self, value)
+                               local x = ip.IPv4(value)
+                               return ( x and x:prefix() == 32 ) and x:string() or ""
+                       end
+                       function meship.write(self, sec, value)
+                               uci:set("freifunk", "wizard", "meship_" .. device, value)
+                       end
+               if has_ipv6 then
+                       local meship6 = f:field(Value, "meship6_" .. device, device:upper() .. "  Mesh IPv6 Adresse einrichten", "Ihre Mesh IP Adresse wird automatisch berechnet")
+                       meship6:depends("device_" .. device, "1")
+                       meship6.rmempty = true
+                       function meship6.cfgvalue(self, section)
+                               return get_ula(get_mac(device))
+                       end
+               end
+       
+               local client = f:field(Flag, "client_" .. device, device:upper() .. "  DHCP anbieten", "DHCP weist verbundenen Benutzern automatisch eine Adresse zu. Diese Option sollten Sie unbedingt aktivieren, wenn Sie Nutzer an der drahtlosen Schnittstelle erwarten.")
+                       client:depends("device_" .. device, "1")
+                       client.rmempty = true
+                       function client.cfgvalue(self, section)
+                               return uci:get("freifunk", "wizard", "client_" .. device)
+                       end
+                       function client.write(self, sec, value)
+                               uci:set("freifunk", "wizard", "client_" .. device, value)
+                               uci:save("freifunk")
+                       end
+               local dhcpmesh = f:field(Value, "dhcpmesh_" .. device, device:upper() .. "  Mesh DHCP anbieten", "Bestimmen Sie den Adressbereich aus dem Ihre Nutzer IP Adressen erhalten. Es wird empfohlen einen Adressbereich aus Ihrer lokalen Freifunk Gemeinschaft zu nutzen. Der Adressbereich ist ein netzweit eindeutiger Netzbereich. z.B. 104.1.2.1/28")
+                       dhcpmesh:depends("client_" .. device, "1")
+                       dhcpmesh.rmempty = true
+                       function dhcpmesh.cfgvalue(self, section)
+                               return uci:get("freifunk", "wizard", "dhcpmesh_" .. device)
+                       end
+                       function dhcpmesh.validate(self, value)
+                               local x = ip.IPv4(value)
+                               return ( x and x:minhost()) and x:string() or ""
+                       end
+                       function dhcpmesh.write(self, sec, value)
+                               uci:set("freifunk", "wizard", "dhcpmesh_" .. device, value)
+                               uci:save("freifunk")
+                       end
+               local hwtype = section.type
+               if hwtype == "atheros" then
+                       local vap = f:field(Flag, "vap_" .. device , "Virtueller Drahtloser Zugangspunkt", "Konfigurieren Sie Ihren Virtuellen AP")
+                       vap:depends("client_" .. device, "1")
+                       vap.rmempty = false
+                       function vap.cfgvalue(self, section)
+                               return uci:get("freifunk", "wizard", "vap_" .. device)
+                       end
+                       function vap.write(self, sec, value)
+                               uci:set("freifunk", "wizard", "vap_" .. device, value)
+                               uci:save("freifunk")
+                       end
+               end
+       end)
+
+uci:foreach("network", "interface",
+       function(section)
+               local device = section[".name"]
+               local ifname = uci_state:get("network",device,"ifname")
+               if device ~= "loopback" and not string.find(device, "gvpn")  and not string.find(device, "wifi") and not string.find(device, "wl") and not string.find(device, "wlan") and not string.find(device, "wireless") and not string.find(device, "radio") then
+                       dev = f:field(Flag, "device_" .. device , "<b>Drahtgebundenes Netzwerk \"" .. device:upper() .. "\"</b>", "Konfigurieren Sie Ihre drahtgebunde " .. device:upper() .. " Schnittstelle (LAN).")
+                               dev:depends("netconfig", "1")
+                               dev.rmempty = false
+                               function dev.cfgvalue(self, section)
+                                       return uci:get("freifunk", "wizard", "device_" .. device)
+                               end
+                               function dev.write(self, sec, value)
+                                       uci:set("freifunk", "wizard", "device_" .. device, value)
+                                       uci:save("freifunk")
+                               end
+                       meship = f:field(Value, "meship_" .. device, device:upper() .. "  Mesh IP Adresse einrichten", "Ihre Mesh IP Adresse erhalten Sie von der Freifunk Gemeinschaft in Ihrer Nachbarschaft. Es ist eine netzweit eindeutige Identifikation, z.B. 104.1.1.1.")
+                               meship:depends("device_" .. device, "1")
+                               meship.rmempty = true
+                               function meship.cfgvalue(self, section)
+                                       return uci:get("freifunk", "wizard", "meship_" .. device)
+                               end
+                               function meship.validate(self, value)
+                                       local x = ip.IPv4(value)
+                                       return ( x and x:prefix() == 32 ) and x:string() or ""
+                               end
+                               function meship.write(self, sec, value)
+                                       uci:set("freifunk", "wizard", "meship_" .. device, value)
+                               end
+                       if has_ipv6 then
+                               meship6 = f:field(Value, "meship6_" .. device, device:upper() .. "  Mesh IPv6 Adresse einrichten", "Ihre Mesh IP Adresse wird automatisch berechnet")
+                               meship6:depends("device_" .. device, "1")
+                               meship6.rmempty = true
+                               function meship6.cfgvalue(self, section)
+                                       return get_ula(get_mac(ifname))
+                               end
+                       end
+
+                       client = f:field(Flag, "client_" .. device, device:upper() .. "  DHCP anbieten","DHCP weist verbundenen Benutzern automatisch eine Adresse zu. Diese Option sollten Sie unbedingt aktivieren, wenn Sie Nutzer an der drahtlosen Schnittstelle erwarten.")
+                               client:depends("device_" .. device, "1")
+                               client.rmempty = false
+                               function client.cfgvalue(self, section)
+                                       return uci:get("freifunk", "wizard", "client_" .. device)
+                               end
+                               function client.write(self, sec, value)
+                                       uci:set("freifunk", "wizard", "client_" .. device, value)
+                                       uci:save("freifunk")
+                               end
+                       dhcpmesh = f:field(Value, "dhcpmesh_" .. device, device:upper() .. "  Mesh DHCP anbieten ", "Bestimmen Sie den Adressbereich aus dem Ihre Nutzer IP Adressen erhalten. Es wird empfohlen einen Adressbereich aus Ihrer lokalen Freifunk Gemeinschaft zu nutzen. Der Adressbereich ist ein netzweit eindeutiger Netzbereich. z.B. 104.1.2.1/28")
+                               dhcpmesh:depends("client_" .. device, "1")
+                               dhcpmesh.rmempty = true
+                               function dhcpmesh.cfgvalue(self, section)
+                                       return uci:get("freifunk", "wizard", "dhcpmesh_" .. device)
+                               end
+                               function dhcpmesh.validate(self, value)
+                                       local x = ip.IPv4(value)
+                                       return ( x and x:prefix() <= 30 and x:minhost()) and x:string() or ""
+                               end
+                               function dhcpmesh.write(self, sec, value)
+                                       uci:set("freifunk", "wizard", "dhcpmesh_" .. device, value)
+                                       uci:save("freifunk")
+                               end
+               end
+       end)
+
+share = f:field(Flag, "sharenet", "Eigenen Internetzugang freigeben", "Geben Sie Ihren Internetzugang im Freifunknetz frei.")
+share.rmempty = false
+share:depends("netconfig", "1")
+function share.cfgvalue(self, section)
+       return uci:get("freifunk", "wizard", "share")
+end
+function share.write(self, section, value)
+       uci:set("freifunk", "wizard", "share", value)
+       uci:save("freifunk")
+end
+
+wanproto = f:field(ListValue, "wanproto", "Protokoll des Internetzugangs", "Geben Sie das Protokol an ueber das eine Internet verbindung hergestellt werden kann.")
+wanproto:depends("sharenet", "1")
+wanproto:value("static", translate("static", "static"))
+wanproto:value("dhcp", translate("dhcp", "dhcp"))
+if has_pppoe then wanproto:value("pppoe", "PPPoE") end
+if has_pptp  then wanproto:value("pptp",  "PPTP")  end
+function wanproto.cfgvalue(self, section)
+       return uci:get("network", "wan", "proto") or "dhcp"
+end
+function wanproto.write(self, section, value)
+       uci:set("network", "wan", "proto", value)
+       uci:save("network")
+end
+wanip = f:field(Value, "wanipaddr", translate("ipaddress"))
+wanip:depends("wanproto", "static")
+function wanip.cfgvalue(self, section)
+       return uci:get("network", "wan", "ipaddr")
+end
+function wanip.write(self, section, value)
+       uci:set("network", "wan", "ipaddr", value)
+       uci:save("network")
+end
+wannm = f:field(Value, "wannetmask", translate("netmask"))
+wannm:depends("wanproto", "static")
+function wannm.cfgvalue(self, section)
+       return uci:get("network", "wan", "netmask")
+end
+function wannm.write(self, section, value)
+       uci:set("network", "wan", "netmask", value)
+       uci:save("network")
+end
+wangw = f:field(Value, "wangateway", translate("gateway"))
+wangw:depends("wanproto", "static")
+wangw.rmempty = true
+function wangw.cfgvalue(self, section)
+       return uci:get("network", "wan", "gateway")
+end
+function wangw.write(self, section, value)
+       uci:set("network", "wan", "gateway", value)
+       uci:save("network")
+end
+wandns = f:field(Value, "wandns", translate("dnsserver"))
+wandns:depends("wanproto", "static")
+wandns.rmempty = true
+function wandns.cfgvalue(self, section)
+       return uci:get("network", "wan", "dns")
+end
+function wandns.write(self, section, value)
+       uci:set("network", "wan", "dns", value)
+       uci:save("network")
+end
+wanusr = f:field(Value, "wanusername", translate("username"))
+wanusr:depends("wanproto", "pppoe")
+wanusr:depends("wanproto", "pptp")
+function wanusr.cfgvalue(self, section)
+       return uci:get("network", "wan", "username")
+end
+function wanusr.write(self, section, value)
+       uci:set("network", "wan", "username", value)
+       uci:save("network")
+end
+wanpwd = f:field(Value, "wanpassword", translate("password"))
+wanpwd.password = true
+wanpwd:depends("wanproto", "pppoe")
+wanpwd:depends("wanproto", "pptp")
+function wanpwd.cfgvalue(self, section)
+       return uci:get("network", "wan", "password")
+end
+function wanpwd.write(self, section, value)
+       uci:set("network", "wan", "password", value)
+       uci:save("network")
+end
+
+wansec = f:field(Flag, "wansec", "WAN-Zugriff auf Gateway beschränken", "Verbieten Sie Zugriffe auf Ihr lokales Netzwerk aus dem Freifunknetz.")
+wansec.rmempty = false
+wansec:depends("wanproto", "static")
+wansec:depends("wanproto", "dhcp")
+function wansec.cfgvalue(self, section)
+       return uci:get("freifunk", "wizard", "wan_security")
+end
+function wansec.write(self, section, value)
+       uci:set("freifunk", "wizard", "wan_security", value)
+       uci:save("freifunk")
+end
+if has_qos then
+       wanqosdown = f:field(Value, "wanqosdown", "Download Bandbreite begrenzen", "kb/s")
+       wanqosdown:depends("sharenet", "1")
+       function wanqosdown.cfgvalue(self, section)
+               return uci:get("qos", "wan", "download")
+       end
+       function wanqosdown.write(self, section, value)
+               uci:set("qos", "wan", "download", value)
+               uci:save("qos")
+       end
+       wanqosup = f:field(Value, "wanqosup", "Upload Bandbreite begrenzen", "kb/s")
+       wanqosup:depends("sharenet", "1")
+       function wanqosup.cfgvalue(self, section)
+               return uci:get("qos", "wan", "upload")
+       end
+       function wanqosup.write(self, section, value)
+               uci:set("qos", "wan", "upload", value)
+               uci:save("qos")
+       end
+end
+
+if has_l2gvpn then
+       gvpn = f:field(Flag, "gvpn", "Freifunk Internet Tunnel", "Verbinden Sie ihren Router ueber das Internet mit anderen Freifunknetzen.")
+       gvpn.rmempty = false
+       gvpn:depends("sharenet", "1")
+       function gvpn.cfgvalue(self, section)
+               return uci:get("freifunk", "wizard", "gvpn")
+       end
+       function gvpn.write(self, section, value)
+               uci:set("freifunk", "wizard", "gvpn", value)
+               uci:save("freifunk")
+       end
+       gvpnip = f:field(Value, "gvpnipaddr", translate("ipaddress"))
+       gvpnip:depends("gvpn", "1")
+       function gvpnip.cfgvalue(self, section)
+               return uci:get("l2gvpn", "bbb", "ip") or uci:get("network", "gvpn", "ipaddr")
+       end
+       function gvpnip.validate(self, value)
+               local x = ip.IPv4(value)
+               return ( x and x:prefix() == 32 ) and x:string() or ""
+       end
+end
+
+if has_hb then
+       hb = f:field(Flag, "hb", "Heartbeat aktivieren","Dem Gerät erlauben anonyme Statistiken zu Ã¼bertragen. (empfohlen)")
+       hb.rmempty = false
+       hb:depends("netconfig", "1")
+       function hb.cfgvalue(self, section)
+               return uci:get("freifunk", "wizard", "hb")
+       end
+       function hb.write(self, section, value)
+               uci:set("freifunk", "wizard", "hb", value)
+               uci:save("freifunk")
+       end
+end
+
+-------------------- Control --------------------
+function f.handle(self, state, data)
+       if state == FORM_VALID then
+               local debug = uci:get("freifunk", "wizard", "debug")
+               if debug == "1" then
+                       if data.pw1 then
+                               local stat = luci.sys.user.setpasswd("root", data.pw1) == 0
+                               if stat then
+                                       f.message = translate("a_s_changepw_changed")
+                               else
+                                       f.errmessage = translate("unknownerror")
+                               end
+                       end
+                       data.pw1 = nil
+                       data.pw2 = nil
+                       luci.http.redirect(luci.dispatcher.build_url(unpack(luci.dispatcher.context.requested.path), "system", "system"))
+               else
+                       if data.pw1 then
+                               local stat = luci.sys.user.setpasswd("root", data.pw1) == 0
+                       end
+                       data.pw1 = nil
+                       data.pw2 = nil
+                       uci:commit("freifunk")
+                       uci:commit("wireless")
+                       uci:commit("network")
+                       uci:commit("dhcp")
+                       uci:commit("luci_splash")
+                       uci:commit("firewall")
+                       uci:commit("system")
+                       uci:commit("olsrd")
+                       uci:commit("manager")
+                       if has_autoipv6 then
+                               uci:commit("autoipv6")
+                       end
+                       if has_qos then
+                               uci:commit("qos")
+                       end
+                       if has_l2gvpn then
+                               uci:commit("l2gvpn")
+                       end
+                       if has_radvd then
+                               uci:commit("radvd")
+                       end
+
+                       sys.exec("for s in network dnsmasq luci_splash firewall olsrd radvd l2gvpn; do [ -x /etc/init.d/$s ] && /etc/init.d/$s restart;done > /dev/null &" )
+                       luci.http.redirect(luci.dispatcher.build_url(luci.dispatcher.context.path[1], "freifunk", "ffwizard"))
+               end
+               return false
+       elseif state == FORM_INVALID then
+               self.errmessage = "Ungültige Eingabe: Bitte die Formularfelder auf Fehler prüfen."
+       end
+       return true
+end
+
+local function _strip_internals(tbl)
+       tbl = tbl or {}
+       for k, v in pairs(tbl) do
+               if k:sub(1, 1) == "." then
+                       tbl[k] = nil
+               end
+       end
+       return tbl
+end
+-- Configure Freifunk checked
+function main.write(self, section, value)
+       if value == "0" then
+               uci:set("freifunk", "wizard", "netconfig", "0")
+               uci:save("freifunk")
+               return
+       end
+       -- Collect IP-Address
+       uci:set("freifunk", "wizard", "net", uci:get_first(community, "community", "mesh_network"))
+        uci:save("freifunk")
+
+       -- Invalidate fields
+       if not community then
+               net.tag_missing[section] = true
+               return
+       end
+
+       uci:set("freifunk", "wizard", "netconfig", "1")
+       uci:save("freifunk")
+
+       local netname = "wireless"
+       local network
+       network = ip.IPv4(uci:get_first(community, "community", "mesh_network") or "104.0.0.0/8")
+
+       -- Tune community settings
+--     if community and uci:get("freifunk", community) then
+--             uci:get_all(community)
+--     end
+
+       -- Cleanup
+       uci:delete_all("firewall","zone", {name="freifunk"})
+       uci:delete_all("firewall","forwarding", {dest="freifunk"})
+       uci:delete_all("firewall","forwarding", {src="freifunk"})
+       uci:delete_all("firewall","rule", {dest="freifunk"})
+       uci:delete_all("firewall","rule", {src="freifunk"})
+       uci:save("firewall")
+       -- Create firewall zone and add default rules (first time)
+       --                    firewall_create_zone("name"    , "input" , "output", "forward ", Masqurade)
+       local newzone = tools.firewall_create_zone("freifunk", "ACCEPT", "ACCEPT", "REJECT"  , true)
+       if newzone then
+               uci:foreach("freifunk", "fw_forwarding", function(section)
+                       uci:section("firewall", "forwarding", nil, section)
+               end)
+               uci:foreach(community, "fw_forwarding", function(section)
+                       uci:section("firewall", "forwarding", nil, section)
+               end)
+
+               uci:foreach("freifunk", "fw_rule", function(section)
+                       uci:section("firewall", "rule", nil, section)
+               end)
+               uci:foreach(community, "fw_rule", function(section)
+                       uci:section("firewall", "rule", nil, section)
+               end)
+       end
+       uci:save("firewall")
+       if has_hb then
+               uci:delete("manager", "heartbeat", "interface")
+               uci:save("manager")
+       end
+       -- Delete olsrdv4
+       uci:delete_all("olsrd", "olsrd")
+       local olsrbase
+       olsrbase = uci:get_all("freifunk", "olsrd") or {}
+       util.update(olsrbase, uci:get_all(community, "olsrd") or {})
+       if has_ipv6 then
+               olsrbase.IpVersion='6and4'
+       else
+               olsrbase.IpVersion='4'
+       end
+       uci:section("olsrd", "olsrd", nil, olsrbase)
+       -- Delete olsrdv4 old p2pd settings
+       uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_mdns.so.1.0.0"})
+       uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_p2pd.so.0.1.0"})
+       -- Write olsrdv4 new p2pd settings
+       uci:section("olsrd", "LoadPlugin", nil, {
+               library     = "olsrd_p2pd.so.0.1.0",
+               P2pdTtl     = 10,
+               UdpDestPort = "224.0.0.251 5353",
+               ignore      = 1,
+       })
+       -- Delete http plugin
+       uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_httpinfo.so.0.1"})
+
+       -- Delete olsrdv4 old interface
+       uci:delete_all("olsrd", "Interface")
+       uci:delete_all("olsrd", "Hna4")
+       -- Create wireless ip4/ip6 and firewall config
+       uci:foreach("wireless", "wifi-device",
+       function(sec)
+               local device = sec[".name"]
+               if not luci.http.formvalue("cbid.ffwizward.1.device_" .. device) then
+                       return
+               end
+               node_ip = luci.http.formvalue("cbid.ffwizward.1.meship_" .. device) and ip.IPv4(luci.http.formvalue("cbid.ffwizward.1.meship_" .. device))
+               if has_ipv6 then
+                       node_ip6 = luci.http.formvalue("cbid.ffwizward.1.meship6_" .. device) and ip.IPv6(luci.http.formvalue("cbid.ffwizward.1.meship6_" .. device))
+               end
+               if not node_ip or not network or not network:contains(node_ip) then
+                       meship.tag_missing[section] = true
+                       node_ip = nil
+                       return
+               end
+               -- rename the wireless interface s/wifi/wireless/
+               local nif
+               if string.find(device, "wifi") then
+                       nif = string.gsub(device,"wifi", netname)
+               elseif string.find(device, "wl") then
+                       nif = string.gsub(device,"wl", netname)
+               elseif string.find(device, "wlan") then
+                       nif = string.gsub(device,"wlan", netname)
+               elseif string.find(device, "radio") then
+                       nif = string.gsub(device,"radio", netname)
+               end
+               -- Cleanup
+               tools.wifi_delete_ifaces(device)
+               -- tools.network_remove_interface(device)
+               uci:delete("network", device .. "dhcp")
+               uci:delete("network", device)
+               tools.firewall_zone_remove_interface("freifunk", device)
+               -- tools.network_remove_interface(nif)
+               uci:delete("network", nif .. "dhcp")
+               uci:delete("network", nif)
+               tools.firewall_zone_remove_interface("freifunk", nif)
+               -- Delete old dhcp
+               uci:delete("dhcp", device)
+               uci:delete("dhcp", device .. "dhcp")
+               uci:delete("dhcp", nif)
+               uci:delete("dhcp", nif .. "dhcp")
+               -- Delete old splash
+               uci:delete_all("luci_splash", "iface", {network=device.."dhcp", zone="freifunk"})
+               uci:delete_all("luci_splash", "iface", {network=nif.."dhcp", zone="freifunk"})
+               -- Delete old radvd
+               if has_radvd then
+                       uci:delete_all("radvd", "interface", {interface=nif.."dhcp"})
+                       uci:delete_all("radvd", "interface", {interface=nif})
+                       uci:delete_all("radvd", "prefix", {interface=nif.."dhcp"})
+                       uci:delete_all("radvd", "prefix", {interface=nif})
+               end
+               -- New Config
+               -- Tune wifi device
+               local ssid = uci:get_first(community, "community", "ssid") or "olsr.freifunk.net"
+               local devconfig = uci:get_all("freifunk", "wifi_device")
+               util.update(devconfig, uci:get_all(community, "wifi_device") or {})
+               local channel = luci.http.formvalue("cbid.ffwizward.1.chan_" .. device)
+               local hwmode = "11bg"
+               local bssid = uci:get_all(community, "wifi_iface", "bssid") or "02:CA:FF:EE:BA:BE"
+               local mrate = 5500
+               -- set bssid, see https://kifuse02.pberg.freifunk.net/moin/channel-bssid-essid for schema
+               if channel and channel ~= "default" then
+                       if devconfig.channel ~= channel then
+                               devconfig.channel = channel
+                               local chan = tonumber(channel)
+                               if chan >= 0 and chan < 10 then
+                                       bssid = channel .. "2:CA:FF:EE:BA:BE"
+                               elseif chan == 10 then 
+                                       bssid = "02:CA:FF:EE:BA:BE" 
+                               elseif chan >= 11 and chan <= 14 then
+                                       bssid = string.format("%X",channel) .. "2:CA:FF:EE:BA:BE"
+                               elseif chan >= 36 and chan <= 64 then
+                                       hwmode = "11a"
+                                       mrate = ""
+                                       bssid = "00:" .. channel ..":CA:FF:EE:EE"
+                               elseif chan >= 100 and chan <= 140 then
+                                       hwmode = "11a"
+                                       mrate = ""
+                                       bssid = "01:" .. string.sub(channel, 2) .. ":CA:FF:EE:EE"
+                               end
+                               devconfig.hwmode = hwmode
+                       end
+                       devconfig.country = cc
+                       ssid = ssid .. " - ch" .. channel
+               end
+               uci:tset("wireless", device, devconfig)
+               -- Create wifi iface
+               local ifconfig = uci:get_all("freifunk", "wifi_iface")
+               util.update(ifconfig, uci:get_all(community, "wifi_iface") or {})
+               ifconfig.device = device
+               ifconfig.network = nif
+               ifconfig.ssid = ssid
+               ifconfig.bssid = bssid
+               ifconfig.encryption="none"
+               -- Read Preset 
+               local netconfig = uci:get_all("freifunk", "interface")
+               util.update(netconfig, uci:get_all(community, "interface") or {})
+               netconfig.proto = "static"
+               netconfig.ipaddr = node_ip:string()
+               if has_ipv6 then
+                       netconfig.ip6addr = node_ip6:string()
+               end
+               uci:section("network", "interface", nif, netconfig)
+               if has_radvd then
+                       uci:section("radvd", "interface", nil, {
+                               interface          =nif,
+                               AdvSendAdvert      =1,
+                               AdvManagedFlag     =0,
+                               AdvOtherConfigFlag =0,
+                               ignore             =0
+                       })
+                       uci:section("radvd", "prefix", nil, {
+                               interface          =nif,
+                               AdvOnLink          =1,
+                               AdvAutonomous      =1,
+                               AdvRouterAddr      =0,
+                               ignore             =0,
+                       })
+                       uci:save("radvd")
+               end
+               tools.firewall_zone_add_interface("freifunk", nif)
+               uci:save("firewall")
+               -- Write new olsrv4 interface
+               local olsrifbase = uci:get_all("freifunk", "olsr_interface")
+               util.update(olsrifbase, uci:get_all(community, "olsr_interface") or {})
+               olsrifbase.interface = nif
+               olsrifbase.ignore    = "0"
+               uci:section("olsrd", "Interface", nil, olsrifbase)
+               -- Collect MESH DHCP IP NET
+               local client = luci.http.formvalue("cbid.ffwizward.1.client_" .. device)
+               if client then
+                       local dhcpmeshnet = luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device) and ip.IPv4(luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device))
+                       hbconf(nif)
+                       --[[
+                       if has_hb then
+                               local ifacelist = uci:get_list("manager", "heartbeat", "interface") or {}
+                               table.insert(ifacelist,nif .. "dhcp")
+                               uci:set_list("manager", "heartbeat", "interface", ifacelist)
+                               uci:save("manager")
+                       end
+                       ]]
+                       if dhcpmeshnet then
+                               if not dhcpmeshnet:minhost() or not dhcpmeshnet:mask() then
+                                       dhcpmesh.tag_missing[section] = true
+                                       dhcpmeshnet = nil
+                                       return
+                               end
+                               dhcp_ip = dhcpmeshnet:minhost():string()
+                               dhcp_mask = dhcpmeshnet:mask():string()
+                               dhcp_network = dhcpmeshnet:network():string()
+                               uci:section("olsrd", "Hna4", nil, {
+                                       netmask  = dhcp_mask,
+                                       netaddr  = dhcp_network
+                               })
+                               uci:foreach("olsrd", "LoadPlugin",
+                                       function(s)             
+                                               if s.library == "olsrd_p2pd.so.0.1.0" then
+                                                       uci:set("olsrd", s['.name'], "ignore", "0")
+                                                       local nonolsr = uci:get("olsrd", s['.name'], "NonOlsrIf") or ""
+                                                       vap = luci.http.formvalue("cbid.ffwizward.1.vap_" .. device)
+                                                       if vap then
+                                                               nonolsr = nif.."dhcp "..nonolsr
+                                                       else
+                                                               nonolsr = nif.." "..nonolsr
+                                                       end
+                                                       uci:set("olsrd", s['.name'], "NonOlsrIf", nonolsr)
+                                               end
+                                       end)
+                       else
+                               gen_dhcp_range(netconfig.ipaddr)
+                       end
+                       if dhcp_ip and dhcp_mask then
+                               -- Create alias
+                               local aliasbase = uci:get_all("freifunk", "alias")
+                               util.update(aliasbase, uci:get_all(community, "alias") or {})
+                               aliasbase.ipaddr = dhcp_ip
+                               aliasbase.netmask = dhcp_mask
+                               aliasbase.proto = "static"
+                               vap = luci.http.formvalue("cbid.ffwizward.1.vap_" .. device)
+                               if vap then
+                                       uci:section("network", "interface", nif .. "dhcp", aliasbase)
+                                       uci:section("wireless", "wifi-iface", nil, {
+                                               device     =device,
+                                               mode       ="ap",
+                                               encryption ="none",
+                                               network    =nif .. "dhcp",
+                                               ssid       ="AP-" .. ssid
+                                       })
+                                       if has_radvd then
+                                               uci:section("radvd", "interface", nil, {
+                                                       interface          =nif .. "dhcp",
+                                                       AdvSendAdvert      =1,
+                                                       AdvManagedFlag     =0,
+                                                       AdvOtherConfigFlag =0,
+                                                       ignore             =0
+                                               })
+                                               uci:section("radvd", "prefix", nil, {
+                                                       interface          =nif .. "dhcp",
+                                                       AdvOnLink          =1,
+                                                       AdvAutonomous      =1,
+                                                       AdvRouterAddr      =0,
+                                                       ignore             =0
+                                               })
+                                               uci:save("radvd")
+                                       end
+                                       tools.firewall_zone_add_interface("freifunk", nif .. "dhcp")
+                                       uci:save("wireless")
+                                       ifconfig.mcast_rate = nil
+                                       ifconfig.encryption="none"
+                               else
+                                       aliasbase.interface = nif
+                                       uci:section("network", "alias", nif .. "dhcp", aliasbase)
+                               end
+                               -- Create dhcp
+                               local dhcpbase = uci:get_all("freifunk", "dhcp")
+                               util.update(dhcpbase, uci:get_all(community, "dhcp") or {})
+                               dhcpbase.interface = nif .. "dhcp"
+                               dhcpbase.force = 1
+                               uci:section("dhcp", "dhcp", nif .. "dhcp", dhcpbase)
+                               uci:set_list("dhcp", nif .. "dhcp", "dhcp_option", "119,olsr")
+                               -- Create firewall settings
+                               uci:delete_all("firewall", "rule", {
+                                       src="freifunk",
+                                       proto="udp",
+                                       dest_port="53"
+                               })
+                               uci:section("firewall", "rule", nil, {
+                                       src="freifunk",
+                                       proto="udp",
+                                       dest_port="53",
+                                       target="ACCEPT"
+                               })
+                               uci:delete_all("firewall", "rule", {
+                                       src="freifunk",
+                                       proto="udp",
+                                       src_port="68",
+                                       dest_port="67"
+                               })
+                               uci:section("firewall", "rule", nil, {
+                                       src="freifunk",
+                                       proto="udp",
+                                       src_port="68",
+                                       dest_port="67",
+                                       target="ACCEPT"
+                               })
+                               uci:delete_all("firewall", "rule", {
+                                       src="freifunk",
+                                       proto="tcp",
+                                       dest_port="8082",
+                               })
+                               uci:section("firewall", "rule", nil, {
+                                       src="freifunk",
+                                       proto="tcp",
+                                       dest_port="8082",
+                                       target="ACCEPT"
+                               })
+                               -- Register splash
+                               uci:section("luci_splash", "iface", nil, {network=nif.."dhcp", zone="freifunk"})
+                               uci:save("luci_splash")
+                               -- Make sure that luci_splash is enabled
+                               sys.init.enable("luci_splash")
+                       end
+               else
+                       -- Delete old splash
+                       uci:delete_all("luci_splash", "iface", {network=device.."dhcp", zone="freifunk"})
+               end
+               --Write Ad-Hoc wifi section after AP wifi section
+               uci:section("wireless", "wifi-iface", nil, ifconfig)
+               uci:save("network")
+               uci:save("wireless")
+               uci:save("network")
+               uci:save("firewall")
+               uci:save("dhcp")
+       end)
+       -- Create wired ip and firewall config
+       uci:foreach("network", "interface",
+               function(sec)
+               local device = sec[".name"]
+               if not luci.http.formvalue("cbid.ffwizward.1.device_" .. device) then
+                       return
+               end
+               if device ~= "loopback" and not string.find(device, "wifi") and not string.find(device, "wl") and not string.find(device, "wlan") and not string.find(device, "wireless") and not string.find(device, "radio") then
+                       local node_ip
+                       node_ip = luci.http.formvalue("cbid.ffwizward.1.meship_" .. device) --and ip.IPv4(luci.http.formvalue("cbid.ffwizward.1.meship_" .. device))
+                       if has_ipv6 then
+                               node_ip6 = luci.http.formvalue("cbid.ffwizward.1.meship6_" .. device) --and ip.IPv6(luci.http.formvalue("cbid.ffwizward.1.meship6_" .. device))
+                       end
+                       if not node_ip or not network or not network:contains(node_ip) then
+                               meship.tag_missing[section] = true
+                               node_ip = nil
+                               return
+                       end
+                       -- Cleanup
+                       tools.firewall_zone_remove_interface(device, device)
+                       uci:delete_all("firewall","zone", {name=device})
+                       uci:delete_all("firewall","forwarding", {src=device})
+                       uci:delete_all("firewall","forwarding", {dest=device})
+                       uci:delete("network", device .. "dhcp")
+                       -- Delete old dhcp
+                       uci:delete("dhcp", device)
+                       uci:delete("dhcp", device .. "dhcp")
+                       -- Delete old splash
+                       uci:delete_all("luci_splash", "iface", {network=device.."dhcp", zone="freifunk"})
+                       if has_radvd then
+                               uci:delete_all("radvd", "interface", {interface=device.."dhcp"})
+                               uci:delete_all("radvd", "interface", {interface=device})
+                               uci:delete_all("radvd", "prefix", {interface=device.."dhcp"})
+                               uci:delete_all("radvd", "prefix", {interface=device})
+                       end
+                       -- New Config
+                       local netconfig = uci:get_all("freifunk", "interface")
+                       util.update(netconfig, uci:get_all(community, "interface") or {})
+                       netconfig.proto = "static"
+                       netconfig.ipaddr = node_ip:string()
+                       if has_ipv6 then
+                               netconfig.ip6addr = node_ip6:string()
+                       end
+                       uci:section("network", "interface", device, netconfig)
+                       uci:save("network")
+                       if has_radvd then
+                               uci:section("radvd", "interface", nil, {
+                                       interface          =device,
+                                       AdvSendAdvert      =1,
+                                       AdvManagedFlag     =0,
+                                       AdvOtherConfigFlag =0,
+                                       ignore             =0
+                               })
+                               uci:section("radvd", "prefix", nil, {
+                                       interface          =device,
+                                       AdvOnLink          =1,
+                                       AdvAutonomous      =1,
+                                       AdvRouterAddr      =0,
+                                       ignore             =0,
+                               })
+                               uci:save("radvd")
+                       end
+                       tools.firewall_zone_add_interface("freifunk", device)
+                       uci:save("firewall")
+                       -- Write new olsrv4 interface
+                       local olsrifbase = uci:get_all("freifunk", "olsr_interface")
+                       util.update(olsrifbase, uci:get_all(community, "olsr_interface") or {})
+                       olsrifbase.interface = device
+                       olsrifbase.ignore    = "0"
+                       uci:section("olsrd", "Interface", nil, olsrifbase)
+                       olsrifbase.Mode = 'ether'
+                       -- Collect MESH DHCP IP NET
+                       local client = luci.http.formvalue("cbid.ffwizward.1.client_" .. device)
+                       if client then
+                               local dhcpmeshnet = luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device) and ip.IPv4(luci.http.formvalue("cbid.ffwizward.1.dhcpmesh_" .. device))
+                               hbconf(device)
+--[[
+                               if has_hb then
+                                       hbconf(device)
+                                       local ifacelist = uci:get_list("manager", "heartbeat", "interface") or {}
+                                       table.insert(ifacelist,device .. "dhcp")
+                                       uci:set_list("manager", "heartbeat", "interface", ifacelist)
+                                       uci:save("manager")
+                                       
+                               end
+]]
+                               if dhcpmeshnet then
+                                       if not dhcpmeshnet:minhost() or not dhcpmeshnet:mask() then
+                                               dhcpmesh.tag_missing[section] = true
+                                               dhcpmeshnet = nil
+                                               return
+                                       end
+                                       dhcp_ip = dhcpmeshnet:minhost():string()
+                                       dhcp_mask = dhcpmeshnet:mask():string()
+                                       dhcp_network = dhcpmeshnet:network():string()
+                                       uci:section("olsrd", "Hna4", nil, {
+                                               netmask  = dhcp_mask,
+                                               netaddr  = dhcp_network
+                                       })
+                                       uci:foreach("olsrd", "LoadPlugin",
+                                               function(s)             
+                                                       if s.library == "olsrd_p2pd.so.0.1.0" then
+                                                               uci:set("olsrd", s['.name'], "ignore", "0")
+                                                               local nonolsr = uci:get("olsrd", s['.name'], "NonOlsrIf") or ""
+                                                               uci:set("olsrd", s['.name'], "NonOlsrIf", device .." ".. nonolsr)
+                                                       end
+                                               end)
+                               else
+                                       gen_dhcp_range(netconfig.ipaddr)
+                               end
+                               if dhcp_ip and dhcp_mask then
+                                       -- Create alias
+                                       local aliasbase = uci:get_all("freifunk", "alias")
+                                       util.update(aliasbase, uci:get_all(community, "alias") or {})
+                                       aliasbase.interface = device
+                                       aliasbase.ipaddr = dhcp_ip
+                                       aliasbase.netmask = dhcp_mask
+                                       aliasbase.proto = "static"
+                                       uci:section("network", "alias", device .. "dhcp", aliasbase)
+                                       -- Create dhcp
+                                       local dhcpbase = uci:get_all("freifunk", "dhcp")
+                                       util.update(dhcpbase, uci:get_all(community, "dhcp") or {})
+                                       dhcpbase.interface = device .. "dhcp"
+                                       dhcpbase.force = 1
+                                       uci:section("dhcp", "dhcp", device .. "dhcp", dhcpbase)
+                                       uci:set_list("dhcp", device .. "dhcp", "dhcp_option", "119,olsr")
+                                       -- Create firewall settings
+                                       uci:delete_all("firewall", "rule", {
+                                               src="freifunk",
+                                               proto="udp",
+                                               dest_port="53"
+                                       })
+                                       uci:section("firewall", "rule", nil, {
+                                               src="freifunk",
+                                               proto="udp",
+                                               dest_port="53",
+                                               target="ACCEPT"
+                                       })
+                                       uci:delete_all("firewall", "rule", {
+                                               src="freifunk",
+                                               proto="udp",
+                                               src_port="68",
+                                               dest_port="67"
+                                       })
+                                       uci:section("firewall", "rule", nil, {
+                                               src="freifunk",
+                                               proto="udp",
+                                               src_port="68",
+                                               dest_port="67",
+                                               target="ACCEPT"
+                                       })
+                                       uci:delete_all("firewall", "rule", {
+                                               src="freifunk",
+                                               proto="tcp",
+                                               dest_port="8082",
+                                       })
+                                       uci:section("firewall", "rule", nil, {
+                                               src="freifunk",
+                                               proto="tcp",
+                                               dest_port="8082",
+                                               target="ACCEPT"
+                                       })
+                                       -- Register splash
+                                       uci:section("luci_splash", "iface", nil, {network=device.."dhcp", zone="freifunk"})
+                                       uci:save("luci_splash")
+                                       -- Make sure that luci_splash is enabled
+                                       sys.init.enable("luci_splash")
+                               end
+                       end
+                       uci:save("wireless")
+                       uci:save("network")
+                       uci:save("firewall")
+                       uci:save("dhcp")
+               end
+       end)
+       --enable radvd
+       if has_radvd then
+               sys.init.enable("radvd")
+       end
+       -- Enforce firewall include
+       local has_include = false
+       uci:foreach("firewall", "include",
+               function(section)
+                       if section.path == "/etc/firewall.freifunk" then
+                               has_include = true
+                       end
+               end)
+
+       if not has_include then
+               uci:section("firewall", "include", nil,
+                       { path = "/etc/firewall.freifunk" })
+       end
+       -- Allow state: invalid packets
+       uci:foreach("firewall", "defaults",
+               function(section)
+                       uci:set("firewall", section[".name"], "drop_invalid", "0")
+               end)
+
+       -- Prepare advanced config
+       local has_advanced = false
+       uci:foreach("firewall", "advanced",
+               function(section) has_advanced = true end)
+
+       if not has_advanced then
+               uci:section("firewall", "advanced", nil,
+                       { tcp_ecn = "0", ip_conntrack_max = "8192", tcp_westwood = "1" })
+       end
+       uci:save("wireless")
+       uci:save("network")
+       uci:save("firewall")
+       uci:save("dhcp")
+
+       if has_hb then
+               local dhcphb = hb:formvalue(section)
+               if dhcphb then
+                       uci:set("manager", "heartbeat", "enabled", "1")
+                       -- Make sure that heartbeat is enabled
+                       sys.init.enable("machash")
+               else
+                       uci:set("manager", "heartbeat", "enabled", "0")
+                       -- Make sure that heartbeat is enabled
+                       sys.init.disable("machash")
+               end
+               uci:save("manager")
+       end
+
+       uci:foreach("system", "system",
+               function(s)
+                       -- Make crond silent
+                       uci:set("system", s['.name'], "cronloglevel", "10")
+                       -- Make set timzone and zonename
+                       uci:set("system", s['.name'], "zonename", "Europe/Berlin")
+                       uci:set("system", s['.name'], "timezone", 'CET-1CEST,M3.5.0,M10.5.0/3')
+               end)
+
+       -- Create time rdate_servers
+       local rdate = uci:get_all("freifunk", "time")
+       uci:delete_all("system", "time")
+       uci:section("system", "time", "rdate_servers", rdate)
+       rdate.server = rdate.rdate_servers
+       rdate.rdate_servers = ""
+       uci:delete_all("system", "rdate", nil)
+       uci:section("system", "rdate", nil, rdate)
+       uci:save("system")
+
+       -- Delete old watchdog settings
+       uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_watchdog.so.0.1"})
+       -- Write new watchdog settings
+       uci:section("olsrd", "LoadPlugin", nil, {
+               library  = "olsrd_watchdog.so.0.1",
+               file     = "/var/run/olsrd.watchdog",
+               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",
+               suffix      = "." .. suffix ,
+               hosts_file  = "/var/etc/hosts.olsr",
+               latlon_file = "/var/run/latlon.js",
+               lat         = lat and string.format("%.15f", lat) or "",
+               lon         = lon and string.format("%.15f", lon) or "",
+               services_file = "/var/etc/services.olsr"
+       })
+
+       -- Import hosts and set domain
+       uci:foreach("dhcp", "dnsmasq", function(s)
+               uci:set_list("dhcp", s[".name"], "addnhosts", "/var/etc/hosts.olsr")
+               uci:set("dhcp", s[".name"], "local", "/" .. suffix .. "/")
+               uci:set("dhcp", s[".name"], "domain", suffix)
+       end)
+
+       -- Make sure that OLSR is enabled
+       sys.init.enable("olsrd")
+
+       uci:save("olsrd")
+       uci:save("dhcp")
+       -- Import hosts and set domain
+       if has_ipv6 then
+               uci:foreach("dhcp", "dnsmasq", function(s)
+                       uci:set_list("dhcp", s[".name"], "addnhosts", {"/var/etc/hosts.olsr","/var/etc/hosts.olsr.ipv6"})
+               end)
+       else
+               uci:foreach("dhcp", "dnsmasq", function(s)
+                       uci:set_list("dhcp", s[".name"], "addnhosts", "/var/etc/hosts.olsr")
+               end)
+       end
+
+       uci:save("dhcp")
+
+       -- Internet sharing
+       local share_value = share:formvalue(section)
+       if share_value == "1" then
+               uci:set("freifunk", "wizard", "netconfig", "1")
+               uci:section("firewall", "forwarding", nil, {src="freifunk", dest="wan"})
+
+               if has_autoipv6 then
+                       -- Set autoipv6 tunnel mode
+                       uci:set("autoipv6", "olsr_node", "enable", "0")
+                       uci:set("autoipv6", "tunnel", "enable", "1")
+                       uci:save("autoipv6")
+               end
+
+               -- Delete/Disable gateway plugin
+               uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_dyn_gw.so.0.5"})
+               uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_dyn_gw_plain.so.0.4"})
+               -- Enable gateway_plain plugin
+               uci:section("olsrd", "LoadPlugin", nil, {library="olsrd_dyn_gw_plain.so.0.4"})
+               sys.exec("chmod +x /etc/init.d/freifunk-p2pblock")
+               sys.init.enable("freifunk-p2pblock")
+               sys.init.enable("qos")
+               sys.exec('grep wan /etc/crontabs/root >/dev/null || echo "0 6 * * *     ifup wan" >> /etc/crontabs/root')
+
+               if wansec:formvalue(section) == "1" then
+                       uci:foreach("firewall", "zone",
+                               function(s)             
+                                       if s.name == "wan" then
+                                               uci:set("firewall", s['.name'], "local_restrict", "1")
+                                               return false
+                                       end
+                               end)
+               end
+       else
+               uci:set("freifunk", "wizard", "netconfig", "0")
+               uci:save("freifunk")
+               if has_autoipv6 then
+                       -- Set autoipv6 olsrd mode
+                       uci:set("autoipv6", "olsr_node", "enable", "1")
+                       uci:set("autoipv6", "tunnel", "enable", "0")
+                       uci:save("autoipv6")
+               end
+               -- Delete gateway plugins
+               uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_dyn_gw.so.0.5"})
+               uci:delete_all("olsrd", "LoadPlugin", {library="olsrd_dyn_gw_plain.so.0.4"})
+               -- Disable gateway_plain plugin
+               uci:section("olsrd", "LoadPlugin", nil, {
+                       library     = "olsrd_dyn_gw_plain.so.0.4",
+                       ignore      = 1,
+               })
+               sys.init.disable("freifunk-p2pblock")
+               sys.init.disable("qos")
+               sys.exec("chmod -x /etc/init.d/freifunk-p2pblock")
+               uci:delete_all("firewall", "forwarding", {src="freifunk", dest="wan"})
+               uci:foreach("firewall", "zone",
+                       function(s)             
+                               if s.name == "wan" then
+                                       uci:delete("firewall", s['.name'], "local_restrict")
+                                       return false
+                               end
+                       end)
+       end
+       -- Write gvpn dummy interface
+       if has_l2gvpn then
+               if gvpn then
+                       local vpn = gvpn:formvalue(section)
+                       if vpn then
+                               uci:delete_all("l2gvpn", "l2gvpn")
+                               uci:delete_all("l2gvpn", "node")
+                               uci:delete_all("l2gvpn", "supernode")
+                               -- Write olsr tunnel interface options
+                               local olsr_gvpnifbase = uci:get_all("freifunk", "olsr_gvpninterface")
+                               util.update(olsr_gvpnifbase, uci:get_all(community, "olsr_gvpninterface") or {})
+                               uci:section("olsrd", "Interface", nil, olsr_gvpnifbase)
+                               local vpnip = gvpnip:formvalue(section)
+                               local gvpnif = uci:get_all("freifunk", "gvpn_node")
+                               util.update(gvpnif, uci:get_all(community, "gvpn_node") or {})
+                               if gvpnif and gvpnif.tundev and vpnip then
+                                       uci:section("network", "interface", gvpnif.tundev, {
+                                               ifname  =gvpnif.tundev ,
+                                               proto   ="static" ,
+                                               ipaddr  =vpnip ,
+                                               netmask =gvpnif.subnet or "255.255.255.192" ,
+                                       })
+                                       gvpnif.ip=""
+                                       gvpnif.subnet=""
+                                       gvpnif.up=""
+                                       gvpnif.down=""
+                                       gvpnif.mac="00:00:48:"..string.format("%X",string.gsub( vpnip, ".*%." , "" ))..":00:00"
+                                       tools.firewall_zone_add_interface("freifunk", gvpnif.tundev)
+                                       uci:section("l2gvpn", "node" , gvpnif.community , gvpnif)
+                                       uci:save("network")
+                                       uci:save("l2gvpn")
+                                       uci:save("firewall")
+                                       uci:save("olsrd")
+                                       sys.init.enable("l2gvpn")
+                               end
+                       else
+                               -- Disable l2gvpn
+                               sys.exec("/etc/init.d/l2gvpn stop")
+                               sys.init.disable("l2gvpn")
+                       end
+               end
+       end
+
+       uci:save("freifunk")
+       uci:save("firewall")
+       uci:save("olsrd")
+       uci:save("system")
+end
+
+return f
+
diff --git a/applications/luci-ffwizard/luasrc/view/freifunk/ffwizard_error.htm b/applications/luci-ffwizard/luasrc/view/freifunk/ffwizard_error.htm
new file mode 100644 (file)
index 0000000..2364ff2
--- /dev/null
@@ -0,0 +1,27 @@
+<%+header%>
+
+<%
+local uci = require "luci.model.uci".cursor()
+local basicsurl = luci.dispatcher.build_url(luci.dispatcher.context.path[1], "freifunk", "basics")
+local hostname = uci:get_first ("system", "system", "hostname")
+local latitude = uci:get_first ("system", "system", "latitude")
+local longitude = uci:get_first ("system", "system", "longitude")
+local location = uci:get_first ("system", "system", "location")
+%>
+
+<h2><%:Error%></h2>
+
+<%:You can not use the wizard because some necessary values are not set.%>
+<p/>
+
+<%
+local co = uci:get("freifunk", "community", "name")
+if not (co and hostname and latitude and longitude and location) then
+%>
+<%:Basic settings are missing. Please go to this page and fill all required fields: %>
+<a href='<%=basicsurl%>'><%:Basic settings%></a>
+<p/>
+<% end %>
+
+
+<%+footer%>
index bbad46e..011148d 100755 (executable)
@@ -13,9 +13,6 @@ set_default_config()
                                set freifunk.wifi_device.rxantenna=1
                                set freifunk.wifi_device.disabled=0
                                set freifunk.wifi_device.txpower=""
-                               set freifunk.wifi_device.country=276
-                               set freifunk.wifi_device.regdomain="0x37"
-                               set freifunk.wifi_device.outdoor="1"
                                set freifunk.wifi_device.hwmode=11g
                                set freifunk.wifi_device.distance=1000
                                set freifunk.wifi_iface=defaults
@@ -33,7 +30,6 @@ set_default_config()
                                set freifunk.wifi_device.diversity=""
                                set freifunk.wifi_device.disabled=0
                                set freifunk.wifi_device.txpower=""
-                               set freifunk.wifi_device.country=DE
                                set freifunk.wifi_device.distance=1000
                                set freifunk.wifi_device.htmode='HT40-'
                                set freifunk.wifi_device.hwmode=11ng
@@ -50,7 +46,6 @@ set_default_config()
                                set freifunk.wifi_device.diversity=""
                                set freifunk.wifi_device.disabled=0
                                set freifunk.wifi_device.txpower=""
-                               set freifunk.wifi_device.country=DE
                                set freifunk.wifi_device.txantenna=0
                                set freifunk.wifi_device.rxantenna=0
                                set freifunk.wifi_device.hwmode=11g
index 45039a1..63d480f 100644 (file)
@@ -223,7 +223,7 @@ define Package/luci-mod-freifunk-community
   TITLE:=Freifunk Community Meta-Package
   DEPENDS+= \
    +luci-lib-web +luci-app-splash \
-   +luci-app-ffwizard-leipzig \
+   +luci-app-ffwizard \
    +luci-i18n-german \
    +PACKAGE_luci-mod-freifunk-community:olsrd +PACKAGE_luci-mod-freifunk-community:olsrd-mod-dyn-gw-plain \
    +PACKAGE_luci-mod-freifunk-community:olsrd-mod-txtinfo +PACKAGE_luci-mod-freifunk-community:olsrd-mod-nameservice \
@@ -322,10 +322,8 @@ define Package/luci-app-diag-devinfo/conffiles
 endef
 
 
-$(eval $(call application,ffwizard-leipzig,Freifunk Leipzig configuration wizard))
-
 $(eval $(call application,ffwizard,Freifunk configuration wizard,\
-       +luci-mod-freifunk))
+       +PACKAGE_luci-mod-freifunk))
 
 $(eval $(call application,siitwizard,SIIT IPv4-over-IPv6 configuration wizard,\
        +PACKAGE_luci-app-siitwizard:kmod-siit))
index b9f551b..154a299 100644 (file)
@@ -17,6 +17,7 @@ function index()
        local i18n = luci.i18n.translate
        local uci = require "luci.model.uci".cursor()
 
+       -- Frontend
        local page  = node()
        page.lock   = true
        page.target = alias("freifunk")
@@ -41,6 +42,7 @@ function index()
        local page  = node("freifunk", "index", "contact")
        page.target = template("freifunk/contact")
        page.title  = "Kontakt"
+       page.order    = 10
 
        local page  = node("freifunk", "status")
        page.target = template("freifunk/public_status")
@@ -60,22 +62,39 @@ function index()
                assign({"freifunk", "graph"}, {"admin", "statistics", "graph"}, i18n("Statistics"), 40)
        end
 
-       assign({"mini", "freifunk"}, {"admin", "freifunk"}, "Freifunk", 15)
-       entry({"admin", "freifunk"}, alias("admin", "freifunk", "index"), "Freifunk", 15)
-       local page  = node("admin", "freifunk", "index")
-       page.target = cbi("freifunk/freifunk")
+       -- backend
+       assign({"mini", "freifunk"}, {"admin", "freifunk"}, "Freifunk", 5)
+       entry({"admin", "freifunk"}, alias("admin", "freifunk", "index"), "Freifunk", 5)
+
+       local page  = node("admin", "freifunk")
+       page.target = template("freifunk/adminindex")
        page.title  = "Freifunk"
-       page.order  = 30
+       page.order  = 5
+
+       local page  = node("admin", "freifunk", "basics")
+       page.target = cbi("freifunk/basics")
+       page.title  = "Grundeinstellungen"
+       page.order  = 5
+       
+       local page  = node("admin", "freifunk", "basics", "profile")
+       page.target = cbi("freifunk/profile")
+       page.title  = "Profile"
+       page.order  = 10
+
+       local page  = node("admin", "freifunk", "basics", "profile_expert")
+       page.target = cbi("freifunk/profile_expert")
+       page.title  = "Profile (Expert)"
+       page.order  = 20
 
        local page  = node("admin", "freifunk", "Index-Page")
        page.target = cbi("freifunk/user_index")
        page.title  = "Index-Page"
-       page.order  = 35
+       page.order  = 50
 
        local page  = node("admin", "freifunk", "contact")
        page.target = cbi("freifunk/contact")
        page.title  = "Kontakt"
-       page.order  = 40
+       page.order  = 15
 
        entry({"freifunk", "map"}, template("freifunk-map/frame"), i18n("Karte"), 50)
        entry({"freifunk", "map", "content"}, template("freifunk-map/map"), nil, 51)
@@ -85,7 +104,6 @@ function index()
                        has_serv = true
                end
        end)
-
        if has_serv then
                entry({"freifunk", "services"}, template("freifunk-services/services"), i18n("Services"), 60)
        end
@@ -296,4 +314,3 @@ function public_status_json()
        luci.http.write_json(rv)
        return
 end
-
diff --git a/modules/freifunk/luasrc/model/cbi/freifunk/basics.lua b/modules/freifunk/luasrc/model/cbi/freifunk/basics.lua
new file mode 100644 (file)
index 0000000..1cd5c6d
--- /dev/null
@@ -0,0 +1,115 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2008 Steven Barth <steven@midlink.org>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+$Id: freifunk.lua 3291 2008-09-14 21:59:14Z Cyrus $
+]]--
+
+local fs = require "luci.fs"
+local util = require "luci.util"
+local uci = require "luci.model.uci".cursor()
+local profiles = "/etc/config/profile_"
+
+m = Map("freifunk", "Freifunk")
+c = m:section(NamedSection, "community", "public", "Gemeinschaft", [[Dies sind die Grundeinstellungen
+für die lokale Freifunkgemeinschaft. Diese Werte wirken sich NICHT auf die Konfiguration
+des Routers aus, sondern definieren nur die Vorgaben für den Freifunkassistenten.]])
+
+community = c:option(ListValue, "name", "Gemeinschaft")
+community.rmempty = false
+
+local list = { }
+local list = fs.glob(profiles .. "*")
+
+for k,v in ipairs(list) do
+       local name = uci:get_first(v, "community", "name") or "?"
+       local n = string.gsub(v, profiles, "")
+       community:value(n, name)
+end
+
+n = Map("system", translate("Basic system settings"))
+b = n:section(TypedSection, "system", "Basic system settings")
+b.anonymous = true
+
+hn = b:option(Value, "hostname", "hostname")
+hn.rmempty = false
+function hn.validate(self, value)
+       if value == nil then
+               return
+       elseif (#value > 24) or string.match(value, "[^%w%.%-]") or string.match(value, "^[%-%.]") or string.match(value, "[%-%.]$") then
+               return nil, translate("Hostname may contain up to 24 alphanumeric characters. Minus and period are also allowed, but not in the beginning or the end of the hostname.")
+       else
+               return value
+       end
+end
+
+loc = b:option(Value, "location", "Location")
+loc.rmempty = false
+
+lat = b:option(Value, "latitude", "latitude")
+lat.rmempty = false
+
+lon = b:option(Value, "longitude", "longitude")
+lon.rmempty = false
+
+--[[
+Opens an OpenStreetMap iframe or popup
+Makes use of resources/OSMLatLon.htm and htdocs/resources/osm.js
+(is that the right place for files like these?)
+]]--
+
+local class = util.class
+local co = "profile_augsburg"
+local syslat = uci:get_first(co, "community", "latitude")
+local syslon = uci:get_first(co, "community", "longitude")
+
+OpenStreetMapLonLat = class(AbstractValue)
+
+function OpenStreetMapLonLat.__init__(self, ...)
+       AbstractValue.__init__(self, ...)
+       self.template = "cbi/osmll_value"
+       self.latfield = nil
+       self.lonfield = nil
+       self.centerlat = ""
+       self.centerlon = ""
+       self.zoom = "0"
+       self.width = "100%" --popups will ignore the %-symbol, "100%" is interpreted as "100"
+       self.height = "600"
+       self.popup = false
+       self.displaytext="OpenStreetMap" --text on button, that loads and displays the OSMap
+       self.hidetext="X" -- text on button, that hides OSMap
+end
+
+
+f = SimpleForm("ffwizward", "OpenStreetMap", "Hier kann man die Geokoordinaten des Knotens herausfinden.")
+
+osm = f:field(OpenStreetMapLonLat, "latlon", "Geokoordinaten mit OpenStreetMap ermitteln:", "Klicken Sie auf Ihren Standort in der Karte. Diese Karte funktioniert nur, wenn das Gerät bereits eine Verbindung zum Internet hat.")
+osm.latfield = "lat"
+osm.lonfield = "lon"
+osm.centerlat = syslat
+osm.centerlon = syslon
+osm.width = "100%"
+osm.height = "600"
+osm.popup = false
+
+syslatlengh = string.len(syslat)
+if syslatlengh > 7 then
+       osm.zoom = "15"
+elseif syslatlengh > 5 then
+       osm.zoom = "12"
+else
+       osm.zoom = "6"
+end
+
+osm.displaytext="OpenStreetMap anzeigen"
+osm.hidetext="OpenStreetMap verbergen"
+
+
+return m, n
index c976409..178df28 100644 (file)
@@ -18,17 +18,17 @@ m = Map("freifunk", translate("Contact"), translate("Please fill in your contact
 
 c = m:section(NamedSection, "contact", "public", "")
 
-c:option(Value, "nickname", translate("Nickname"))
-c:option(Value, "name", translate("Realname"))
-c:option(Value, "mail", translate("E-Mail"), translate("You really should provide your address here!"))
-c:option(Value, "phone", translate("Phone"))
-c:option(Value, "location", translate("Location"))
-c:option(Value, "note", translate("Notice"))
+local nick = c:option(Value, "nickname", translate("Nickname"))
+nick.rmempty = false
+
+name = c:option(Value, "name", translate("Realname"))
+name.rmempty = false
 
-m2 = Map("system", translate("Coordinates"))
+mail = c:option(Value, "mail", translate("E-Mail"))
+mail.rmempty = false
 
-s = m2:section(TypedSection, "system", "")
-s:option(Value, "latitude", translate("Latitude")).rmempty = true
-s:option(Value, "longitude", translate("Longitude")).rmempty = true
+c:option(Value, "phone", translate("Phone"))
+
+c:option(Value, "note", translate("Notice"))
 
-return m, m2
+return m
diff --git a/modules/freifunk/luasrc/model/cbi/freifunk/freifunk.lua b/modules/freifunk/luasrc/model/cbi/freifunk/freifunk.lua
deleted file mode 100644 (file)
index 1a14746..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
---[[
-LuCI - Lua Configuration Interface
-
-Copyright 2008 Steven Barth <steven@midlink.org>
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-$Id$
-]]--
-m = Map("freifunk", "Freifunk")
-
-c = m:section(NamedSection, "community", "public", "Gemeinschaft", [[Dies sind die Grundeinstellungen
-für die lokale Freifunkgemeinschaft. Diese Werte wirken sich NICHT auf die Konfiguration
-des Routers aus, sondern definieren nur die Vorgaben für den Freifunkassistenten.]])
-c:option(Value, "name", "Gemeinschaft")
-c:option(Value, "homepage", "Webseite")
-c:option(Value, "ssid", "ESSID")
-c:option(Value, "prefix", "Netzprefix")
-
-return m
\ No newline at end of file
diff --git a/modules/freifunk/luasrc/model/cbi/freifunk/profile.lua b/modules/freifunk/luasrc/model/cbi/freifunk/profile.lua
new file mode 100644 (file)
index 0000000..87ec03c
--- /dev/null
@@ -0,0 +1,55 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       httc://www.apache.org/licenses/LICENSE-2.0
+]]--
+
+local uci = require "luci.model.uci".cursor()
+local community = "profile_" .. uci:get("freifunk", "community", "name")
+--local community = "profile_augsburg"
+
+
+m = Map(community, translate("Community settings"), translate("These are the settings of your local community"))
+
+c = m:section(NamedSection, "profile", "community", "foobar")
+
+name = c:option(Value, "name", "Name")
+name.rmempty = false
+
+homepage = c:option(Value, "homepage", "Webseite")
+
+cc = c:option(Value, "country", "Countrycode")
+function cc.cfgvalue(self, section)
+       return uci:get(community, "wifi_device", "country")
+end
+function cc.write(self, sec, value)
+       if value then
+               uci:set(community, "wifi_device", "country", value)
+               uci:save(community)
+       end
+end
+
+ssid = c:option(Value, "ssid", "ESSID")
+ssid.rmempty = false
+
+prefix = c:option(Value, "mesh_network", "Netzprefix")
+prefix.rmempty = false
+
+splash_net = c:option(Value, "splash_network", "Netzwerk für Client-DHCP-Adressen")
+splash_net.rmempty = false
+
+splash_prefix = c:option(Value, "splash_prefix", "Netzgröße für Clientnetze")
+splash_prefix.rmempty = false
+
+lat = c:option(Value, "latitude", "Latitude")
+lat.rmempty = false
+
+lon = c:option(Value, "longitude", "longitude")
+lon.rmempty = false
+return m
diff --git a/modules/freifunk/luasrc/model/cbi/freifunk/profile_expert.lua b/modules/freifunk/luasrc/model/cbi/freifunk/profile_expert.lua
new file mode 100644 (file)
index 0000000..5da7e7b
--- /dev/null
@@ -0,0 +1,36 @@
+--[[
+LuCI - Lua Configuration Interface
+
+Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+       httc://www.apache.org/licenses/LICENSE-2.0
+]]--
+
+local fs = require "nixio.fs"
+local uci = require "luci.model.uci".cursor()
+local community = "/etc/config/profile_" .. uci:get("freifunk", "community", "name")
+
+f = SimpleForm("community", translate("Community profile"), translate("This is the complete content of the selected community profile."))
+
+t = f:field(TextValue, "cop")
+t.rmempty = true
+t.rows = 30
+function t.cfgvalue()
+       return fs.readfile(community) or ""
+end
+
+function f.handle(self, state, data)
+       if state == FORM_VALID then
+               if data.cop then
+                       fs.writefile(cop, data.rcs:gsub("\r\n", "\n"))
+               end
+       end
+       return true
+end
+
+return f
+
diff --git a/modules/freifunk/luasrc/view/freifunk/adminindex.htm b/modules/freifunk/luasrc/view/freifunk/adminindex.htm
new file mode 100644 (file)
index 0000000..d2bf0b7
--- /dev/null
@@ -0,0 +1,33 @@
+<%+header%>
+<%
+local uci = require "luci.model.uci".cursor()
+local contact = uci:get_all("freifunk", "contact")
+local contacturl = luci.dispatcher.build_url(luci.dispatcher.context.path[1], "freifunk", "contact")
+local hostname = uci:get_first ("system", "system", "hostname")
+local latitude = uci:get_first ("system", "system", "latitude")
+local longitude = uci:get_first ("system", "system", "longitude")
+local location = uci:get_first ("system", "system", "location")
+local basicsurl = luci.dispatcher.build_url(luci.dispatcher.context.path[1], "freifunk", "basics")
+%>
+
+<h2><%:Freifunk Overview%></h2>
+
+<%:These pages will assist you in setting up your router for Freifunk or similar wireless community networks.%>
+<p />
+
+<% if not (hostname and latitude and longitude and location) then%>
+<div class="error">
+        <%:Basic settings are missing. Please go to this page and fill all required fields: %>
+        <a href='<%=basicsurl%>'><%:Basic settings%></a>
+</div>
+<%end%>
+<p />
+
+<% if not (contact.nickname and contact.name and contact.mail) then%>
+<div class="error">
+       <%:Contact information missing. Please go to this page and fill all required fields: %>
+       <a href='<%=contacturl%>'><%:Contact%></a>
+</div>
+<%end%>
+
+<%+footer%>
index 0b4a068..0d917ad 100644 (file)
@@ -13,15 +13,23 @@ $Id$
 
 -%>
 <%+header%>
-<% local contact = luci.model.uci.cursor():get_all("freifunk", "contact") %>
+
+<% 
+local uci = require "luci.model.uci".cursor()
+local contact = uci:get_all("freifunk", "contact")
+local location = uci:get_first("system", "system", "location")
+local lon = uci:get_first("system", "system", "longitude")
+local lat = uci:get_first("system", "system", "latitude")
+%>
+
 <h2><a id="content" name="content"><%:Contact%></a></h2>
 <table cellspacing="0" cellpadding="6">
        <tr><th><%:Nickname%>:</th><td><%=contact.nickname%></td></tr>
        <tr><th><%:Realname%>:</th><td><%=contact.name%></td></tr>
        <tr><th><%:E-Mail%>:</th><td><%=contact.mail%></td></tr>
        <tr><th><%:Phone%>:</th><td><%=contact.phone%></td></tr>
-       <tr><th><%:Location%>:</th><td><%=contact.location%></td></tr>
-       <tr><th><%:Coordinates%>:</th><td><%=contact.geo%></td></tr>
+       <tr><th><%:Location%>:</th><td><%=location%></td></tr>
+       <tr><th><%:Coordinates%>:</th><td><%=lat%> <%=lon%></td></tr>
        <tr><th><%:Notice%>:</th><td><%=contact.note%></td></tr>
 </table>
 <%+footer%>
index d93dcd8..4a9ab2e 100644 (file)
@@ -14,7 +14,16 @@ $Id$
 -%>
 <%+header%>
 <% 
-local ff = luci.model.uci.cursor():get_all("freifunk")
+local uci = require "luci.model.uci".cursor()
+local ff = uci:get_all("freifunk")
+if not ff.community.name then
+       ff.community.name = ""
+end
+local co = "profile_" .. ff.community.name
+local community = uci:get_first(co, "community", "name") or "Freifunk"
+local url = uci:get_first(co, "community", "homepage") or "http://www.freifunk.net"
+
+
 require("luci.fs")
 local usertext = luci.fs.readfile("/www/luci-static/index_user.html")
 
@@ -23,7 +32,7 @@ if (ff.community.DefaultText or "") ~= "disabled" then
        defaulttext = '<h2><a id="content" name="content">'..
        (translate("Hello and welcome in the network of"))..
        ' '..
-       (ff.community.name or "Freifunk Deutschland")..
+       (community or "Freifunk Deutschland")..
        '!</a></h2><p>'..
        translate("We are an initiative to establish a free, independent and open wireless mesh network.")..
        '<br />'..
@@ -31,20 +40,16 @@ if (ff.community.DefaultText or "") ~= "disabled" then
        ' '..
        luci.sys.hostname()..
        '. '..
-       translate("It is operated by")..
+       translate("It is operated by ")..
        '<a href="'..
        luci.dispatcher.build_url("freifunk", "index", "contact")..
-       '"> '..
-       (ff.contact.nickname or "Anonymous")..
+       '">'..
+       (ff.contact.nickname or translate("Please set your contact information"))..
        '</a>.</p><p>'..
        translate("You can find further information about the global Freifunk initiative at")..
        ' <a href="http://freifunk.net">Freifunk.net</a>.<br />'..
        translate("If you are interested in our project then contact the local community")..
-       ' <a href="'..
-       (ff.community.homepage or "http//freifunk.net")..
-       '">'..
-       (ff.community.name or "Freifunk")..
-       '</a>.</p><p><strong>'..
+       ' <a href="'..url..'">'..community..'</a>.</p><p><strong>'..
        translate("Notice")..
        '</strong>: '..
        translate("Internet access depends on technical and organisational conditions and may or may not work for you.")..
index fe1514f..8eb577f 100644 (file)
@@ -88,275 +88,3 @@ config 'defaults' 'time'
 config 'defaults' 'upgrade'
        option 'repository' 'http://dev.luci.freifunk-halle.net/freifunk-snapshots'
        option 'rssfeed' 'http://firmware.leipzig.freifunk.net/kamikaze/.rss.xml'
-
-config 'community' 'leipzig'
-       option 'name' 'Freifunk Leipzig'
-       option 'homepage' 'http://leipzig.freifunk.net'
-       option 'ssid' 'leipzig.freifunk.net'
-       option 'mesh_network' '104.61.0.0/16'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '51.33348'
-       option 'longitude' '12.40297'
-
-config 'community' 'halle'
-       option 'name' 'Freifunk Halle'
-       option 'homepage' 'http://halle.freifunk.net'
-       option 'ssid' 'halle.freifunk.net'
-       option 'mesh_network' '104.62.0.0/16'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '51.47911'
-       option 'longitude' '11.96901'
-
-config 'community' 'l59'
-       option 'name' 'Freifunk L59'
-       option 'homepage' 'http://freifunk.net'
-       option 'ssid' 'start.freifunk.net'
-       option 'mesh_network' '104.59.0.0/16'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '52.26337'
-       option 'longitude' '10.52103'
-
-config 'community' 'berlin'
-       option 'name' 'Freifunk Berlin'
-       option 'homepage' 'http://berlin.freifunk.net'
-       option 'ssid' 'olsr.freifunk.net'
-       option 'mesh_network' '104.0.0.0/8'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '52.52075'
-       option 'longitude' '13.40948'
-       option 'external' 'freifunk_berlin'
-
-config 'community' 'potsdam'
-       option 'name' 'Freifunk Potsdam'
-       option 'homepage' 'http://potsdam.freifunk.net'
-       option 'ssid' 'www.freifunk-potsdam.de'
-       option 'mesh_network' '10.22.0.0/16'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '52.39349'
-       option 'longitude' '13.06489'
-       option 'external' 'freifunk_potsdam'
-
-config 'community' 'hamburg'
-       option 'name' 'Freifunk Hamburg'
-       option 'homepage' 'http://hamburg.piratenpartei.de'
-       option 'ssid' 'hamburg.freifunk.net'
-       option 'mesh_network' '10.112.0.0/12'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '53.56262'
-       option 'longitude' '10.01069'
-       option 'external' 'freifunk_hamburg'
-
-config 'community' 'hannover'
-       option 'name' 'Freifunk Hannover'
-       option 'homepage' 'http://hannover.freifunk.net'
-       option 'ssid' 'hannover.freifunk.net'
-       option 'mesh_network' '10.2.0.0/16'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '52.38427'
-       option 'longitude' '9.74359'
-       option 'external' 'freifunk_hannover'
-
-config 'community' 'augsburg'
-       option 'name' 'Freifunk Augsburg'
-       option 'homepage' 'http://augsburg.freifunk.net'
-       option 'ssid' 'augsburg.freifunk.net'
-       option 'mesh_network' '10.11.0.0/18'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '48.37071'
-       option 'longitude' '10.89475'
-       option 'suffix' 'ffa'
-       option 'external' 'freifunk_augsburg'
-
-config 'community' 'jena'
-       option 'name' 'Freifunk Jena'
-       option 'homepage' 'http://www.freifunk-jena.de'
-       option 'ssid' 'www.freifunk-jena.de'
-       option 'mesh_network' '10.127.0.0/20'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '29'
-       option 'latitude' '50.92779'
-       option 'longitude' '11.58431'
-       option 'external' 'freifunk_jena'
-
-config 'community' 'mainz'
-       option 'name' 'Freifunk Mainz'
-       option 'homepage' 'http://mainz.freifunk.net'
-       option 'ssid' 'mainz.freifunk.net'
-       option 'mesh_network' '10.37.0.0/16'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '49.99635'
-       option 'longitude' '8.27417'
-       option 'external' 'freifunk_mainz'
-
-config 'community' 'seefeld'
-       option 'name' 'Freifunk Seefeld'
-       option 'homepage' 'http://wiki.freifunk.net/Seefeld.freifunk.net'
-       option 'ssid' 'seefeld.freifunk.net'
-       option 'mesh_network' '10.111.0.0/16'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '48.03485'
-       option 'longitude' '11.21279'
-       option 'external' 'freifunk_seefeld'
-
-config 'community' 'duesseldorf'
-       option 'name' 'Freifunk Duesseldorf'
-       option 'homepage' 'http://wiki.piratenpartei.de/D%C3%BCsseldorf/Freifunk'
-       option 'ssid' 'duesseldorf.freifunk.net'
-       option 'mesh_network' '10.40.0.0/16'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '51.22347'
-       option 'longitude' '6.78449'
-       option 'external' 'freifunk_duesseldorf'
-
-config 'community' 'oldenburg'
-       option 'name' 'Freifunk Oldenburg'
-       option 'homepage' 'http://oldenburg.freifunk.net'
-       option 'ssid' 'oldenburg.freifunk.net'
-       option 'mesh_network' '10.18.0.0/16'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '53.14083'
-       option 'longitude' '8.21314'
-       option 'external' 'freifunk_oldenburg'
-
-config 'community' 'kiberpipa'
-       option 'name' 'Kiberpipa.net'
-       option 'homepage' 'http://www.kiberpipa.net'
-       option 'ssid' 'open.kiberpipa.net'
-       option 'mesh_network' '10.14.0.0/16'
-       option 'splash_network' '10.14.128.0/17'
-       option 'splash_prefix' '27'
-       option 'latitude' '46.05063'
-       option 'longitude' '14.50402'
-       option 'external' 'freifunk_kiberpipa'
-
-config 'community' 'wlanljubljana'
-       option 'name' 'wlan ljubljana'
-       option 'homepage' 'http://wlan-lj.net'
-       option 'ssid' 'open.wlan-lj.net'
-       option 'mesh_network' '10.254.0.0/16'
-       option 'splash_network' '10.254.120.0/21'
-       option 'splash_prefix' '27'
-       option 'latitude' '46.05063'
-       option 'longitude' '14.50402'
-       option 'external' 'freifunk_wlanljubljana'
-
-config 'community' 'heppenheim'
-       option 'name' 'Freifunk Heppenheim'
-       option 'homepage' 'http://heppenheim.freifunk.net'
-       option 'ssid' 'heppenheim.freifunk.net'
-       option 'mesh_network' '10.48.0.0/16'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '51.151786'
-       option 'longitude' '10.415039'
-
-config 'community' 'bensheim'
-       option 'name' 'Freifunk Bensheim'
-       option 'homepage' 'http://bensheim.freifunk.net'
-       option 'ssid' 'bensheim.freifunk.net'
-       option 'mesh_network' '10.49.0.0/16'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '49.63939'
-       option 'longitude' '8.633718'
-
-config 'community' 'marburg'
-       option 'name' 'Freifunk Marburg'
-       option 'homepage' ' http://marburg.freifunk.de'
-       option 'ssid' 'marburg.freifunk.net'
-       option 'mesh_network' '10.128.0.0/16'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '29'
-       option 'latitude' '49.63939'
-       option 'longitude' '8.633718'
-       option 'external' 'freifunk_marburg'
-
-config 'community' 'openwireless_bern'
-       option 'name' 'Openwireless Bern'
-       option 'homepage' 'http://bern.openwireless.ch/'
-       option 'ssid' 'www.openwireless.ch'
-       option 'mesh_network' '10.247.0.0/16'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '50.814788'
-       option 'longitude' '8.769239'
-       option 'external' 'openwireless_bern'
-
-config 'community' 'piraten_BergischesLand'
-       option 'name' 'Piratenfreifunk Bergisches Land'
-       option 'homepage' 'http://www.piraten-bergisches-land.de'
-       option 'ssid' 'PiratenfunkBL'
-       option 'mesh_network' '10.3.0.0/16'
-       option 'splash_network' '192.168.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '51.26849'
-       option 'longitude' '7.19476'
-       option 'external' 'freifunk_bergischesland'
-
-config 'community' 'piraten_dresden'
-       option 'name' 'Piratenfreifunk Dresden'
-       option 'homepage' 'http://www.piraten-sachsen.de/'
-       option 'ssid' 'dresden.freifunk.net'
-       option 'mesh_network' '10.12.0.0/16'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '51.05081'
-       option 'longitude' '13.73420'
-       option 'external' 'freifunk_dresden'
-
-config 'community' 'dresden'
-       option 'name' 'Freifunk Dresden'
-       option 'homepage' 'http://ddmesh.de/'
-       option 'ssid' 'dresden.freifunk.net'
-       option 'mesh_network' '10.12.0.0/16'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '51.05081'
-       option 'longitude' '13.73420'
-       option 'external' 'freifunk_dresden'
-
-config 'community' 'neuss'
-       option 'name' 'Freifunk Neuss'
-       option 'homepage' 'http://neuss.freifunk.net'
-       option 'ssid' 'neuss.freifunk.net'
-       option 'mesh_network' '172.28.0.0/16'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '51.19045'
-       option 'longitude' '6.69471'
-       option 'external' 'freifunk_neuss'
-
-config 'community' 'pberg'
-       option 'name' 'Freifunk Berlin Prenzlauer Berg'
-       option 'homepage' 'http://pberg.freifunk.net'
-       option 'ssid' 'olsr.freifunk.net'
-       option 'mesh_network' '104.0.0.0/8'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '52.5427'
-       option 'longitude' '13.4172'
-       option 'external' 'freifunk_berlin'
-
-config 'community' 'rosbach'
-       option 'name' 'Freifunk Rosbach'
-       option 'homepage' 'freifunk-rosbach.de'
-       option 'ssid' 'rosbach.freifunk.net'
-       option 'mesh_network' '10.212.0.0/16'
-       option 'splash_network' '10.104.0.0/16'
-       option 'splash_prefix' '27'
-       option 'latitude' '50.18'
-       option 'longitude' '8.42'
-       option 'external' 'freifunk_rosbach'
-
diff --git a/modules/freifunk/root/etc/config/freifunk_augsburg b/modules/freifunk/root/etc/config/freifunk_augsburg
deleted file mode 100644 (file)
index 1ce71e0..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package 'freifunk_augsburg'
-
-config 'defaults' 'interface'
-       option 'netmask' '255.255.192.0'
-
diff --git a/modules/freifunk/root/etc/config/freifunk_bergischesland b/modules/freifunk/root/etc/config/freifunk_bergischesland
deleted file mode 100644 (file)
index cfdb15f..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package        'freifunk_bergischesland'
-
-config 'defaults' 'wifi_device'
-       option 'channel' '11'
-
-config 'defaults' 'wifi_iface'
-       option 'bssid' '02:40:00:42:42:42'
-
diff --git a/modules/freifunk/root/etc/config/freifunk_berlin b/modules/freifunk/root/etc/config/freifunk_berlin
deleted file mode 100644 (file)
index 467c3c4..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package 'freifunk_berlin'
-
-config 'defaults' 'wifi_device'
-       option 'channel' '10'
-
diff --git a/modules/freifunk/root/etc/config/freifunk_dresden b/modules/freifunk/root/etc/config/freifunk_dresden
deleted file mode 100644 (file)
index 239589a..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package 'freifunk_dresden'
-
-config 'defaults' 'wifi_device'
-       option 'channel' '1'
-
diff --git a/modules/freifunk/root/etc/config/freifunk_duesseldorf b/modules/freifunk/root/etc/config/freifunk_duesseldorf
deleted file mode 100644 (file)
index 945cba6..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-package 'freifunk_duesseldorf'
-
-config 'defaults' 'interface'
-       option 'netmask' '255.255.0.0'
-
-config 'defaults' 'wifi_device'
-       option 'channel' '3'
-
-config 'defaults' 'wifi_iface'
-       option 'bssid' '02:CA:FF:EE:BA:BE'
-
diff --git a/modules/freifunk/root/etc/config/freifunk_hamburg b/modules/freifunk/root/etc/config/freifunk_hamburg
deleted file mode 100644 (file)
index 4f9abdf..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package 'freifunk_hamburg'
-
-config 'defaults' 'interface'
-       option 'netmask' '255.240.0.0'
-
-config 'defaults' 'wifi_device'
-       option 'channel' '1'
-
diff --git a/modules/freifunk/root/etc/config/freifunk_hannover b/modules/freifunk/root/etc/config/freifunk_hannover
deleted file mode 100644 (file)
index 10200f7..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package 'freifunk_hannover'
-
-config 'defaults' 'wifi_iface'
-       option 'bssid' 'CA:FF:EE:CA:FF:EE'
-
-config 'defaults' 'interface'
-       option 'netmask' '255.255.0.0'
-
diff --git a/modules/freifunk/root/etc/config/freifunk_jena b/modules/freifunk/root/etc/config/freifunk_jena
deleted file mode 100644 (file)
index eb85b18..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-package 'freifunk_jena'
-
-config 'defaults' 'interface'
-       option 'dns' '217.11.48.200 217.11.49.200 8.8.8.8'
-
diff --git a/modules/freifunk/root/etc/config/freifunk_kiberpipa b/modules/freifunk/root/etc/config/freifunk_kiberpipa
deleted file mode 100644 (file)
index 6699291..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package 'freifunk_kiberpipa'
-
-config 'defaults' 'wifi_device'
-       option 'channel' '8'
-
-config 'defaults' 'interface'
-       option 'dns' '10.14.0.1 208.67.222.220 208.67.220.222'
-       option 'netmask' '255.255.0.0'
diff --git a/modules/freifunk/root/etc/config/freifunk_mainz b/modules/freifunk/root/etc/config/freifunk_mainz
deleted file mode 100644 (file)
index e50f6f1..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-package 'freifunk_mainz'
-
-config 'defaults' 'wifi_iface'
-       option 'bssid' '02:ca:ff:ee:ba:be'
-
-config 'defaults' 'wifi_device'
-       option 'channel' '1'
-
-config 'defaults' 'interface'
-       option 'netmask' '255.255.0.0'
-
diff --git a/modules/freifunk/root/etc/config/freifunk_marburg b/modules/freifunk/root/etc/config/freifunk_marburg
deleted file mode 100644 (file)
index 2045a38..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-package 'freifunk_marburg'
-
-config 'defaults' 'interface'
-       option 'dns' '8.8.8.8 212.204.49.83'
-        option 'netmask' '255.255.0.0'
-
diff --git a/modules/freifunk/root/etc/config/freifunk_neuss b/modules/freifunk/root/etc/config/freifunk_neuss
deleted file mode 100644 (file)
index 8ee6a15..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-package 'freifunk_neuss'
-
-config 'defaults' 'wifi_device'
-       option 'channel' '11'
-
-config 'defaults' 'interface'
-       option 'netmask' '255.255.0.0'
-
-config 'defaults' 'wifi_iface'
-       option 'bssid' 'DE:AD:BE:EF:CA:FE'
diff --git a/modules/freifunk/root/etc/config/freifunk_oldenburg b/modules/freifunk/root/etc/config/freifunk_oldenburg
deleted file mode 100644 (file)
index 24367d3..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package 'freifunk_oldenburg'
-
-config 'defaults' 'wifi_device'
-       option 'channel' '6'
-
-config 'defaults' 'wifi_iface'
-       option 'bssid' '02:CA:FF:EE:BA:BE'
diff --git a/modules/freifunk/root/etc/config/freifunk_potsdam b/modules/freifunk/root/etc/config/freifunk_potsdam
deleted file mode 100644 (file)
index feb7fb5..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package 'freifunk_potsdam'
-
-config 'defaults' 'interface'
-       option 'netmask' '255.255.0.0'
-
-config 'defaults' 'wifi_device'
-       option 'channel' '13'
-
diff --git a/modules/freifunk/root/etc/config/freifunk_rosbach b/modules/freifunk/root/etc/config/freifunk_rosbach
deleted file mode 100644 (file)
index b8df6d1..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-package        'freifunk_rosbach'
-
-config 'defaults' 'wifi_device'
-       option 'channel' '13'
-
-config 'defaults' 'wifi_iface'
-       option 'bssid' 'D2:CA:FF:EE:BA:BE'
-
-config 'defaults' 'interface'
-        option 'netmask' '255.255.0.0'
-
diff --git a/modules/freifunk/root/etc/config/freifunk_seefeld b/modules/freifunk/root/etc/config/freifunk_seefeld
deleted file mode 100644 (file)
index 7a2346f..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-package 'freifunk_seefeld'
-
-config 'defaults' 'interface'
-       option 'netmask' '255.255.255.0'
-
-config 'defaults' 'wifi_device'
-       option 'channel' '1'
-       option 'bssid' '02:CA:FF:EE:BA:BB'
-
diff --git a/modules/freifunk/root/etc/config/freifunk_wlanljubljana b/modules/freifunk/root/etc/config/freifunk_wlanljubljana
deleted file mode 100644 (file)
index 3a4e300..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package 'freifunk_wlanljubljana'
-
-config 'defaults' 'wifi_device'
-       option 'channel' '8'
-
-config 'defaults' 'interface'
-       option 'dns' '10.254.0.1 10.254.0.2'
-       option 'netmask' '255.255.0.0'
diff --git a/modules/freifunk/root/etc/config/openwireless_bern b/modules/freifunk/root/etc/config/openwireless_bern
deleted file mode 100644 (file)
index c69a6df..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-package 'openwireless_bern'
-
-config 'defaults' 'interface'
-       option 'netmask' '255.255.0.0'
-       option 'dns' '208.67.222.222 208.67.220.220'
-
-config 'defaults' 'wifi_device'
-       option 'channel' '10'
-       option 'country' '756'
-
diff --git a/modules/freifunk/root/etc/config/profile_-custom b/modules/freifunk/root/etc/config/profile_-custom
new file mode 100644 (file)
index 0000000..3b06444
--- /dev/null
@@ -0,0 +1,11 @@
+config 'community'     'profile'
+       option 'name' 'Custom'
+       option 'homepage' 'http://example.freifunk.net'
+       option 'ssid' 'example.freifunk.net'
+       option 'splash_network' '10.104.0.0/16'
+       option 'latitude' '52.000'
+       option 'longitude' '10.000'
+       option 'external' 'freifunk_custom'
+       option 'splash_prefix' '28'
+       option 'mesh_network' '1.0.0.0/16'
+
diff --git a/modules/freifunk/root/etc/config/profile_augsburg b/modules/freifunk/root/etc/config/profile_augsburg
new file mode 100644 (file)
index 0000000..fd5cdda
--- /dev/null
@@ -0,0 +1,14 @@
+config 'community' 'profile'
+        option 'name' 'Freifunk Augsburg'
+        option 'homepage' 'http://augsburg.freifunk.net'
+        option 'ssid' 'augsburg.freifunk.net'
+        option 'mesh_network' '10.11.0.0/18'
+        option 'splash_network' '10.104.0.0/16'
+        option 'latitude' '48.37071'
+        option 'longitude' '10.89475'
+        option 'suffix' 'ffa'
+        option 'splash_prefix' '27'
+
+config 'defaults' 'interface'
+        option 'netmask' '255.255.192.0'
+
diff --git a/modules/freifunk/root/etc/config/profile_bensheim b/modules/freifunk/root/etc/config/profile_bensheim
new file mode 100644 (file)
index 0000000..48c1d47
--- /dev/null
@@ -0,0 +1,9 @@
+config 'community' 'profile'
+       option 'name' 'Freifunk Bensheim'
+       option 'homepage' 'http://bensheim.freifunk.net'
+       option 'ssid' 'bensheim.freifunk.net'
+       option 'mesh_network' '10.49.0.0/16'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '27'
+       option 'latitude' '49.63939'
+       option 'longitude' '8.633718'
diff --git a/modules/freifunk/root/etc/config/profile_bergischesland b/modules/freifunk/root/etc/config/profile_bergischesland
new file mode 100644 (file)
index 0000000..b32eea9
--- /dev/null
@@ -0,0 +1,20 @@
+config 'community'     'profile'
+       option 'name' 'Piratenfreifunk Bergisches Land'
+       option 'homepage' 'http://www.piraten-bergisches-land.de'
+       option 'ssid' 'PiratenfunkBL'
+       option 'mesh_network' '10.3.0.0/16'
+       option 'splash_network' '192.168.0.0/16'
+       option 'splash_prefix' '27'
+       option 'latitude' '51.26849'
+       option 'longitude' '7.19476'
+       option 'external' 'freifunk_bergischesland'
+
+config 'defaults' 'wifi_device'
+       option 'channel' '11'
+
+config 'defaults' 'wifi_iface'
+       option 'bssid' '02:40:00:42:42:42'
+
+config 'defaults' 'interface'
+       option 'netmask' '255.255.0.0'
+
diff --git a/modules/freifunk/root/etc/config/profile_berlin b/modules/freifunk/root/etc/config/profile_berlin
new file mode 100644 (file)
index 0000000..a37a6cb
--- /dev/null
@@ -0,0 +1,12 @@
+config 'community' 'profile'
+       option 'name' 'Freifunk Berlin'
+       option 'homepage' 'http://berlin.freifunk.net'
+       option 'ssid' 'olsr.freifunk.net'
+       option 'mesh_network' '104.0.0.0/8'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '27'
+       option 'latitude' '52.52075'
+       option 'longitude' '13.40948'
+
+config 'defaults' 'wifi_device'
+       option 'channel' '10'
diff --git a/modules/freifunk/root/etc/config/profile_dresden b/modules/freifunk/root/etc/config/profile_dresden
new file mode 100644 (file)
index 0000000..6b5dc87
--- /dev/null
@@ -0,0 +1,12 @@
+config 'community' 'profile'
+       option 'name' 'Freifunk Dresden'
+       option 'homepage' 'http://ddmesh.de/'
+       option 'ssid' 'dresden.freifunk.net'
+       option 'mesh_network' '10.12.0.0/16'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '27'
+       option 'latitude' '51.05081'
+       option 'longitude' '13.73420'
+
+config 'defaults' 'wifi_device'
+       option 'channel' '1'
diff --git a/modules/freifunk/root/etc/config/profile_duesseldorf b/modules/freifunk/root/etc/config/profile_duesseldorf
new file mode 100644 (file)
index 0000000..64ebbac
--- /dev/null
@@ -0,0 +1,18 @@
+config 'community' 'profile'
+       option 'name' 'Freifunk Duesseldorf'
+       option 'homepage' 'http://wiki.piratenpartei.de/D%C3%BCsseldorf/Freifunk'
+       option 'ssid' 'duesseldorf.freifunk.net'
+       option 'mesh_network' '10.40.0.0/16'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '27'
+       option 'latitude' '51.22347'
+       option 'longitude' '6.78449'
+
+config 'defaults' 'interface'
+       option 'netmask' '255.255.0.0'
+
+config 'defaults' 'wifi_device'
+       option 'channel' '3'
+
+config 'defaults' 'wifi_iface'
+       option 'bssid' '02:CA:FF:EE:BA:BE'
diff --git a/modules/freifunk/root/etc/config/profile_halle b/modules/freifunk/root/etc/config/profile_halle
new file mode 100644 (file)
index 0000000..2680087
--- /dev/null
@@ -0,0 +1,9 @@
+config 'community' 'profile'
+       option 'name' 'Freifunk Halle'
+       option 'homepage' 'http://halle.freifunk.net'
+       option 'ssid' 'halle.freifunk.net'
+       option 'mesh_network' '104.62.0.0/16'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '27'
+       option 'latitude' '51.47911'
+       option 'longitude' '11.96901'
diff --git a/modules/freifunk/root/etc/config/profile_hamburg b/modules/freifunk/root/etc/config/profile_hamburg
new file mode 100644 (file)
index 0000000..ba1dd21
--- /dev/null
@@ -0,0 +1,15 @@
+config 'community' 'profile'
+       option 'name' 'Freifunk Hamburg'
+       option 'homepage' 'http://hamburg.piratenpartei.de'
+       option 'ssid' 'hamburg.freifunk.net'
+       option 'mesh_network' '10.112.0.0/12'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '27'
+       option 'latitude' '53.56262'
+       option 'longitude' '10.01069'
+
+config 'defaults' 'interface'
+       option 'netmask' '255.240.0.0'
+
+config 'defaults' 'wifi_device'
+       option 'channel' '1'
diff --git a/modules/freifunk/root/etc/config/profile_hannover b/modules/freifunk/root/etc/config/profile_hannover
new file mode 100644 (file)
index 0000000..99f2c46
--- /dev/null
@@ -0,0 +1,16 @@
+config 'community' 'profile'
+       option 'name' 'Freifunk Hannover'
+       option 'homepage' 'http://hannover.freifunk.net'
+       option 'ssid' 'hannover.freifunk.net'
+       option 'mesh_network' '10.2.0.0/16'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '27'
+       option 'latitude' '52.38427'
+       option 'longitude' '9.74359'
+
+config 'defaults' 'wifi_iface'
+       option 'bssid' 'CA:FF:EE:CA:FF:EE'
+
+config 'defaults' 'interface'
+       option 'netmask' '255.255.0.0'
+
diff --git a/modules/freifunk/root/etc/config/profile_heppenheim b/modules/freifunk/root/etc/config/profile_heppenheim
new file mode 100644 (file)
index 0000000..a830494
--- /dev/null
@@ -0,0 +1,9 @@
+config 'community' 'profile'
+       option 'name' 'Freifunk Heppenheim'
+       option 'homepage' 'http://heppenheim.freifunk.net'
+       option 'ssid' 'heppenheim.freifunk.net'
+       option 'mesh_network' '10.48.0.0/16'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '27'
+       option 'latitude' '51.151786'
+       option 'longitude' '10.415039'
diff --git a/modules/freifunk/root/etc/config/profile_jena b/modules/freifunk/root/etc/config/profile_jena
new file mode 100644 (file)
index 0000000..5741d09
--- /dev/null
@@ -0,0 +1,12 @@
+config 'community' 'profile'
+       option 'name' 'Freifunk Jena'
+       option 'homepage' 'http://www.freifunk-jena.de'
+       option 'ssid' 'www.freifunk-jena.de'
+       option 'mesh_network' '10.127.0.0/20'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '29'
+       option 'latitude' '50.92779'
+       option 'longitude' '11.58431'
+
+config 'defaults' 'interface'
+       option 'dns' '217.11.48.200 217.11.49.200 8.8.8.8'
diff --git a/modules/freifunk/root/etc/config/profile_kiberpipa b/modules/freifunk/root/etc/config/profile_kiberpipa
new file mode 100644 (file)
index 0000000..628850a
--- /dev/null
@@ -0,0 +1,16 @@
+config 'community' 'profile'
+       option 'name' 'Kiberpipa.net'
+       option 'homepage' 'http://www.kiberpipa.net'
+       option 'ssid' 'open.kiberpipa.net'
+       option 'mesh_network' '10.14.0.0/16'
+       option 'splash_network' '10.14.128.0/17'
+       option 'splash_prefix' '27'
+       option 'latitude' '46.05063'
+       option 'longitude' '14.50402'
+
+config 'defaults' 'wifi_device'
+       option 'channel' '8'
+
+config 'defaults' 'interface'
+       option 'dns' '10.14.0.1 208.67.222.220 208.67.220.222'
+       option 'netmask' '255.255.0.0'
diff --git a/modules/freifunk/root/etc/config/profile_l59 b/modules/freifunk/root/etc/config/profile_l59
new file mode 100644 (file)
index 0000000..67c48cc
--- /dev/null
@@ -0,0 +1,9 @@
+config 'community' 'profile'
+       option 'name' 'Freifunk L59'
+       option 'homepage' 'http://freifunk.net'
+       option 'ssid' 'start.freifunk.net'
+       option 'mesh_network' '104.59.0.0/16'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '27'
+       option 'latitude' '52.26337'
+       option 'longitude' '10.52103'
diff --git a/modules/freifunk/root/etc/config/profile_leipzig b/modules/freifunk/root/etc/config/profile_leipzig
new file mode 100644 (file)
index 0000000..1418f7a
--- /dev/null
@@ -0,0 +1,12 @@
+config 'community' 'profile'
+       option 'name' 'Freifunk Leipzig'
+       option 'homepage' 'http://leipzig.freifunk.net'
+       option 'ssid' 'leipzig.freifunk.net'
+       option 'mesh_network' '104.61.0.0/16'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '27'
+       option 'latitude' '51.33348'
+       option 'longitude' '12.40297'
+
+
+
diff --git a/modules/freifunk/root/etc/config/profile_mainz b/modules/freifunk/root/etc/config/profile_mainz
new file mode 100644 (file)
index 0000000..c6cd61d
--- /dev/null
@@ -0,0 +1,19 @@
+config 'community' 'profile'
+       option 'name' 'Freifunk Mainz'
+       option 'homepage' 'http://mainz.freifunk.net'
+       option 'ssid' 'mainz.freifunk.net'
+       option 'mesh_network' '10.37.0.0/16'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '27'
+       option 'latitude' '49.99635'
+       option 'longitude' '8.27417'
+
+config 'defaults' 'wifi_iface'
+       option 'bssid' '02:ca:ff:ee:ba:be'
+
+config 'defaults' 'wifi_device'
+       option 'channel' '1'
+
+config 'defaults' 'interface'
+       option 'netmask' '255.255.0.0'
+
diff --git a/modules/freifunk/root/etc/config/profile_marburg b/modules/freifunk/root/etc/config/profile_marburg
new file mode 100644 (file)
index 0000000..21ad644
--- /dev/null
@@ -0,0 +1,13 @@
+config 'community' 'profile'
+       option 'name' 'Freifunk Marburg'
+       option 'homepage' ' http://marburg.freifunk.de'
+       option 'ssid' 'marburg.freifunk.net'
+       option 'mesh_network' '10.128.0.0/16'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '29'
+       option 'latitude' '49.63939'
+       option 'longitude' '8.633718'
+
+config 'defaults' 'interface'
+       option 'dns' '8.8.8.8 212.204.49.83'
+        option 'netmask' '255.255.0.0'
diff --git a/modules/freifunk/root/etc/config/profile_neuss b/modules/freifunk/root/etc/config/profile_neuss
new file mode 100644 (file)
index 0000000..5f97d87
--- /dev/null
@@ -0,0 +1,18 @@
+config 'community' 'profile'
+       option 'name' 'Freifunk Neuss'
+       option 'homepage' 'http://neuss.freifunk.net'
+       option 'ssid' 'neuss.freifunk.net'
+       option 'mesh_network' '172.28.0.0/16'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '27'
+       option 'latitude' '51.19045'
+       option 'longitude' '6.69471'
+
+config 'defaults' 'wifi_device'
+       option 'channel' '11'
+
+config 'defaults' 'interface'
+       option 'netmask' '255.255.0.0'
+
+config 'defaults' 'wifi_iface'
+       option 'bssid' 'DE:AD:BE:EF:CA:FE'
diff --git a/modules/freifunk/root/etc/config/profile_oldenburg b/modules/freifunk/root/etc/config/profile_oldenburg
new file mode 100644 (file)
index 0000000..e967fdb
--- /dev/null
@@ -0,0 +1,15 @@
+config 'community' 'profile'
+       option 'name' 'Freifunk Oldenburg'
+       option 'homepage' 'http://oldenburg.freifunk.net'
+       option 'ssid' 'oldenburg.freifunk.net'
+       option 'mesh_network' '10.18.0.0/16'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '27'
+       option 'latitude' '53.14083'
+       option 'longitude' '8.21314'
+
+config 'defaults' 'wifi_device'
+       option 'channel' '6'
+
+config 'defaults' 'wifi_iface'
+       option 'bssid' '02:CA:FF:EE:BA:BE'
diff --git a/modules/freifunk/root/etc/config/profile_openwireless_bern b/modules/freifunk/root/etc/config/profile_openwireless_bern
new file mode 100644 (file)
index 0000000..b9f5cbd
--- /dev/null
@@ -0,0 +1,19 @@
+config 'community' 'profile'
+       option 'name' 'Openwireless Bern'
+       option 'homepage' 'http://bern.openwireless.ch/'
+       option 'ssid' 'www.openwireless.ch'
+       option 'mesh_network' '10.247.0.0/16'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '27'
+       option 'latitude' '50.814788'
+       option 'longitude' '8.769239'
+
+config 'defaults' 'interface'
+       option 'netmask' '255.255.0.0'
+       option 'dns' '208.67.222.222 208.67.220.220'
+
+config 'defaults' 'wifi_device'
+       option 'channel' '10'
+       option 'country' '756'
+
+
diff --git a/modules/freifunk/root/etc/config/profile_pberg b/modules/freifunk/root/etc/config/profile_pberg
new file mode 100644 (file)
index 0000000..ea2f7b0
--- /dev/null
@@ -0,0 +1,12 @@
+config 'community' 'profile'
+       option 'name' 'Freifunk Berlin Prenzlauer Berg'
+       option 'homepage' 'http://pberg.freifunk.net'
+       option 'ssid' 'olsr.freifunk.net'
+       option 'mesh_network' '104.0.0.0/8'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '27'
+       option 'latitude' '52.5427'
+       option 'longitude' '13.4172'
+
+config 'defaults' 'wifi_device'
+       option 'channel' '10'
diff --git a/modules/freifunk/root/etc/config/profile_piraten_dresden b/modules/freifunk/root/etc/config/profile_piraten_dresden
new file mode 100644 (file)
index 0000000..2af0e31
--- /dev/null
@@ -0,0 +1,12 @@
+config 'community' 'profile'
+       option 'name' 'Piratenfreifunk Dresden'
+       option 'homepage' 'http://www.piraten-sachsen.de/'
+       option 'ssid' 'dresden.freifunk.net'
+       option 'mesh_network' '10.12.0.0/16'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '27'
+       option 'latitude' '51.05081'
+       option 'longitude' '13.73420'
+
+config 'defaults' 'wifi_device'
+       option 'channel' '1'
diff --git a/modules/freifunk/root/etc/config/profile_potsdam b/modules/freifunk/root/etc/config/profile_potsdam
new file mode 100644 (file)
index 0000000..ff1d661
--- /dev/null
@@ -0,0 +1,15 @@
+config 'community' 'profile'
+       option 'name' 'Freifunk Potsdam'
+       option 'homepage' 'http://potsdam.freifunk.net'
+       option 'ssid' 'www.freifunk-potsdam.de'
+       option 'mesh_network' '10.22.0.0/16'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '27'
+       option 'latitude' '52.39349'
+       option 'longitude' '13.06489'
+
+config 'defaults' 'interface'
+       option 'netmask' '255.255.0.0'
+
+config 'defaults' 'wifi_device'
+       option 'channel' '13'
diff --git a/modules/freifunk/root/etc/config/profile_rosbach b/modules/freifunk/root/etc/config/profile_rosbach
new file mode 100644 (file)
index 0000000..ec07281
--- /dev/null
@@ -0,0 +1,18 @@
+config 'community' 'profile'
+       option 'name' 'Freifunk Rosbach'
+       option 'homepage' 'freifunk-rosbach.de'
+       option 'ssid' 'rosbach.freifunk.net'
+       option 'mesh_network' '10.212.0.0/16'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '27'
+       option 'latitude' '50.18'
+       option 'longitude' '8.42'
+
+config 'defaults' 'wifi_device'
+       option 'channel' '13'
+
+config 'defaults' 'wifi_iface'
+       option 'bssid' 'D2:CA:FF:EE:BA:BE'
+
+config 'defaults' 'interface'
+        option 'netmask' '255.255.0.0'
diff --git a/modules/freifunk/root/etc/config/profile_seefeld b/modules/freifunk/root/etc/config/profile_seefeld
new file mode 100644 (file)
index 0000000..f88562d
--- /dev/null
@@ -0,0 +1,16 @@
+config 'community' 'profile'
+       option 'name' 'Freifunk Seefeld'
+       option 'homepage' 'http://wiki.freifunk.net/Seefeld.freifunk.net'
+       option 'ssid' 'seefeld.freifunk.net'
+       option 'mesh_network' '10.111.0.0/16'
+       option 'splash_network' '10.104.0.0/16'
+       option 'splash_prefix' '27'
+       option 'latitude' '48.03485'
+       option 'longitude' '11.21279'
+
+config 'defaults' 'interface'
+       option 'netmask' '255.255.255.0'
+
+config 'defaults' 'wifi_device'
+       option 'channel' '1'
+       option 'bssid' '02:CA:FF:EE:BA:BB'
diff --git a/modules/freifunk/root/etc/config/profile_wlanljubljana b/modules/freifunk/root/etc/config/profile_wlanljubljana
new file mode 100644 (file)
index 0000000..9d76eeb
--- /dev/null
@@ -0,0 +1,16 @@
+config 'community' 'profile'
+       option 'name' 'wlan ljubljana'
+       option 'homepage' 'http://wlan-lj.net'
+       option 'ssid' 'open.wlan-lj.net'
+       option 'mesh_network' '10.254.0.0/16'
+       option 'splash_network' '10.254.120.0/21'
+       option 'splash_prefix' '27'
+       option 'latitude' '46.05063'
+       option 'longitude' '14.50402'
+
+config 'defaults' 'wifi_device'
+       option 'channel' '8'
+
+config 'defaults' 'interface'
+       option 'dns' '10.254.0.1 10.254.0.2'
+       option 'netmask' '255.255.0.0'
index 035ca16..496cbad 100644 (file)
@@ -22,19 +22,16 @@ local cattree  = category and luci.dispatcher.node(category)
 local node     = luci.dispatcher.context.dispatched
 local hostname = luci.sys.hostname()
 
-local c = luci.model.uci.cursor():get_all("freifunk", "community")
 
-if c and c.name then
-       community = c.name
-else
-       community = "Freifunk"
+local uci = require "luci.model.uci".cursor()
+local ff = uci:get("freifunk", "community", "name")
+if not ff then
+        ff = ""
 end
+local co = "profile_" .. ff
+local community = uci:get_first(co, "community", "name") or "Freifunk"
+local hp = uci:get_first(co, "community", "homepage") or "http://www.freifunk.net"
 
-if c and c.homepage then
-       homepage = c.homepage
-else
-       homepage = "http://freifunk.net"
-end
 
 local c = tree
 for i,r in ipairs(request) do
@@ -88,8 +85,8 @@ require("luci.http").prepare_content("application/xhtml+xml")
 
 <div id="header">
        <span id="header_left">
-               <a href="<%=homepage%>"><img src="/luci-static/freifunk-generic/logo.jpg" alt="FF Logo" /></a>
-               <a href="<%=homepage%>"><%=community%></a>
+               <a href="<%=hp%>"><img src="/luci-static/freifunk-generic/logo.jpg" alt="FF Logo" /></a>
+               <a href="<%=hp%>"><%=community%></a>
        </span>
        <p>
                <%=luci.version.distversion%><br />