gluon-config-mode-domain-select: new package
[Matthias Schiffer: slightly clean up code]
This commit is contained in:
parent
0dd03597a6
commit
b98956e47e
@ -55,6 +55,7 @@ Several Freifunk communities in Germany use Gluon as the foundation of their Fre
|
||||
|
||||
package/gluon-client-bridge
|
||||
package/gluon-config-mode-contact-info
|
||||
package/gluon-config-mode-domain-select
|
||||
package/gluon-config-mode-geo-location
|
||||
package/gluon-ebtables-filter-multicast
|
||||
package/gluon-ebtables-filter-ra-dhcp
|
||||
|
19
docs/package/gluon-config-mode-domain-select.rst
Normal file
19
docs/package/gluon-config-mode-domain-select.rst
Normal file
@ -0,0 +1,19 @@
|
||||
gluon-config-mode-domain-select
|
||||
===============================
|
||||
This package provides a drop-down list for the config mode to select the domain
|
||||
the node will be placed in. If the selection has changed the upgrade scripts in
|
||||
``/lib/gluon/upgrade/`` are triggered to update the nodes configuration.
|
||||
|
||||
Hiding domains could be useful for default or testing domains, which should not
|
||||
be accidentally selected by a node operater.
|
||||
|
||||
domains/*.conf
|
||||
---------------------
|
||||
|
||||
hide_domain \: optional (defaults to false)
|
||||
- ``false`` shows this domain in drop-down list
|
||||
- ``true`` hides this domain
|
||||
|
||||
Example::
|
||||
|
||||
hide_domain = true
|
@ -16,6 +16,15 @@ msgstr ""
|
||||
"Freifunk-Knoten. Fülle das folgende Formular deinen Vorstellungen "
|
||||
"entsprechend aus und sende es ab."
|
||||
|
||||
msgid "gluon-config-mode:domain"
|
||||
msgstr "Domäne"
|
||||
|
||||
msgid "gluon-config-mode:domain-select"
|
||||
msgstr ""
|
||||
"Hier hast du die Möglichkeit, die Mesh-Domäne, in der sich dein Knoten "
|
||||
"befindet, auszuwählen. Bitte denke daran, dass sich dein Knoten nur mit den "
|
||||
"Knoten der ausgewählten Domäne verbinden kann."
|
||||
|
||||
msgid "gluon-config-mode:pubkey"
|
||||
msgstr ""
|
||||
"<p>Dies ist der öffentliche Schlüssel deines Freifunk-Knotens. Erst nachdem "
|
||||
|
@ -15,6 +15,15 @@ msgstr ""
|
||||
"Welcome to the setup wizard of your new Freifunk Alpha Centauri node. "
|
||||
"Please fill out the following form and submit it."
|
||||
|
||||
msgid "gluon-config-mode:domain"
|
||||
msgstr "Domain"
|
||||
|
||||
msgid "gluon-config-mode:domain-select"
|
||||
msgstr ""
|
||||
"Here you have the possibility of selecting the mesh domain in which your node "
|
||||
"is placed. Please keep in mind that your router only connects with the nodes "
|
||||
"of the selected domain"
|
||||
|
||||
msgid "gluon-config-mode:pubkey"
|
||||
msgstr ""
|
||||
"<p>This is your Freifunk node's public key. The node won't be able to "
|
||||
|
@ -16,6 +16,12 @@ msgstr ""
|
||||
"Freifunk. Remplissez le formulaire suivant en fonction de vos besoins "
|
||||
"et enregistrez le"
|
||||
|
||||
msgid "gluon-config-mode:domain"
|
||||
msgstr "Domaine"
|
||||
|
||||
msgid "gluon-config-mode:domain-select"
|
||||
msgstr ""
|
||||
|
||||
msgid "gluon-config-mode:pubkey"
|
||||
msgstr ""
|
||||
"<p>Ceci est la clé publique de votre nœud Freifunk. Seulment après que la clé soit "
|
||||
|
@ -4,6 +4,12 @@ msgstr "Content-Type: text/plain; charset=UTF-8"
|
||||
msgid "gluon-config-mode:welcome"
|
||||
msgstr ""
|
||||
|
||||
msgid "gluon-config-mode:domain"
|
||||
msgstr ""
|
||||
|
||||
msgid "gluon-config-mode:domain-select"
|
||||
msgstr ""
|
||||
|
||||
msgid "gluon-config-mode:pubkey"
|
||||
msgstr ""
|
||||
|
||||
|
42
package/gluon-config-mode-domain-select/Makefile
Normal file
42
package/gluon-config-mode-domain-select/Makefile
Normal file
@ -0,0 +1,42 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=gluon-config-mode-domain-select
|
||||
PKG_VERSION:=1
|
||||
|
||||
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
|
||||
|
||||
include ../gluon.mk
|
||||
|
||||
PKG_CONFIG_DEPENDS += $(GLUON_I18N_CONFIG)
|
||||
|
||||
|
||||
define Package/gluon-config-mode-domain-select
|
||||
SECTION:=gluon
|
||||
CATEGORY:=Gluon
|
||||
TITLE:=UI for changing the node-config
|
||||
DEPENDS:=+gluon-config-mode-core @GLUON_MULTIDOMAIN
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
$(call GluonBuildI18N,gluon-config-mode-domain-select,i18n)
|
||||
$(call GluonSrcDiet,./luasrc,$(PKG_BUILD_DIR)/luadest/)
|
||||
endef
|
||||
|
||||
define Package/gluon-config-mode-domain-select/install
|
||||
$(CP) $(PKG_BUILD_DIR)/luadest/* $(1)/
|
||||
$(call GluonInstallI18N,gluon-config-mode-domain-select,$(1))
|
||||
endef
|
||||
|
||||
define Package/gluon-config-domain-select/postinst
|
||||
#!/bin/sh
|
||||
$(call GluonCheckSite,check_site.lua)
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,gluon-config-mode-domain-select))
|
1
package/gluon-config-mode-domain-select/check_site.lua
Normal file
1
package/gluon-config-mode-domain-select/check_site.lua
Normal file
@ -0,0 +1 @@
|
||||
need_boolean(in_domain({'hide_domain'}), false)
|
@ -0,0 +1,54 @@
|
||||
return function(form, uci)
|
||||
local fs = require 'nixio.fs'
|
||||
local json = require 'jsonc'
|
||||
local site = require 'gluon.site'
|
||||
|
||||
local selected_domain = uci:get('gluon', 'core', 'domain')
|
||||
local configured = uci:get_first('gluon-setup-mode','setup_mode', 'configured') == '1' or (selected_domain ~= site.default_domain())
|
||||
|
||||
local function get_domain_list()
|
||||
local list = {}
|
||||
for domain_path in fs.glob('/lib/gluon/domains/*.json') do
|
||||
local domain_code = domain_path:match('([^/]+)%.json$')
|
||||
local domain = assert(json.load(domain_path))
|
||||
|
||||
if not domain.hide_domain or (configured and domain.domain_code == selected_domain) then
|
||||
table.insert(list, {
|
||||
domain_code = domain_code,
|
||||
domain_name = domain.domain_names[domain_code],
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
table.sort(list, function(a, b) return a.domain_name < b.domain_name end)
|
||||
return list
|
||||
end
|
||||
|
||||
local s = form:section(Section, nil, translate('gluon-config-mode:domain-select'))
|
||||
local o = s:option(ListValue, 'domain', translate('gluon-config-mode:domain'))
|
||||
|
||||
if configured then
|
||||
o.default = selected_domain
|
||||
end
|
||||
|
||||
for _, domain in ipairs(get_domain_list()) do
|
||||
o:value(domain.domain_code, domain.domain_name)
|
||||
end
|
||||
|
||||
local domain_changed = false
|
||||
|
||||
function o:write(data)
|
||||
if data ~= selected_domain then
|
||||
domain_changed = true
|
||||
uci:set('gluon', 'core', 'domain', data)
|
||||
end
|
||||
end
|
||||
|
||||
local function reconfigure()
|
||||
if domain_changed then
|
||||
os.execute('gluon-reconfigure')
|
||||
end
|
||||
end
|
||||
|
||||
return {'gluon', reconfigure}
|
||||
end
|
Loading…
Reference in New Issue
Block a user