diff --git a/gluon-config-mode-ffhh/Makefile b/gluon-config-mode-ffhh/Makefile deleted file mode 100644 index 93a547a..0000000 --- a/gluon-config-mode-ffhh/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (C) 2012 Nils Schneider -# This is free software, licensed under the Apache 2.0 license. - -include $(TOPDIR)/rules.mk - -PKG_NAME:=gluon-config-mode-ffhh -PKG_VERSION:=4 - -PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) - -include $(INCLUDE_DIR)/package.mk - -define Package/gluon-config-mode-ffhh - SECTION:=gluon - CATEGORY:=Gluon - TITLE:=Luci based config mode for user friendly setup of new meshnodes - DEPENDS:=+gluon-luci-core +gluon-setup-mode +gluon-lock-password +gluon-simple-tc - PROVIDES:=gluon-config-mode -endef - -define Package/gluon-config-mode-ffhh/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-ffhh/install - $(CP) ./files/* $(1)/ -endef - -define Package/gluon-config-mode-ffhh/postinst -#!/bin/sh -$(call GluonCheckSite,check_site.lua) -endef - -$(eval $(call BuildPackage,gluon-config-mode-ffhh)) diff --git a/gluon-config-mode-ffhh/check_site.lua b/gluon-config-mode-ffhh/check_site.lua deleted file mode 100644 index 436de62..0000000 --- a/gluon-config-mode-ffhh/check_site.lua +++ /dev/null @@ -1,4 +0,0 @@ -need_string 'config_mode.msg_welcome' -need_string 'config_mode.msg_pubkey' -need_string 'config_mode.msg_reboot' -need_string 'config_mode.msg_nopubkey' diff --git a/gluon-config-mode-ffhh/files/usr/lib/lua/luci/controller/gluon-config-mode/index.lua b/gluon-config-mode-ffhh/files/usr/lib/lua/luci/controller/gluon-config-mode/index.lua deleted file mode 100644 index def9d40..0000000 --- a/gluon-config-mode-ffhh/files/usr/lib/lua/luci/controller/gluon-config-mode/index.lua +++ /dev/null @@ -1,83 +0,0 @@ ---[[ -Copyright 2013 Nils Schneider - -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.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() - - if uci_state:get_first("gluon-setup-mode", "setup_mode", "running", "0") == "1" then - local root = node() - if not root.target then - root.target = alias("gluon-config-mode") - root.index = true - end - - page = node() - page.lock = true - page.target = alias("gluon-config-mode") - page.subindex = true - page.index = false - - page = node("gluon-config-mode") - page.title = _("Wizard") - page.target = alias("gluon-config-mode", "wizard") - page.order = 5 - page.setuser = "root" - page.setgroup = "root" - page.index = true - - entry({"gluon-config-mode", "wizard"}, form("gluon-config-mode/wizard")).index = true - entry({"gluon-config-mode", "reboot"}, call("action_reboot")) - end -end - -function action_reboot() - local configmode = require "luci.tools.gluon-config-mode" - 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 = configmode.get_fastd_pubkey(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}) - else - debug.setfenv(io.stdout, debug.getfenv(io.open '/dev/null')) - io.stdout:close() - - -- Sleep a little so the browser can fetch everything required to - -- display the reboot page, then reboot the device. - nixio.nanosleep(2) - - -- Run reboot with popen so it gets its own std filehandles. - io.popen("reboot") - - -- Prevent any further execution in this child. - os.exit() - end -end diff --git a/gluon-config-mode-ffhh/files/usr/lib/lua/luci/model/cbi/gluon-config-mode/wizard.lua b/gluon-config-mode-ffhh/files/usr/lib/lua/luci/model/cbi/gluon-config-mode/wizard.lua deleted file mode 100644 index 1b61e49..0000000 --- a/gluon-config-mode-ffhh/files/usr/lib/lua/luci/model/cbi/gluon-config-mode/wizard.lua +++ /dev/null @@ -1,92 +0,0 @@ -local configmode = require "luci.tools.gluon-config-mode" -local meshvpn_name = "mesh_vpn" -local uci = luci.model.uci.cursor() -local f, s, o - --- prepare fastd key as early as possible -configmode.setup_fastd_secret(meshvpn_name) - -f = SimpleForm("wizard") -f.reset = false -f.template = "gluon-config-mode/cbi/wizard" -f.submit = "Fertig" - -if uci:get_bool("autoupdater", "settings", "enabled") then - f:set(nil, "autoupdater_msg", [[Dieser Knoten aktualisiert seine Firmware automatisch, - sobald eine neue Version vorliegt. Falls du dies nicht möchtest, - kannst du die Funktion im Expertmode deaktivieren.]]) -else - f:set(nil, "autoupdater_msg", [[Dieser Knoten aktualisiert seine Firmware nicht automatisch. - Diese Funktion kannst du im Expertmode aktivieren.]]) -end - -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" - -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" - -function f.handle(self, state, data) - if state == FORM_VALID then - local stat = false - - -- 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") - - luci.http.redirect(luci.dispatcher.build_url("gluon-config-mode", "reboot")) - end - - return true -end - -return f diff --git a/gluon-config-mode-ffhh/files/usr/lib/lua/luci/tools/gluon-config-mode.lua b/gluon-config-mode-ffhh/files/usr/lib/lua/luci/tools/gluon-config-mode.lua deleted file mode 100644 index ba1748f..0000000 --- a/gluon-config-mode-ffhh/files/usr/lib/lua/luci/tools/gluon-config-mode.lua +++ /dev/null @@ -1,29 +0,0 @@ -local luci = require "luci" -local io = require "io" - -module "luci.tools.gluon-config-mode" - -function setup_fastd_secret(name) - local uci = luci.model.uci.cursor() - local secret = uci:get("fastd", name, "secret") - - if not secret or not secret:match("%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x") then - local f = io.popen("fastd --generate-key --machine-readable", "r") - local secret = f:read("*a") - f:close() - - uci:set("fastd", name, "secret", secret) - uci:save("fastd") - uci:commit("fastd") - end -end - -function get_fastd_pubkey(name) - local f = io.popen("/etc/init.d/fastd show_key " .. name, "r") - local key = f:read("*a") - f:close() - - return key -end - - diff --git a/gluon-config-mode-ffhh/files/usr/lib/lua/luci/view/gluon-config-mode/cbi/wizard.htm b/gluon-config-mode-ffhh/files/usr/lib/lua/luci/view/gluon-config-mode/cbi/wizard.htm deleted file mode 100644 index cc5ce36..0000000 --- a/gluon-config-mode-ffhh/files/usr/lib/lua/luci/view/gluon-config-mode/cbi/wizard.htm +++ /dev/null @@ -1,71 +0,0 @@ -<%- - local site = require 'gluon.site_config' - local sysconfig = require 'gluon.sysconfig' - local template = require 'luci.template' --%> - -

Willkommen!

-

- <%= template.render_string(site.config_mode.msg_welcome, {hostname=hostname, sysconfig=sysconfig}) %> -

-

-<%=self.data["autoupdater_msg"]%> -

- -<% if not self.embedded then %> -
-
- - -
-<% end %> -
- <% if self.title and #self.title > 0 then %>

<%=self.title%>

<% end %> - <% if self.description and #self.description > 0 then %>
<%=self.description%>
<% end %> - <% self:render_children() %> -
-
-<%- if self.message then %> -
<%=self.message%>
-<%- end %> -<%- if self.errmessage then %> -
<%=self.errmessage%>
-<%- end %> -<% if not self.embedded then %> -
-<%- - if type(self.hidden) == "table" then - for k, v in pairs(self.hidden) do --%> - -<%- - end - end -%> -<% if redirect then %> -
- -
-<% end %> -<%- if self.flow and self.flow.skip then %> - -<% end %> -<%- if self.submit ~= false then %> - -<% end %> -<%- if self.reset ~= false then %> - -<% end %> -<%- if self.cancel ~= false and self.on_cancel then %> - -<% end %> - -
-
-<% end %> diff --git a/gluon-config-mode-ffhh/files/usr/lib/lua/luci/view/gluon-config-mode/reboot.htm b/gluon-config-mode-ffhh/files/usr/lib/lua/luci/view/gluon-config-mode/reboot.htm deleted file mode 100644 index 7b2070f..0000000 --- a/gluon-config-mode-ffhh/files/usr/lib/lua/luci/view/gluon-config-mode/reboot.htm +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - <%=hostname%> - <% if title then %><%=title%><% else %><%:Rebooting...%><% end %> - - - -
-
-

Geschafft! Dein Freifunkknoten ist nun fertig eingerichtet.

- <% if pubkey then %> -
-

- <%= luci.template.render_string(site.config_mode.msg_pubkey) %> -

-
- # <%= hostname %> -
- <%= pubkey %> -
-
- <% else %> -

- <%= luci.template.render_string(site.config_mode.msg_nopubkey) %> -

- <% end %> -
- <%= luci.template.render_string(site.config_mode.msg_reboot) %> -
-
-
- - diff --git a/gluon-config-mode-reboot-ffhh/Makefile b/gluon-config-mode-reboot-ffhh/Makefile new file mode 100644 index 0000000..8370714 --- /dev/null +++ b/gluon-config-mode-reboot-ffhh/Makefile @@ -0,0 +1,36 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=gluon-config-mode-reboot-ffhh +PKG_VERSION:=2 + +PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) + +include $(GLUONDIR)/include/package.mk + +define Package/gluon-config-mode-reboot-ffhh + SECTION:=gluon + CATEGORY:=Gluon + TITLE:=Show text on reboot page if mesh vpn is disabled + 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-reboot-ffhh/install + $(CP) ./files/* $(1)/ +endef + +define Package/gluon-config-mode-reboot-ffhh/postinst +#!/bin/sh +$(call GluonCheckSite,check_site.lua) +endef + +$(eval $(call BuildPackage,gluon-config-mode-reboot-ffhh)) diff --git a/gluon-config-mode-reboot-ffhh/check_site.lua b/gluon-config-mode-reboot-ffhh/check_site.lua new file mode 100644 index 0000000..8017c24 --- /dev/null +++ b/gluon-config-mode-reboot-ffhh/check_site.lua @@ -0,0 +1 @@ +need_string 'config_mode.msg_nopubkey' diff --git a/gluon-config-mode-reboot-ffhh/files/lib/gluon/config-mode/reboot/0101-nopubkey.lua b/gluon-config-mode-reboot-ffhh/files/lib/gluon/config-mode/reboot/0101-nopubkey.lua new file mode 100644 index 0000000..806633d --- /dev/null +++ b/gluon-config-mode-reboot-ffhh/files/lib/gluon/config-mode/reboot/0101-nopubkey.lua @@ -0,0 +1,22 @@ +local msg = [[

+ <%= luci.template.render_string(site.config_mode.msg_nopubkey) %> +

]] + +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 site = require 'gluon.site_config' + local sysconfig = require 'gluon.sysconfig' + + local hostname = uci:get_first("system", "system", "hostname") + + return function () + luci.template.render_string(msg, { hostname=hostname + , site=site + , sysconfig=sysconfig + }) + end +end