-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
web config web UI now using ssl on port 443
- Loading branch information
Showing
18 changed files
with
239 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# 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:=ffbsee-config-mode-core | ||
PKG_VERSION:=0.1 | ||
|
||
include $(TOPDIR)/../package/gluon.mk | ||
|
||
define Package/ffbsee-config-mode-core | ||
TITLE:=Configuration wizard for user friendly setup of new mesh nodes | ||
DEPENDS:=+gluon-setup-mode +gluon-web-model +gluon-config-mode-theme +uhttpd +libuhttpd-openssl +openssl-util | ||
PROVIDES:=gluon-config-mode-core | ||
endef | ||
|
||
define Package/ffbsee-config-mode-core/install | ||
$(Gluon/Build/Install) | ||
|
||
$(INSTALL_DIR) $(1)/lib/gluon/config-mode/view/ $(1)/lib/gluon/config-mode/www/static/ | ||
$(LN) /lib/gluon/web/i18n $(1)/lib/gluon/config-mode/ | ||
$(LN) /lib/gluon/web/view/{error,model} $(1)/lib/gluon/config-mode/view/ | ||
$(LN) /lib/gluon/web/www/static/gluon-web-model.js $(1)/lib/gluon/config-mode/www/static/ | ||
endef | ||
|
||
$(eval $(call BuildPackageGluon,ffbsee-config-mode-core)) |
15 changes: 15 additions & 0 deletions
15
ffbsee-config-mode-core/files/lib/gluon/config-mode/view/wizard/reboot.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<h2><%:Your node's setup is now complete.%></h2> | ||
<% | ||
local util = require "gluon.util" | ||
|
||
local parts = {} | ||
for _, entry in ipairs(util.glob('/lib/gluon/config-mode/reboot/*')) do | ||
local p = assert(loadfile(entry)) | ||
setfenv(p, getfenv()) | ||
table.insert(parts, p) | ||
end | ||
|
||
for _, p in ipairs(parts) do | ||
p() | ||
end | ||
%> |
16 changes: 16 additions & 0 deletions
16
ffbsee-config-mode-core/files/lib/gluon/config-mode/view/wizard/welcome.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<%- | ||
local site_i18n = i18n 'gluon-site' | ||
|
||
local sysconfig = require 'gluon.sysconfig' | ||
|
||
local msg = site_i18n._translate('gluon-config-mode:welcome') | ||
if not msg then return end | ||
-%> | ||
<p> | ||
<% | ||
renderer.render_string(msg, { | ||
hostname = hostname, | ||
sysconfig = sysconfig, | ||
}) | ||
%> | ||
</p> |
11 changes: 11 additions & 0 deletions
11
ffbsee-config-mode-core/files/lib/gluon/config-mode/www/index.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> | ||
<meta http-equiv="Pragma" content="no-cache" /> | ||
<meta http-equiv="Expires" content="0" /> | ||
<meta http-equiv="refresh" content="0; URL=/cgi-bin/config" /> | ||
</head> | ||
<body> | ||
</body> | ||
</html> |
14 changes: 14 additions & 0 deletions
14
ffbsee-config-mode-core/files/lib/gluon/setup-mode/rc.d/S50uhttpd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/sh /etc/rc.common | ||
|
||
START=50 | ||
|
||
USE_PROCD=1 | ||
|
||
UHTTPD_BIN="/usr/sbin/uhttpd" | ||
|
||
start_service() { | ||
procd_open_instance | ||
procd_set_param respawn | ||
procd_set_param command "$UHTTPD_BIN" -f -h /lib/gluon/config-mode/www -x /cgi-bin -A 1 -R -C /etc/uhttpd.crt -K /etc/uhttpd.key -s 0.0.0.0:443 -s :::443 | ||
procd_close_instance | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"PO-Revision-Date: 2015-03-19 02:07+0100\n" | ||
"Last-Translator: Matthias Schiffer <[email protected]>\n" | ||
"Language-Team: German\n" | ||
"Language: de\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
|
||
msgid "Save & restart" | ||
msgstr "Speichern & Neustarten" | ||
|
||
msgid "Welcome!" | ||
msgstr "Willkommen!" | ||
|
||
msgid "Wizard" | ||
msgstr "Wizard" | ||
|
||
msgid "Your node's setup is now complete." | ||
msgstr "Dein Knoten ist nun fertig eingerichtet." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: PACKAGE VERSION\n" | ||
"PO-Revision-Date: 2015-08-12 23:30+0100\n" | ||
"Last-Translator:Tobias Bernot <[email protected]>\n" | ||
"Language-Team: French\n" | ||
"Language: fr\n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Plural-Forms: nplurals=2; plural=(n != 1);\n" | ||
|
||
msgid "Save & restart" | ||
msgstr "Enregistrer & Redémarer" | ||
|
||
msgid "Welcome!" | ||
msgstr "Bienvenue!" | ||
|
||
msgid "Wizard" | ||
msgstr "Assistant" | ||
|
||
msgid "Your node's setup is now complete." | ||
msgstr "La configuration de votre nœud est terminée." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
msgid "" | ||
msgstr "Content-Type: text/plain; charset=UTF-8" | ||
|
||
msgid "Save & restart" | ||
msgstr "" | ||
|
||
msgid "Welcome!" | ||
msgstr "" | ||
|
||
msgid "Wizard" | ||
msgstr "" | ||
|
||
msgid "Your node's setup is now complete." | ||
msgstr "" |
4 changes: 4 additions & 0 deletions
4
ffbsee-config-mode-core/luasrc/lib/gluon/config-mode/controller/gluon-config-mode/index.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package 'gluon-config-mode-core' | ||
|
||
entry({}, alias("wizard")) | ||
entry({"wizard"}, model("gluon-config-mode/wizard"), _("Wizard"), 5) |
44 changes: 44 additions & 0 deletions
44
ffbsee-config-mode-core/luasrc/lib/gluon/config-mode/model/gluon-config-mode/wizard.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
local util = require "gluon.util" | ||
local uci = require("simple-uci").cursor() | ||
|
||
local f = Form(translate("Welcome!")) | ||
f.submit = translate('Save & restart') | ||
f.reset = false | ||
|
||
local s = f:section(Section) | ||
s.template = "wizard/welcome" | ||
s.package = "gluon-config-mode-core" | ||
|
||
for _, entry in ipairs(util.glob('/lib/gluon/config-mode/wizard/*')) do | ||
local section = assert(loadfile(entry)) | ||
setfenv(section, getfenv()) | ||
section()(f, uci) | ||
end | ||
|
||
function f:write() | ||
local fcntl = require 'posix.fcntl' | ||
local unistd = require 'posix.unistd' | ||
|
||
uci:set("gluon-setup-mode", uci:get_first("gluon-setup-mode", "setup_mode"), "configured", true) | ||
uci:save("gluon-setup-mode") | ||
|
||
os.execute('gluon-reconfigure') | ||
|
||
f.template = "wizard/reboot" | ||
f.package = "gluon-config-mode-core" | ||
f.hidenav = true | ||
|
||
if unistd.fork() == 0 then | ||
-- Replace stdout with /dev/null | ||
local null = fcntl.open('/dev/null', fcntl.O_WRONLY) | ||
unistd.dup2(null, unistd.STDOUT_FILENO) | ||
|
||
-- Sleep a little so the browser can fetch everything required to | ||
-- display the reboot page, then reboot the device. | ||
unistd.sleep(1) | ||
|
||
unistd.execp('reboot', {[0] = 'reboot'}) | ||
end | ||
end | ||
|
||
return f |
20 changes: 20 additions & 0 deletions
20
ffbsee-config-mode-core/luasrc/lib/gluon/config-mode/reboot/0900-msg-reboot.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
local site_i18n = i18n 'gluon-site' | ||
|
||
local site = require 'gluon.site' | ||
local sysconfig = require 'gluon.sysconfig' | ||
local pretty_hostname = require 'pretty_hostname' | ||
|
||
local uci = require("simple-uci").cursor() | ||
|
||
local hostname = pretty_hostname.get(uci) | ||
local contact = uci:get_first('gluon-node-info', 'owner', 'contact') | ||
|
||
local msg = site_i18n._translate('gluon-config-mode:reboot') | ||
if not msg then return end | ||
|
||
renderer.render_string(msg, { | ||
hostname = hostname, | ||
site = site, | ||
sysconfig = sysconfig, | ||
contact = contact, | ||
}) |
8 changes: 8 additions & 0 deletions
8
ffbsee-config-mode-core/luasrc/lib/gluon/config-mode/www/cgi-bin/config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/lua | ||
|
||
require 'gluon.web.cgi' { | ||
base_path = '/lib/gluon/config-mode', | ||
|
||
layout_package = 'gluon-config-mode-theme', | ||
layout_template = 'theme/layout', | ||
} |
12 changes: 12 additions & 0 deletions
12
ffbsee-config-mode-core/luasrc/lib/gluon/upgrade/300-config-mode-rule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/lua | ||
|
||
local uci = require('simple-uci').cursor() | ||
|
||
uci:section('firewall', 'rule', 'loc_client' .. '_https', { | ||
src = 'loc_client', | ||
dest_port = '443', | ||
proto = 'tcp', | ||
target = 'ACCEPT', | ||
}) | ||
|
||
uci:save('firewall') |
3 changes: 3 additions & 0 deletions
3
ffbsee-config-mode-core/luasrc/lib/gluon/upgrade/300-update-certs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/ash | ||
|
||
openssl req -new -x509 -sha256 -newkey rsa:2048 -nodes -keyout /etc/uhttpd.key -days 365 -out /etc/uhttpd.crt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters