Rename a lot of stuff, put init script into the config_mode package
This commit is contained in:
parent
b1a118bebe
commit
39514836fd
|
@ -0,0 +1,3 @@
|
|||
config wizard
|
||||
option enabled '1'
|
||||
option configured '0'
|
|
@ -1,8 +0,0 @@
|
|||
config wizard
|
||||
option enabled '1'
|
||||
option configured '0'
|
||||
|
||||
config bandwidth
|
||||
option upstream '0'
|
||||
option downstream '0'
|
||||
option enabled '0'
|
|
@ -0,0 +1,53 @@
|
|||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=12
|
||||
|
||||
|
||||
config_mode_iface=eth0
|
||||
config_mode_addr=192.168.1.1
|
||||
config_mode_plen=24
|
||||
|
||||
config_mode_dnsname=freifunk
|
||||
config_mode_dhcp_range=192.168.1.2,192.168.1.254
|
||||
|
||||
check_enable() {
|
||||
config_get enabled "$1" enabled
|
||||
config_get configured "$1" configured
|
||||
|
||||
if [ "$enabled" = 1 -o "$configured" != 1 ]; then
|
||||
export enable=1
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
enable=0
|
||||
config_load config_mode
|
||||
config_foreach check_enable wizard
|
||||
|
||||
if [ "$enable" = '1' ]; then
|
||||
lua -luci -e 'require "luci.model.uci"; uci_state=luci.model.uci.cursor_state(); uci_state:section("config_mode", "wizard", nil, { running = "1" }); uci_state:save("config_mode")'
|
||||
uci set 'config_mode.@wizard[0].enabled=0'
|
||||
uci commit config_mode
|
||||
|
||||
ip addr add $config_mode_addr/$config_mode_plen dev $config_mode_iface
|
||||
ip link set up dev $config_mode_iface
|
||||
|
||||
/etc/init.d/telnet start
|
||||
/etc/init.d/dropbear start
|
||||
/etc/init.d/uhttpd start
|
||||
/etc/init.d/led start
|
||||
|
||||
# correctly finish firstboot
|
||||
/etc/init.d/done boot
|
||||
|
||||
echo "$config_mode_addr $config_mode_dnsname" > /tmp/hosts.config_mode
|
||||
dnsmasq -h -H /tmp/hosts.config_mode -R -F interface:$config_mode_iface,$config_mode_dhcp_range -l /tmp/dhcp.leases -O option:router
|
||||
|
||||
. /etc/diag.sh
|
||||
get_status_led
|
||||
status_led_set_timer 1000 300
|
||||
|
||||
# block further boot
|
||||
while true; do sleep 1; done
|
||||
fi
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
module("luci.controller.ffhl.wizard", package.seeall)
|
||||
|
||||
function index()
|
||||
local uci_state = luci.model.uci.cursor_state()
|
||||
if uci_state:get_first("ffhl", "wizard", "running", "0") == "1" then
|
||||
entry({"wizard", "welcome"}, template("ffhl-wizard/welcome"), "Willkommen", 10).dependent=false
|
||||
entry({"wizard", "password"}, form("ffhl-wizard/password"), "Passwort", 20).dependent=false
|
||||
entry({"wizard", "hostname"}, form("ffhl-wizard/hostname"), "Hostname", 30).dependent=false
|
||||
entry({"wizard", "meshvpn"}, form("ffhl-wizard/meshvpn"), "Mesh-VPN", 40).dependent=false
|
||||
entry({"wizard", "meshvpn", "pubkey"}, template("ffhl-wizard/meshvpn-key"), "Mesh-VPN Key", 1).dependent=false
|
||||
entry({"wizard", "completed"}, template("ffhl-wizard/completed"), "Fertig", 50).dependent=false
|
||||
entry({"wizard", "completed", "reboot"}, call("reboot"), "reboot", 1).dependent=false
|
||||
end
|
||||
end
|
||||
|
||||
function reboot()
|
||||
local uci = luci.model.uci.cursor()
|
||||
|
||||
uci:foreach("ffhl", "wizard",
|
||||
function(s)
|
||||
uci:set("ffhl", s[".name"], "configured", "1")
|
||||
end
|
||||
)
|
||||
|
||||
uci:save("ffhl")
|
||||
uci:commit("ffhl")
|
||||
|
||||
luci.sys.reboot()
|
||||
end
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
module("luci.controller.ffhl.index", package.seeall)
|
||||
module("luci.controller.freifunk.index", package.seeall)
|
||||
|
||||
|
||||
function index()
|
||||
local uci_state = luci.model.uci.cursor_state()
|
||||
|
||||
if uci_state:get_first("ffhl", "wizard", "running", "0") == "1" then
|
||||
if uci_state:get_first("config_mode", "wizard", "running", "0") == "1" then
|
||||
local root = node()
|
||||
if not root.target then
|
||||
root.target = alias("wizard", "welcome")
|
|
@ -0,0 +1,30 @@
|
|||
module("luci.controller.freifunk.wizard", package.seeall)
|
||||
|
||||
function index()
|
||||
local uci_state = luci.model.uci.cursor_state()
|
||||
if uci_state:get_first("freifunk", "wizard", "running", "0") == "1" then
|
||||
entry({"wizard", "welcome"}, template("freifunk-wizard/welcome"), "Willkommen", 10).dependent=false
|
||||
entry({"wizard", "password"}, form("freifunk-wizard/password"), "Passwort", 20).dependent=false
|
||||
entry({"wizard", "hostname"}, form("freifunk-wizard/hostname"), "Hostname", 30).dependent=false
|
||||
entry({"wizard", "meshvpn"}, form("freifunk-wizard/meshvpn"), "Mesh-VPN", 40).dependent=false
|
||||
entry({"wizard", "meshvpn", "pubkey"}, template("freifunk-wizard/meshvpn-key"), "Mesh-VPN Key", 1).dependent=false
|
||||
entry({"wizard", "completed"}, template("freifunk-wizard/completed"), "Fertig", 50).dependent=false
|
||||
entry({"wizard", "completed", "reboot"}, call("reboot"), "reboot", 1).dependent=false
|
||||
end
|
||||
end
|
||||
|
||||
function reboot()
|
||||
local uci = luci.model.uci.cursor()
|
||||
|
||||
uci:foreach("config_mode", "wizard",
|
||||
function(s)
|
||||
uci:set("config_mode", s[".name"], "configured", "1")
|
||||
end
|
||||
)
|
||||
|
||||
uci:save("config_mode")
|
||||
uci:commit("config_mode")
|
||||
|
||||
luci.sys.reboot()
|
||||
end
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
local uci = luci.model.uci.cursor()
|
||||
|
||||
local nav = require "luci.tools.ffhl-wizard.nav"
|
||||
local nav = require "luci.tools.freifunk-wizard.nav"
|
||||
|
||||
local f = SimpleForm("hostname", "Name deines Freifunkknotens", "Als nächstes solltest du einem Freifunkknoten einen individuellen Namen geben. Dieser hilft dir und auch uns den Überblick zu behalten.")
|
||||
f.template = "ffhl-wizard/wizardform"
|
||||
f.template = "freifunk-wizard/wizardform"
|
||||
|
||||
hostname = f:field(Value, "hostname", "Hostname")
|
||||
hostname.value = uci:get_first("system", "system", "hostname")
|
|
@ -1,6 +1,7 @@
|
|||
local uci = luci.model.uci.cursor()
|
||||
local meshvpn = "ffhl_mesh_vpn"
|
||||
|
||||
local nav = require "luci.tools.ffhl-wizard.nav"
|
||||
local uci = luci.model.uci.cursor()
|
||||
local nav = require "luci.tools.freifunk-wizard.nav"
|
||||
|
||||
local f = SimpleForm("meshvpn", "Mesh-VPN", "<p>Um deinen Freifunkknoten auch über das Internet mit dem Freifunk-Netzwerk zu verbinden, kann das Mesh-VPN aktiviert werden.\
|
||||
Dies erlaubt es, den Freifunk-Knoten zu betreiben, auch wenn es keine anderen Knoten in deiner Umgebung gibt, mit denen eine WLAN-Verbindung möglich ist.</p>\
|
||||
|
@ -8,40 +9,40 @@ Dies erlaubt es, den Freifunk-Knoten zu betreiben, auch wenn es keine anderen Kn
|
|||
<p>Damit das Mesh-VPN deine Internet-Verbindung nicht unverhältnismäßig auslastet, kann die Bandbreite begrenzt werden. Wenn du zum Beispiel eine DSL-16000-Leitung hast\
|
||||
und maximal ein Viertel der Leitung zur Verfügung stellen willst, muss als Downstream-Bandbreite 4000 kbit/s eingetragen werden.</p>\
|
||||
<p>Um das Freifunk-Netz nicht zu sehr auszubremsen, bitten wir darum, mindestens 1000 kbit/s im Downstream und 100 kbit/s im Upstream bereitzustellen.</p>")
|
||||
f.template = "ffhl-wizard/wizardform"
|
||||
f.template = "freifunk-wizard/wizardform"
|
||||
|
||||
meshvpn = f:field(Flag, "meshvpn", "Mesh-VPN aktivieren?")
|
||||
meshvpn.default = string.format("%d", uci:get("fastd", "ffhl_mesh_vpn", "enabled", "0"))
|
||||
meshvpn.default = string.format("%d", uci:get("fastd", meshvpn, "enabled", "0"))
|
||||
meshvpn.rmempty = false
|
||||
|
||||
tc = f:field(Flag, "tc", "Bandbreitenbegrenzung aktivieren?")
|
||||
tc.default = string.format("%d", uci:get_first("ffhl", "bandwidth", "enabled", "0"))
|
||||
tc.default = string.format("%d", uci:get_first("freifunk", "bandwidth", "enabled", "0"))
|
||||
tc.rmempty = false
|
||||
|
||||
downstream = f:field(Value, "downstream", "Downstream-Bandbreite (kbit/s)")
|
||||
downstream.value = uci:get_first("ffhl", "bandwidth", "downstream", "0")
|
||||
downstream.value = uci:get_first("freifunk", "bandwidth", "downstream", "0")
|
||||
upstream = f:field(Value, "upstream", "Upstream-Bandbreite (kbit/s)")
|
||||
upstream.value = uci:get_first("ffhl", "bandwidth", "upstream", "0")
|
||||
upstream.value = uci:get_first("freifunk", "bandwidth", "upstream", "0")
|
||||
|
||||
function f.handle(self, state, data)
|
||||
if state == FORM_VALID then
|
||||
local stat = false
|
||||
uci:set("fastd", "ffhl_mesh_vpn", "enabled", data.meshvpn)
|
||||
uci:set("fastd", meshvpn, "enabled", data.meshvpn)
|
||||
uci:save("fastd")
|
||||
uci:commit("fastd")
|
||||
|
||||
uci:foreach("ffhl", "bandwidth", function(s)
|
||||
uci:set("ffhl", s[".name"], "upstream", data.upstream)
|
||||
uci:set("ffhl", s[".name"], "downstream", data.downstream)
|
||||
uci:set("ffhl", s[".name"], "enabled", data.tc)
|
||||
uci:foreach("freifunk", "bandwidth", function(s)
|
||||
uci:set("freifunk", s[".name"], "upstream", data.upstream)
|
||||
uci:set("freifunk", s[".name"], "downstream", data.downstream)
|
||||
uci:set("freifunk", s[".name"], "enabled", data.tc)
|
||||
end
|
||||
)
|
||||
|
||||
uci:save("ffhl")
|
||||
uci:commit("ffhl")
|
||||
uci:save("freifunk")
|
||||
uci:commit("freifunk")
|
||||
|
||||
if data.meshvpn == "1" then
|
||||
local secret = uci:get("fastd", "ffhl_mesh_vpn", "secret")
|
||||
local secret = uci:get("fastd", meshvpn, "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
|
||||
luci.sys.call("/etc/init.d/haveged start")
|
||||
local f = io.popen("fastd --generate-key --machine-readable", "r")
|
||||
|
@ -49,7 +50,7 @@ function f.handle(self, state, data)
|
|||
f:close()
|
||||
luci.sys.call("/etc/init.d/haveged stop")
|
||||
|
||||
uci:set("fastd", "ffhl_mesh_vpn", "secret", secret)
|
||||
uci:set("fastd", meshvpn, "secret", secret)
|
||||
uci:save("fastd")
|
||||
uci:commit("fastd")
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
local nav = require "luci.tools.ffhl-wizard.nav"
|
||||
local nav = require "luci.tools.freifunk-wizard.nav"
|
||||
|
||||
f = SimpleForm("password", "Administrator-Passwort setzen", "<p>Damit nur du Zugriff auf deinen Freifunkknoten hast, solltest du jetzt ein Passwort vergeben. \
|
||||
Da man mit Hilfe von diesem beliebige Einstellungen geändert werden können, sollte es möglichst sicher sein.</p>\
|
||||
|
@ -8,7 +8,7 @@ Da man mit Hilfe von diesem beliebige Einstellungen geändert werden können, so
|
|||
<li>Es sollte mehr als acht Zeichen beinhalten.</li>\
|
||||
<li>Es sollte auch Zahlen & Sonderzeichen enthalten.</li>\
|
||||
</ul>")
|
||||
f.template = "ffhl-wizard/wizardform"
|
||||
f.template = "freifunk-wizard/wizardform"
|
||||
|
||||
pw1 = f:field(Value, "pw1", "Passwort")
|
||||
pw1.password = true
|
|
@ -1,4 +1,4 @@
|
|||
module("luci.tools.ffhl-wizard.nav", package.seeall)
|
||||
module("luci.tools.freifunk-wizard.nav", package.seeall)
|
||||
|
||||
function maybe_redirect_to_successor()
|
||||
local pre, suc = get()
|
|
@ -1,15 +1,17 @@
|
|||
<%
|
||||
local address = "freifunk.luebeck@asta.uni-luebeck.de"
|
||||
|
||||
local disp = require "luci.dispatcher"
|
||||
local f = io.popen("/etc/init.d/fastd show_key ffhl_mesh_vpn", "r")
|
||||
local f = io.popen("/etc/init.d/fastd show_key freifunk_mesh_vpn", "r")
|
||||
local key = f:read("*a")
|
||||
f:close()
|
||||
|
||||
%>
|
||||
<%+header%>
|
||||
<h2>Schlüsselaustausch</h2>
|
||||
<p>Dies ist der öffentliche Schlüssel deines Freifunkknotens. Bitte schicke ihn an freifunk.luebeck@asta.uni-luebeck.de um ihn auf den Freifunkservern eintragen zu lassen. Sobald der Schlüssel eingetragen wurde, kann dein Knoten das Mesh-VPN nutzen.</p>
|
||||
<p>Dies ist der öffentliche Schlüssel deines Freifunkknotens. Bitte schicke ihn an <%=address=%> um ihn auf den Freifunkservern eintragen zu lassen. Sobald der Schlüssel eingetragen wurde, kann dein Knoten das Mesh-VPN nutzen.</p>
|
||||
<div style="text-align: center;font-size: 2em;line-height: 1em; background: #f5f5f5; border: 1px solid #ececec; margin-bottom: 0.5em; padding: 0.5em">
|
||||
<%=key%>
|
||||
</div>
|
||||
<%+ffhl-wizard/nav%>
|
||||
<%+freifunk-wizard/nav%>
|
||||
<%+footer%>
|
|
@ -1,5 +1,5 @@
|
|||
<%
|
||||
local nav = require "luci.tools.ffhl-wizard.nav"
|
||||
local nav = require "luci.tools.freifunk-wizard.nav"
|
||||
local predecessor, successor = nav.get()
|
||||
%>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<%
|
||||
local disp = require "luci.dispatcher"
|
||||
local nav = require "luci.tools.ffhl-wizard.nav"
|
||||
local nav = require "luci.tools.freifunk-wizard.nav"
|
||||
local predecessor, successor = nav.get()
|
||||
%>
|
||||
<%+header%>
|
|
@ -53,7 +53,7 @@
|
|||
" />
|
||||
<% end %>
|
||||
<%
|
||||
local nav = require "luci.tools.ffhl-wizard.nav"
|
||||
local nav = require "luci.tools.freifunk-wizard.nav"
|
||||
local predecessor, successor = nav.get()
|
||||
%>
|
||||
<% if predecessor then %>
|
Loading…
Reference in New Issue