Adapt to new modular config mode, add new reboot-ffhh package
this makes the old ffhh specific config mode obsolte, as only a package (reboot-ffhh) is need to add the necessary information to the reboot page
This commit is contained in:
parent
cc08450972
commit
918d892f15
|
@ -1,44 +0,0 @@
|
||||||
# Copyright (C) 2012 Nils Schneider <nils at nilsschneider.net>
|
|
||||||
# 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))
|
|
|
@ -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'
|
|
|
@ -1,83 +0,0 @@
|
||||||
--[[
|
|
||||||
Copyright 2013 Nils Schneider <nils@nilsschneider.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.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
|
|
|
@ -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 <b>automatisch</b>,
|
|
||||||
sobald eine neue Version vorliegt. Falls du dies nicht möchtest,
|
|
||||||
kannst du die Funktion im <i>Expertmode</i> deaktivieren.]])
|
|
||||||
else
|
|
||||||
f:set(nil, "autoupdater_msg", [[Dieser Knoten aktualisiert seine Firmware <b>nicht automatisch</b>.
|
|
||||||
Diese Funktion kannst du im <i>Expertmode</i> 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
|
|
|
@ -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
|
|
||||||
|
|
||||||
|
|
|
@ -1,71 +0,0 @@
|
||||||
<%-
|
|
||||||
local site = require 'gluon.site_config'
|
|
||||||
local sysconfig = require 'gluon.sysconfig'
|
|
||||||
local template = require 'luci.template'
|
|
||||||
-%>
|
|
||||||
|
|
||||||
<h2>Willkommen!</h2>
|
|
||||||
<p>
|
|
||||||
<%= template.render_string(site.config_mode.msg_welcome, {hostname=hostname, sysconfig=sysconfig}) %>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<%=self.data["autoupdater_msg"]%>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<% if not self.embedded then %>
|
|
||||||
<form method="post" enctype="multipart/form-data" action="<%=REQUEST_URI%>">
|
|
||||||
<div>
|
|
||||||
<script type="text/javascript" src="<%=resource%>/cbi.js"></script>
|
|
||||||
<input type="hidden" name="cbi.submit" value="1" />
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
<div class="cbi-map" id="cbi-<%=self.config%>">
|
|
||||||
<% if self.title and #self.title > 0 then %><h2><a id="content" name="content"><%=self.title%></a></h2><% end %>
|
|
||||||
<% if self.description and #self.description > 0 then %><div class="cbi-map-descr"><%=self.description%></div><% end %>
|
|
||||||
<% self:render_children() %>
|
|
||||||
<br />
|
|
||||||
</div>
|
|
||||||
<%- if self.message then %>
|
|
||||||
<div><%=self.message%></div>
|
|
||||||
<%- end %>
|
|
||||||
<%- if self.errmessage then %>
|
|
||||||
<div class="error"><%=self.errmessage%></div>
|
|
||||||
<%- end %>
|
|
||||||
<% if not self.embedded then %>
|
|
||||||
<div class="cbi-page-actions">
|
|
||||||
<%-
|
|
||||||
if type(self.hidden) == "table" then
|
|
||||||
for k, v in pairs(self.hidden) do
|
|
||||||
-%>
|
|
||||||
<input type="hidden" id="<%=k%>" name="<%=k%>" value="<%=pcdata(v)%>" />
|
|
||||||
<%-
|
|
||||||
end
|
|
||||||
end
|
|
||||||
%>
|
|
||||||
<% if redirect then %>
|
|
||||||
<div style="float:left">
|
|
||||||
<input class="cbi-button cbi-button-link" type="button" value="<%:Back to Overview%>" onclick="location.href='<%=pcdata(redirect)%>'" />
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
<%- if self.flow and self.flow.skip then %>
|
|
||||||
<input class="cbi-button cbi-button-skip" type="submit" name="cbi.skip" value="<%:Skip%>" />
|
|
||||||
<% end %>
|
|
||||||
<%- if self.submit ~= false then %>
|
|
||||||
<input class="cbi-button cbi-button-save" type="submit" value="
|
|
||||||
<%- if not self.submit then -%><%-:Submit-%><%-else-%><%=self.submit%><%end-%>
|
|
||||||
" />
|
|
||||||
<% end %>
|
|
||||||
<%- if self.reset ~= false then %>
|
|
||||||
<input class="cbi-button cbi-button-reset" type="reset" value="
|
|
||||||
<%- if not self.reset then -%><%-:Reset-%><%-else-%><%=self.reset%><%end-%>
|
|
||||||
" />
|
|
||||||
<% end %>
|
|
||||||
<%- if self.cancel ~= false and self.on_cancel then %>
|
|
||||||
<input class="cbi-button cbi-button-reset" type="submit" name="cbi.cancel" value="
|
|
||||||
<%- if not self.cancel then -%><%-:Cancel-%><%-else-%><%=self.cancel%><%end-%>
|
|
||||||
" />
|
|
||||||
<% end %>
|
|
||||||
<script type="text/javascript">cbi_d_update();</script>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<% end %>
|
|
|
@ -1,35 +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>
|
|
||||||
<% else %>
|
|
||||||
<p>
|
|
||||||
<%= luci.template.render_string(site.config_mode.msg_nopubkey) %>
|
|
||||||
</p>
|
|
||||||
<% end %>
|
|
||||||
<fieldset class="cbi-section">
|
|
||||||
<%= luci.template.render_string(site.config_mode.msg_reboot) %>
|
|
||||||
</fieldset>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
36
gluon-config-mode-reboot-ffhh/Makefile
Normal file
36
gluon-config-mode-reboot-ffhh/Makefile
Normal file
|
@ -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))
|
1
gluon-config-mode-reboot-ffhh/check_site.lua
Normal file
1
gluon-config-mode-reboot-ffhh/check_site.lua
Normal file
|
@ -0,0 +1 @@
|
||||||
|
need_string 'config_mode.msg_nopubkey'
|
|
@ -0,0 +1,22 @@
|
||||||
|
local msg = [[<p>
|
||||||
|
<%= luci.template.render_string(site.config_mode.msg_nopubkey) %>
|
||||||
|
</p>]]
|
||||||
|
|
||||||
|
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
|
Loading…
Reference in a new issue