Bladeren bron

gluon-config-mode: modularize wizard

This commit splits gluon-config-mode into several, mostly independent
packages.

* gluon-config-mode-core: basic functionality (required)
* gluon-config-mode-hostname: hostname field
* gluon-config-mode-autoupdater: show when autoupdater is enabled
* gluon-config-mode-mesh-vpn: fastd vpn configuration, bw limit
* gluon-config-mode-geo-location: geo coordinates
* gluon-config-mode-contact-info: contact info field

The package gluon-config-mode has been removed. You need to replace
it with these packages (or any subset of them) in site.mk:

* gluon-config-mode-hostname
* gluon-config-mode-autoupdater
* gluon-config-mode-mesh-vpn
* gluon-config-mode-geo-location
* gluon-config-mode-contact-info

Note: It is not possible to deactivate the autoupdater in config mode
anymore (expert mode will still allow it). Instead, a message is shown
in case the autoupdater is enabled.
Nils Schneider 9 jaren geleden
bovenliggende
commit
3aecc92073
22 gewijzigde bestanden met toevoegingen van 462 en 197 verwijderingen
  1. 35 0
      package/gluon-config-mode-autoupdater/Makefile
  2. 19 0
      package/gluon-config-mode-autoupdater/files/lib/gluon/config-mode/wizard/0050-autoupdater-info.lua
  3. 31 0
      package/gluon-config-mode-contact-info/Makefile
  4. 31 0
      package/gluon-config-mode-contact-info/files/lib/gluon/config-mode/wizard/0500-contact-info.lua
  5. 7 11
      package/gluon-config-mode-core/Makefile
  6. 0 1
      package/gluon-config-mode-core/check_site.lua
  7. 3 0
      package/gluon-config-mode-core/files/lib/gluon/config-mode/reboot/0900-msg-reboot.lua
  8. 23 17
      package/gluon-config-mode-core/files/usr/lib/lua/luci/controller/gluon-config-mode/index.lua
  9. 38 0
      package/gluon-config-mode-core/files/usr/lib/lua/luci/model/cbi/gluon-config-mode/wizard.lua
  10. 0 0
      package/gluon-config-mode-core/files/usr/lib/lua/luci/view/gluon-config-mode/cbi/wizard.htm
  11. 17 0
      package/gluon-config-mode-core/files/usr/lib/lua/luci/view/gluon-config-mode/reboot.htm
  12. 31 0
      package/gluon-config-mode-geo-location/Makefile
  13. 45 0
      package/gluon-config-mode-geo-location/files/lib/gluon/config-mode/wizard/0400-geo-location.lua
  14. 31 0
      package/gluon-config-mode-hostname/Makefile
  15. 20 0
      package/gluon-config-mode-hostname/files/lib/gluon/config-mode/wizard/0100-hostname.lua
  16. 36 0
      package/gluon-config-mode-mesh-vpn/Makefile
  17. 1 0
      package/gluon-config-mode-mesh-vpn/check_site.lua
  18. 30 0
      package/gluon-config-mode-mesh-vpn/files/lib/gluon/config-mode/reboot/0100-mesh-vpn.lua
  19. 63 0
      package/gluon-config-mode-mesh-vpn/files/lib/gluon/config-mode/wizard/0300-mesh-vpn.lua
  20. 0 136
      package/gluon-config-mode/files/usr/lib/lua/luci/model/cbi/gluon-config-mode/wizard.lua
  21. 0 31
      package/gluon-config-mode/files/usr/lib/lua/luci/view/gluon-config-mode/reboot.htm
  22. 1 1
      package/gluon-luci-admin/Makefile

+ 35 - 0
package/gluon-config-mode-autoupdater/Makefile

@@ -0,0 +1,35 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gluon-config-mode-autoupdater
+PKG_VERSION:=1
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(GLUONDIR)/include/package.mk
+
+define Package/gluon-config-mode-autoupdater
+  SECTION:=gluon
+  CATEGORY:=Gluon
+  TITLE:=Let the user know whether the autoupdater is enabled or not.
+  DEPENDS:=+gluon-config-mode-core +gluon-autoupdater
+endef
+
+define Package/gluon-config-mode-autoupdater/description
+	Luci based config mode
+endef
+
+define Build/Prepare
+	mkdir -p $(PKG_BUILD_DIR)
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+define Package/gluon-config-mode-autoupdater/install
+	$(CP) ./files/* $(1)/
+endef
+
+$(eval $(call BuildPackage,gluon-config-mode-autoupdater))

+ 19 - 0
package/gluon-config-mode-autoupdater/files/lib/gluon/config-mode/wizard/0050-autoupdater-info.lua

@@ -0,0 +1,19 @@
+local cbi = require "luci.cbi"
+local uci = luci.model.uci.cursor()
+
+local M = {}
+
+function M.section(form)
+  local enabled = uci:get_bool("autoupdater", "settings", "enabled")
+  if enabled then
+    local s = form:section(cbi.SimpleSection, nil,
+      [[Dieser Knoten aktualisiert seine Firmware automatisch, sobald
+      eine neue Version vorliegt.]])
+  end
+end
+
+function M.handle(data)
+  return
+end
+
+return M

+ 31 - 0
package/gluon-config-mode-contact-info/Makefile

@@ -0,0 +1,31 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gluon-config-mode-contact-info
+PKG_VERSION:=1
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(GLUONDIR)/include/package.mk
+
+define Package/gluon-config-mode-contact-info
+  SECTION:=gluon
+  CATEGORY:=Gluon
+  TITLE:=Set a custom string that will be distributed in the mesh.
+  DEPENDS:=+gluon-config-mode-core +gluon-node-info
+endef
+
+define Build/Prepare
+	mkdir -p $(PKG_BUILD_DIR)
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+define Package/gluon-config-mode-contact-info/install
+	$(CP) ./files/* $(1)/
+endef
+
+$(eval $(call BuildPackage,gluon-config-mode-contact-info))

+ 31 - 0
package/gluon-config-mode-contact-info/files/lib/gluon/config-mode/wizard/0500-contact-info.lua

@@ -0,0 +1,31 @@
+local cbi = require "luci.cbi"
+local uci = luci.model.uci.cursor()
+
+local M = {}
+
+function M.section(form)
+  local s = form:section(cbi.SimpleSection, nil,
+    [[Hier kannst du einen <em>öffentlichen</em> Hinweis hinterlegen um
+    anderen Freifunkern zu ermöglichen Kontakt mit dir aufzunehmen. Bitte
+    beachte, dass dieser Hinweis auch öffentlich im Internet, zusammen mit
+    den Koordinaten deines Knotens, einsehbar sein wird.]])
+
+  local o = s:option(cbi.Value, "_contact", "Kontakt")
+  o.default = uci:get_first("gluon-node-info", "owner", "contact", "")
+  o.rmempty = true
+  o.datatype = "string"
+  o.description = "z.B. E-Mail oder Telefonnummer"
+  o.maxlen = 140
+end
+
+function M.handle(data)
+  if data._contact ~= nil then
+    uci:set("gluon-node-info", uci:get_first("gluon-node-info", "owner"), "contact", data._contact)
+  else
+    uci:delete("gluon-node-info", uci:get_first("gluon-node-info", "owner"), "contact")
+  end
+  uci:save("gluon-node-info")
+  uci:commit("gluon-node-info")
+end
+
+return M

+ 7 - 11
package/gluon-config-mode/Makefile → package/gluon-config-mode-core/Makefile

@@ -3,22 +3,18 @@
 
 include $(TOPDIR)/rules.mk
 
-PKG_NAME:=gluon-config-mode
-PKG_VERSION:=4
+PKG_NAME:=gluon-config-mode-core
+PKG_VERSION:=2
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
 
 include $(GLUONDIR)/include/package.mk
 
-define Package/gluon-config-mode
+define Package/gluon-config-mode-core
   SECTION:=gluon
   CATEGORY:=Gluon
   TITLE:=Luci based config mode for user friendly setup of new mesh nodes
-  DEPENDS:=+gluon-luci-core +gluon-setup-mode +gluon-lock-password +gluon-node-info +gluon-simple-tc
-endef
-
-define Package/gluon-config-mode/description
-	Luci based config mode
+  DEPENDS:=+gluon-luci-core +gluon-setup-mode +gluon-lock-password
 endef
 
 define Build/Prepare
@@ -31,13 +27,13 @@ endef
 define Build/Compile
 endef
 
-define Package/gluon-config-mode/install
+define Package/gluon-config-mode-core/install
 	$(CP) ./files/* $(1)/
 endef
 
-define Package/gluon-config-mode/postinst
+define Package/gluon-config-mode-core/postinst
 #!/bin/sh
 $(call GluonCheckSite,check_site.lua)
 endef
 
-$(eval $(call BuildPackage,gluon-config-mode))
+$(eval $(call BuildPackage,gluon-config-mode-core))

+ 0 - 1
package/gluon-config-mode/check_site.lua → package/gluon-config-mode-core/check_site.lua

@@ -1,3 +1,2 @@
 need_string 'config_mode.msg_welcome'
-need_string 'config_mode.msg_pubkey'
 need_string 'config_mode.msg_reboot'

+ 3 - 0
package/gluon-config-mode-core/files/lib/gluon/config-mode/reboot/0900-msg-reboot.lua

@@ -0,0 +1,3 @@
+local site = require 'gluon.site_config'
+
+return function () luci.template.render_string(site.config_mode.msg_reboot) end

+ 23 - 17
package/gluon-config-mode/files/usr/lib/lua/luci/controller/gluon-config-mode/index.lua → package/gluon-config-mode-core/files/usr/lib/lua/luci/controller/gluon-config-mode/index.lua

@@ -12,12 +12,6 @@ $Id$
 
 module("luci.controller.gluon-config-mode.index", package.seeall)
 
-local site = require 'gluon.site_config'
-
-
-local meshvpn_name = "mesh_vpn"
-
-
 function index()
   local uci_state = luci.model.uci.cursor_state()
 
@@ -48,24 +42,36 @@ function index()
 end
 
 function action_reboot()
-  local util = require "luci.util"
-  local pubkey
   local uci = luci.model.uci.cursor()
-  local meshvpn_enabled = uci:get("fastd", meshvpn_name, "enabled", "0")
-  local sysconfig = require 'gluon.sysconfig'
-  if meshvpn_enabled == "1" then
-    pubkey = util.exec("/etc/init.d/fastd show_key " .. meshvpn_name)
-  end
 
   uci:set("gluon-setup-mode", uci:get_first("gluon-setup-mode", "setup_mode"), "configured", "1")
   uci:save("gluon-setup-mode")
   uci:commit("gluon-setup-mode")
 
-  local hostname = uci:get_first("system", "system", "hostname")
-
   if nixio.fork() ~= 0 then
-    luci.template.render("gluon-config-mode/reboot",
-      {luci=luci, pubkey=pubkey, hostname=hostname, site=site, sysconfig=sysconfig})
+    local fs = require "luci.fs"
+
+    local parts_dir = "/lib/gluon/config-mode/reboot/"
+    local files = fs.dir(parts_dir)
+
+    table.sort(files)
+
+    local parts = {}
+
+    for _, entry in ipairs(files) do
+      if entry:sub(1, 1) ~= '.' then
+        local f = dofile(parts_dir .. '/' .. entry)
+        if f ~= nil then
+          table.insert(parts, f)
+        end
+      end
+    end
+
+    local hostname = uci:get_first("system", "system", "hostname")
+
+    luci.template.render("gluon-config-mode/reboot", { parts=parts
+                                                     , hostname=hostname
+                                                     })
   else
     debug.setfenv(io.stdout, debug.getfenv(io.open '/dev/null'))
     io.stdout:close()

+ 38 - 0
package/gluon-config-mode-core/files/usr/lib/lua/luci/model/cbi/gluon-config-mode/wizard.lua

@@ -0,0 +1,38 @@
+local wizard_dir = "/lib/gluon/config-mode/wizard/"
+local uci = luci.model.uci.cursor()
+local fs = require "luci.fs"
+local f, s
+
+local wizard = {}
+local files = fs.dir(wizard_dir)
+
+table.sort(files)
+
+for _, entry in ipairs(files) do
+  if entry:sub(1, 1) ~= '.' then
+    table.insert(wizard, dofile(wizard_dir .. '/' .. entry))
+  end
+end
+
+f = SimpleForm("wizard")
+f.reset = false
+f.template = "gluon-config-mode/cbi/wizard"
+f.submit = "Speichern &amp; Neustarten"
+
+for _, s in ipairs(wizard) do
+  s.section(f)
+end
+
+function f.handle(self, state, data)
+  if state == FORM_VALID then
+    for _, s in ipairs(wizard) do
+      s.handle(data)
+    end
+
+    luci.http.redirect(luci.dispatcher.build_url("gluon-config-mode", "reboot"))
+  end
+
+  return true
+end
+
+return f

+ 0 - 0
package/gluon-config-mode/files/usr/lib/lua/luci/view/gluon-config-mode/cbi/wizard.htm → package/gluon-config-mode-core/files/usr/lib/lua/luci/view/gluon-config-mode/cbi/wizard.htm


+ 17 - 0
package/gluon-config-mode-core/files/usr/lib/lua/luci/view/gluon-config-mode/reboot.htm

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%=luci.i18n.context.lang%>" lang="<%=luci.i18n.context.lang%>">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <title><%=hostname%> is rebooting</title>
+    <link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/cascade.css" />
+  </head>
+  <body>
+    <div id="maincontainer">
+      <div id="maincontent">
+        <h2>Dein Freifunkknoten ist nun fertig eingerichtet.</h2>
+        <% for k, v in ipairs(parts) do v() end %>
+      </div>
+    </div>
+  </body>
+</html>

+ 31 - 0
package/gluon-config-mode-geo-location/Makefile

@@ -0,0 +1,31 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gluon-config-mode-geo-location
+PKG_VERSION:=1
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(GLUONDIR)/include/package.mk
+
+define Package/gluon-config-mode-geo-location
+  SECTION:=gluon
+  CATEGORY:=Gluon
+  TITLE:=Set geographic location of a node
+  DEPENDS:=+gluon-config-mode-core +gluon-node-info
+endef
+
+define Build/Prepare
+	mkdir -p $(PKG_BUILD_DIR)
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+define Package/gluon-config-mode-geo-location/install
+	$(CP) ./files/* $(1)/
+endef
+
+$(eval $(call BuildPackage,gluon-config-mode-geo-location))

+ 45 - 0
package/gluon-config-mode-geo-location/files/lib/gluon/config-mode/wizard/0400-geo-location.lua

@@ -0,0 +1,45 @@
+local cbi = require "luci.cbi"
+local uci = luci.model.uci.cursor()
+
+local M = {}
+
+function M.section(form)
+  local s = form:section(cbi.SimpleSection, nil,
+    [[Um deinen Knoten auf der Karte anzeigen zu können, benötigen
+    wir seine Koordinaten. Hier hast du die Möglichkeit, diese zu
+    hinterlegen.]])
+
+  local o
+
+  o = s:option(cbi.Flag, "_location", "Knoten auf der Karte anzeigen")
+  o.default = uci:get_first("gluon-node-info", "location", "share_location", o.disabled)
+  o.rmempty = false
+
+  o = s:option(cbi.Value, "_latitude", "Breitengrad")
+  o.default = uci:get_first("gluon-node-info", "location", "latitude")
+  o:depends("_location", "1")
+  o.rmempty = false
+  o.datatype = "float"
+  o.description = "z.B. 53.873621"
+
+  o = s:option(cbi.Value, "_longitude", "Längengrad")
+  o.default = uci:get_first("gluon-node-info", "location", "longitude")
+  o:depends("_location", "1")
+  o.rmempty = false
+  o.datatype = "float"
+  o.description = "z.B. 10.689901"
+end
+
+function M.handle(data)
+  local sname = uci:get_first("gluon-node-info", "location")
+
+  uci:set("gluon-node-info", sname, "share_location", data._location)
+  if data._location and data._latitude ~= nil and data._longitude ~= nil then
+    uci:set("gluon-node-info", sname, "latitude", data._latitude)
+    uci:set("gluon-node-info", sname, "longitude", data._longitude)
+  end
+  uci:save("gluon-node-info")
+  uci:commit("gluon-node-info")
+end
+
+return M

+ 31 - 0
package/gluon-config-mode-hostname/Makefile

@@ -0,0 +1,31 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gluon-config-mode-hostname
+PKG_VERSION:=1
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(GLUONDIR)/include/package.mk
+
+define Package/gluon-config-mode-hostname
+  SECTION:=gluon
+  CATEGORY:=Gluon
+  TITLE:=Set the hostname
+  DEPENDS:=+gluon-config-mode-core
+endef
+
+define Build/Prepare
+	mkdir -p $(PKG_BUILD_DIR)
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+define Package/gluon-config-mode-hostname/install
+	$(CP) ./files/* $(1)/
+endef
+
+$(eval $(call BuildPackage,gluon-config-mode-hostname))

+ 20 - 0
package/gluon-config-mode-hostname/files/lib/gluon/config-mode/wizard/0100-hostname.lua

@@ -0,0 +1,20 @@
+local cbi = require "luci.cbi"
+local uci = luci.model.uci.cursor()
+
+local M = {}
+
+function M.section(form)
+  local s = form:section(cbi.SimpleSection, nil, nil)
+  local o = s:option(cbi.Value, "_hostname", "Name dieses Knotens")
+  o.value = uci:get_first("system", "system", "hostname")
+  o.rmempty = false
+  o.datatype = "hostname"
+end
+
+function M.handle(data)
+  uci:set("system", uci:get_first("system", "system"), "hostname", data._hostname)
+  uci:save("system")
+  uci:commit("system")
+end
+
+return M

+ 36 - 0
package/gluon-config-mode-mesh-vpn/Makefile

@@ -0,0 +1,36 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gluon-config-mode-mesh-vpn
+PKG_VERSION:=2
+
+PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
+
+include $(GLUONDIR)/include/package.mk
+
+define Package/gluon-config-mode-mesh-vpn
+  SECTION:=gluon
+  CATEGORY:=Gluon
+  TITLE:=Toggle mesh-vpn and bandwidth limit
+  DEPENDS:=+gluon-config-mode-core +gluon-mesh-vpn-fastd +gluon-simple-tc
+endef
+
+define Build/Prepare
+	mkdir -p $(PKG_BUILD_DIR)
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+define Package/gluon-config-mode-mesh-vpn/install
+	$(CP) ./files/* $(1)/
+endef
+
+define Package/gluon-config-mode-mesh-vpn/postinst
+#!/bin/sh
+$(call GluonCheckSite,check_site.lua)
+endef
+
+$(eval $(call BuildPackage,gluon-config-mode-mesh-vpn))

+ 1 - 0
package/gluon-config-mode-mesh-vpn/check_site.lua

@@ -0,0 +1 @@
+need_string 'config_mode.msg_pubkey'

+ 30 - 0
package/gluon-config-mode-mesh-vpn/files/lib/gluon/config-mode/reboot/0100-mesh-vpn.lua

@@ -0,0 +1,30 @@
+local msg = [[<p>
+               <%= luci.template.render_string(site.config_mode.msg_pubkey) %>
+             </p>
+             <div class="the-key">
+               # <%= hostname %>
+               <br/>
+               <%= pubkey %>
+             </div>]]
+
+local uci = luci.model.uci.cursor()
+local meshvpn_enabled = uci:get("fastd", "mesh_vpn", "enabled", "0")
+
+if meshvpn_enabled ~= "1" then
+  return nil
+else
+  local util = require "luci.util"
+  local site = require 'gluon.site_config'
+  local sysconfig = require 'gluon.sysconfig'
+
+  local pubkey = util.exec("/etc/init.d/fastd show_key " .. "mesh_vpn")
+  local hostname = uci:get_first("system", "system", "hostname")
+
+  return function ()
+           luci.template.render_string(msg, { pubkey=pubkey
+                                            , hostname=hostname
+                                            , site=site
+                                            , sysconfig=sysconfig
+                                            })
+         end
+end

+ 63 - 0
package/gluon-config-mode-mesh-vpn/files/lib/gluon/config-mode/wizard/0300-mesh-vpn.lua

@@ -0,0 +1,63 @@
+local cbi = require "luci.cbi"
+local uci = luci.model.uci.cursor()
+
+local M = {}
+
+function M.section(form)
+  local s = form:section(cbi.SimpleSection, nil,
+    [[Falls du deinen Knoten über das Internet mit Freifunk verbinden
+    möchtest, kannst du hier das Mesh-VPN aktivieren.  Solltest du dich
+    dafür entscheiden, hast du die Möglichkeit die dafür genutzte
+    Bandbreite zu beschränken. Lässt du das Mesh-VPN deaktiviert,
+    verbindet sich dein Knoten nur per WLAN mit anderen Knoten in der
+    Nähe.]])
+
+  local o
+
+  o = s:option(cbi.Flag, "_meshvpn", "Mesh-VPN aktivieren")
+  o.default = uci:get_bool("fastd", "mesh_vpn", "enabled") and o.enabled or o.disabled
+  o.rmempty = false
+
+  o = s:option(cbi.Flag, "_limit_enabled", "Mesh-VPN Bandbreite begrenzen")
+  o:depends("_meshvpn", "1")
+  o.default = uci:get_bool("gluon-simple-tc", "mesh_vpn", "enabled") and o.enabled or o.disabled
+  o.rmempty = false
+
+  o = s:option(cbi.Value, "_limit_ingress", "Downstream (kbit/s)")
+  o:depends("_limit_enabled", "1")
+  o.value = uci:get("gluon-simple-tc", "mesh_vpn", "limit_ingress")
+  o.rmempty = false
+  o.datatype = "integer"
+
+  o = s:option(cbi.Value, "_limit_egress", "Upstream (kbit/s)")
+  o:depends("_limit_enabled", "1")
+  o.value = uci:get("gluon-simple-tc", "mesh_vpn", "limit_egress")
+  o.rmempty = false
+  o.datatype = "integer"
+end
+
+function M.handle(data)
+  uci:set("fastd", "mesh_vpn", "enabled", data._meshvpn)
+  uci:save("fastd")
+  uci:commit("fastd")
+
+  -- checks for nil needed due to o:depends(...)
+  if data._limit_enabled ~= nil then
+    uci:set("gluon-simple-tc", "mesh_vpn", "interface")
+    uci:set("gluon-simple-tc", "mesh_vpn", "enabled", data._limit_enabled)
+    uci:set("gluon-simple-tc", "mesh_vpn", "ifname", "mesh-vpn")
+
+    if data._limit_ingress ~= nil then
+      uci:set("gluon-simple-tc", "mesh_vpn", "limit_ingress", data._limit_ingress)
+    end
+
+    if data._limit_egress ~= nil then
+      uci:set("gluon-simple-tc", "mesh_vpn", "limit_egress", data._limit_egress)
+    end
+
+    uci:commit("gluon-simple-tc")
+    uci:commit("gluon-simple-tc")
+  end
+end
+
+return M

+ 0 - 136
package/gluon-config-mode/files/usr/lib/lua/luci/model/cbi/gluon-config-mode/wizard.lua

@@ -1,136 +0,0 @@
-local meshvpn_name = "mesh_vpn"
-local uci = luci.model.uci.cursor()
-local f, s, o
-
-f = SimpleForm("wizard")
-f.reset = false
-f.template = "gluon-config-mode/cbi/wizard"
-f.submit = "Speichern &amp; Neustarten"
-
-s = f:section(SimpleSection, nil, nil)
-
-o = s:option(Value, "_hostname", "Name dieses Knotens")
-o.value = uci:get_first("system", "system", "hostname")
-o.rmempty = false
-o.datatype = "hostname"
-
-o = s:option(Flag, "_autoupdate", "Firmware automatisch aktualisieren")
-o.default = uci:get_bool("autoupdater", "settings", "enabled") and o.enabled or o.disabled
-o.rmempty = false
-
-s = f:section(SimpleSection, nil, [[Falls du deinen Knoten über das Internet
-mit Freifunk verbinden möchtest, kannst du hier das Mesh-VPN aktivieren.
-Solltest du dich dafür entscheiden, hast du die Möglichkeit die dafür
-genutzte Bandbreite zu beschränken. Lässt du das Mesh-VPN deaktiviert,
-verbindet sich dein Knoten nur per WLAN mit anderen Knoten in der Nähe.]])
-
-o = s:option(Flag, "_meshvpn", "Mesh-VPN aktivieren")
-o.default = uci:get_bool("fastd", meshvpn_name, "enabled") and o.enabled or o.disabled
-o.rmempty = false
-
-o = s:option(Flag, "_limit_enabled", "Mesh-VPN Bandbreite begrenzen")
-o:depends("_meshvpn", "1")
-o.default = uci:get_bool("gluon-simple-tc", meshvpn_name, "enabled") and o.enabled or o.disabled
-o.rmempty = false
-
-o = s:option(Value, "_limit_ingress", "Downstream (kbit/s)")
-o:depends("_limit_enabled", "1")
-o.value = uci:get("gluon-simple-tc", meshvpn_name, "limit_ingress")
-o.rmempty = false
-o.datatype = "integer"
-
-o = s:option(Value, "_limit_egress", "Upstream (kbit/s)")
-o:depends("_limit_enabled", "1")
-o.value = uci:get("gluon-simple-tc", meshvpn_name, "limit_egress")
-o.rmempty = false
-o.datatype = "integer"
-
-s = f:section(SimpleSection, nil, [[Um deinen Knoten auf der Karte anzeigen
-zu können, benötigen wir seine Koordinaten. Hier hast du die Möglichkeit,
-diese zu hinterlegen.]])
-
-o = s:option(Flag, "_location", "Knoten auf der Karte anzeigen")
-o.default = uci:get_first("gluon-node-info", "location", "share_location", o.disabled)
-o.rmempty = false
-
-o = s:option(Value, "_latitude", "Breitengrad")
-o.default = uci:get_first("gluon-node-info", "location", "latitude")
-o:depends("_location", "1")
-o.rmempty = false
-o.datatype = "float"
-o.description = "z.B. 53.873621"
-
-o = s:option(Value, "_longitude", "Längengrad")
-o.default = uci:get_first("gluon-node-info", "location", "longitude")
-o:depends("_location", "1")
-o.rmempty = false
-o.datatype = "float"
-o.description = "z.B. 10.689901"
-
-s = f:section(SimpleSection, nil, [[Hier kannst du einen
-<em>öffentlichen</em> Hinweis hinterlegen um anderen Freifunkern zu
-ermöglichen Kontakt mit dir aufzunehmen. Bitte beachte, dass dieser Hinweis
-auch öffentlich im Internet, zusammen mit den Koordinaten deines Knotens,
-einsehbar sein wird.]])
-
-o = s:option(Value, "_contact", "Kontakt")
-o.default = uci:get_first("gluon-node-info", "owner", "contact", "")
-o.rmempty = true
-o.datatype = "string"
-o.description = "z.B. E-Mail oder Telefonnummer"
-o.maxlen = 140
-
-function f.handle(self, state, data)
-  if state == FORM_VALID then
-    local stat = false
-
-    uci:set("autoupdater", "settings", "enabled", data._autoupdate)
-    uci:save("autoupdater")
-    uci:commit("autoupdater")
-
-    -- checks for nil needed due to o:depends(...)
-    if data._limit_enabled ~= nil then
-      uci:set("gluon-simple-tc", meshvpn_name, "interface")
-      uci:set("gluon-simple-tc", meshvpn_name, "enabled", data._limit_enabled)
-      uci:set("gluon-simple-tc", meshvpn_name, "ifname", "mesh-vpn")
-
-      if data._limit_ingress ~= nil then
-        uci:set("gluon-simple-tc", meshvpn_name, "limit_ingress", data._limit_ingress)
-      end
-
-      if data._limit_egress ~= nil then
-        uci:set("gluon-simple-tc", meshvpn_name, "limit_egress", data._limit_egress)
-      end
-
-      uci:commit("gluon-simple-tc")
-    end
-
-    uci:set("fastd", meshvpn_name, "enabled", data._meshvpn)
-    uci:save("fastd")
-    uci:commit("fastd")
-
-    uci:set("system", uci:get_first("system", "system"), "hostname", data._hostname)
-    uci:save("system")
-    uci:commit("system")
-
-    local sname = uci:get_first("gluon-node-info", "location")
-    uci:set("gluon-node-info", sname, "share_location", data._location)
-    if data._location and data._latitude ~= nil and data._longitude ~= nil then
-      uci:set("gluon-node-info", sname, "latitude", data._latitude)
-      uci:set("gluon-node-info", sname, "longitude", data._longitude)
-    end
-    if data._contact ~= nil then
-      uci:set("gluon-node-info", uci:get_first("gluon-node-info", "owner"), "contact", data._contact)
-    else
-      uci:delete("gluon-node-info", uci:get_first("gluon-node-info", "owner"), "contact")
-    end
-    uci:save("gluon-node-info")
-    uci:commit("gluon-node-info")
-
-    luci.http.redirect(luci.dispatcher.build_url("gluon-config-mode", "reboot"))
-  end
-
-  return true
-end
-
-return f

+ 0 - 31
package/gluon-config-mode/files/usr/lib/lua/luci/view/gluon-config-mode/reboot.htm

@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%=luci.i18n.context.lang%>" lang="<%=luci.i18n.context.lang%>">
-  <head>
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-    <title><%=hostname%> - <% if title then %><%=title%><% else %><%:Rebooting...%><% end %></title>
-    <link rel="stylesheet" type="text/css" media="screen" href="<%=media%>/cascade.css" />
-  </head>
-  <body>
-    <div id="maincontainer">
-      <div id="maincontent">
-        <h2>Geschafft! Dein Freifunkknoten ist nun fertig eingerichtet.</h2>
-        <% if pubkey then %>
-        <fieldset class="cbi-section">
-          <p>
-            <%= luci.template.render_string(site.config_mode.msg_pubkey) %>
-          </p>
-          <div class="the-key">
-            # <%= hostname %>
-            <br/>
-            <%= pubkey %>
-          </div>
-        </fieldset>
-        <% end %>
-        <fieldset class="cbi-section">
-          <%= luci.template.render_string(site.config_mode.msg_reboot) %>
-        </fieldset>
-      </div>
-    </div>
-  </body>
-</html>

+ 1 - 1
package/gluon-luci-admin/Makefile

@@ -15,7 +15,7 @@ define Package/gluon-luci-admin
   SECTION:=gluon
   CATEGORY:=Gluon
   TITLE:=Luci based simple administration interface for mesh nodes
-  DEPENDS:=+gluon-luci-core +gluon-config-mode
+  DEPENDS:=+gluon-luci-core +gluon-config-mode-core
 endef
 
 define Package/gluon-luci-admin/description