diff options
author | Steven Barth <steven@midlink.org> | 2008-09-05 01:01:53 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-09-05 01:01:53 +0000 |
commit | 05f350547e275e23062892227e20d536709ef99a (patch) | |
tree | 96e3181270ab8d6041c4854e17a8662ec9535599 /applications/luci-ffwizard-leipzig/luasrc/controller | |
parent | 35a529a5c56df3dbcd105f691d164f4f85283611 (diff) |
FFWizard rewrite
Diffstat (limited to 'applications/luci-ffwizard-leipzig/luasrc/controller')
-rw-r--r-- | applications/luci-ffwizard-leipzig/luasrc/controller/ffwizard.lua | 21 | ||||
-rw-r--r-- | applications/luci-ffwizard-leipzig/luasrc/controller/luci_ffwizard_leipzig/wizard.lua | 229 |
2 files changed, 21 insertions, 229 deletions
diff --git a/applications/luci-ffwizard-leipzig/luasrc/controller/ffwizard.lua b/applications/luci-ffwizard-leipzig/luasrc/controller/ffwizard.lua new file mode 100644 index 0000000000..9e7c0decaf --- /dev/null +++ b/applications/luci-ffwizard-leipzig/luasrc/controller/ffwizard.lua @@ -0,0 +1,21 @@ +--[[ +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", "index", "ffwizard"}, form("ffwizard"), "Freifunkassistent", 50) +end
\ No newline at end of file diff --git a/applications/luci-ffwizard-leipzig/luasrc/controller/luci_ffwizard_leipzig/wizard.lua b/applications/luci-ffwizard-leipzig/luasrc/controller/luci_ffwizard_leipzig/wizard.lua deleted file mode 100644 index bd9503ba43..0000000000 --- a/applications/luci-ffwizard-leipzig/luasrc/controller/luci_ffwizard_leipzig/wizard.lua +++ /dev/null @@ -1,229 +0,0 @@ -module("luci.controller.luci_ffwizard_leipzig.wizard", package.seeall) - -function index() - entry({"admin", "index", "wizard"}, call("action_wizard"), "Freifunkassistent", 20).i18n="ffwizard-leipzig" -end - - -function action_wizard() - if luci.http.formvalue("ip") then - return configure_freifunk() - end - - local ifaces = {} - luci.model.uci.foreach("wireless", "wifi-device", - function(section) - table.insert(ifaces, section[".name"]) - end) - - luci.template.render("freifunk/wizard", {ifaces=ifaces}) -end - -function configure_freifunk() - local ip = luci.http.formvalue("ip") - local uci = luci.model.uci - local cfg = { - wireless = uci.load("wireless"), - luci_fw = uci.load("luci_fw"), - luci_splash = uci.load("luci_splash"), - olsr = uci.load("olsr") - } - - -- Configure FF-Interface - uci.delete("network", "ff") - uci.delete("network", "ffdhcp") - - uci.section("network", "interface", "ff", { - type = "bridge", - proto = "static", - ipaddr = ip, - netmask = uci.get("freifunk", "community", "mask"), - dns = uci.get("freifunk", "community", "dns") - }) - - -- Reset Routing - uci.delete_all("luci_fw", "routing", - function (section) - return (section.iface == "ff" or section.oface == "ff") - end) - - if cfg.luci_fw then - uci.section("luci_fw", "routing", nil, { - iface = "ff", - oface = "ff", - fwd = "1" - }) - end - - -- Routing from Internal - local iface = luci.http.formvalue("frominternal") - if iface and iface ~= "" then - uci.delete_all("luci_fw", "routing", - function (section) - return (section.iface == iface and section.oface == "ff") - end) - - if cfg.luci_fw then - uci.section("luci_fw", "routing", nil, { - iface = iface, - oface = "ff", - fwd = "1", - nat = "1" - }) - end - end - - -- Routing to External - local iface = luci.http.formvalue("toexternal") - if iface and iface ~= "" then - uci.delete_all("luci_fw", "routing", - function (section) - return (section.oface == iface and section.iface == "ff") - end) - - if cfg.luci_fw then - uci.section("luci_fw", "routing", nil, { - oface = iface, - iface = "ff", - fwd = "1", - nat = "1" - }) - end - end - - -- Configure DHCP - if luci.http.formvalue("dhcp") then - local dhcpnet = uci.get("freifunk", "community", "dhcp"):match("^([0-9]+)") - local dhcpip = ip:gsub("^[0-9]+", dhcpnet) - - uci.section("network", "interface", "ffdhcp", { - proto = "static", - ifname = "br-ff:dhcp", - ipaddr = dhcpip, - netmask = uci.get("freifunk", "community", "dhcpmask") - }) - - uci.delete_all("dhcp", "dhcp", - function (section) - return (section.interface == "ffdhcp") - end) - - local dhcpbeg = 48 + tonumber(ip:match("[0-9]+$")) * 4 - uci.section("dhcp", "dhcp", nil, { - interface = "ffdhcp", - start = dhcpbeg, - limit = ((dhcpbeg < 252) and 3 or 2), - leasetime = "30m" - }) - - - uci.delete_all("luci_splash", "iface", - function (section) - return (section.network == "ffdhcp") - end) - - if cfg.luci_splash then - uci.section("luci_splash", "iface", nil, { - network = "ffdhcp" - }) - end - - - uci.delete_all("luci_fw", "routing", - function (section) - return (section.iface == "ffdhcp" or section.oface == "ffdhcp") - end) - - if cfg.luci_fw then - uci.section("luci_fw", "routing", nil, { - iface = "ffdhcp", - oface = "ff", - nat = "1" - }) - - local iface = luci.http.formvalue("toexternal") - if iface and iface ~= "" then - uci.section("luci_fw", "routing", nil, { - iface = "ffdhcp", - oface = iface, - nat = "1" - }) - end - end - end - - -- Configure OLSR - if luci.http.formvalue("olsr") and cfg.olsr then - uci.delete_all("olsr", "Interface") - uci.delete_all("olsr", "LoadPlugin") - - if luci.http.formvalue("shareinet") then - uci.section("olsr", "LoadPlugin", "dyn_gw", { - Library = "olsrd_dyn_gw.so.0.4" - }) - end - - uci.section("olsr", "LoadPlugin", "nameservice", { - Library = "olsrd_nameservice.so.0.3", - name = ip:gsub("%.", "-"), - hosts_file = "/var/etc/hosts", - suffix = ".olsr", - latlon_infile = "/tmp/latlon.txt" - }) - - uci.section("olsr", "LoadPlugin", "txtinfo", { - Library = "olsrd_txtinfo.so.0.1", - Accept = "127.0.0.1" - }) - - uci.section("olsr", "Interface", nil, { - Interface = "ff", - HelloInterval = "6.0", - HelloValidityTime = "108.0", - TcInterval = "4.0", - TcValidityTime = "324.0", - MidInterval = "18.0", - MidValidityTime = "324.0", - HnaInterval = "18.0", - HnaValidityTime = "108.0" - }) - end - - -- Configure Wifi - if cfg.wireless then - uci.foreach("wireless", "wifi-device", - function (section) - local device = section[".name"] - - if luci.http.formvalue("wifi."..device) then - uci.delete_all("wireless", "wifi-iface", - function (section) - return (section.device == device) - end) - - uci.tset("wireless", device, { - disabled = "0", - mode = "11g", - txantenna = "1", - rxantenna = "1", - channel = uci.get("freifunk", "community", "channel") - }) - - uci.section("wireless", "wifi-iface", nil, { - device = device, - network = "ff", - mode = "adhoc", - ssid = uci.get("freifunk", "community", "essid"), - bssid = uci.get("freifunk", "community", "bssid"), - txpower = 13 - }) - end - end) - end - - -- Save UCI - uci.save() - - - luci.http.redirect(luci.dispatcher.build_url("admin", "uci", "changes")) -end
\ No newline at end of file |