2014-11-17 13:50:15 +00:00
|
|
|
Config Mode
|
|
|
|
===========
|
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
The `Config Mode` consists of several modules that provide a range of different
|
|
|
|
condiguration options:
|
2014-11-17 13:50:15 +00:00
|
|
|
|
|
|
|
gluon-config-mode-core
|
|
|
|
This modules provides the core functionality for the config mode.
|
|
|
|
All modules must depend on it.
|
|
|
|
|
|
|
|
gluon-config-mode-hostname
|
|
|
|
Provides a hostname field.
|
|
|
|
|
|
|
|
gluon-config-mode-autoupdater
|
|
|
|
Informs whether the autoupdater is enabled.
|
|
|
|
|
|
|
|
gluon-config-mode-mesh-vpn
|
|
|
|
Allows toggling of mesh-vpn-fastd and setting a bandwidth limit.
|
|
|
|
|
|
|
|
gluon-config-mode-geo-location
|
|
|
|
Enables the user to set the geographical location of the node.
|
|
|
|
|
|
|
|
gluon-config-mode-contact-info
|
|
|
|
Adds a field where the user can provide contact information.
|
|
|
|
|
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
Writing Config Mode modules
|
2014-11-17 13:50:15 +00:00
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
Config mode modules are located at ``/lib/gluon/config-mode/wizard`` and
|
|
|
|
``/lib/gluon/config-mode/reboot``. Modules are named like ``0000-name.lua`` and
|
|
|
|
are executed in lexical order. In the standard package set, the
|
2014-11-17 13:50:15 +00:00
|
|
|
order is, for wizard modules:
|
|
|
|
|
|
|
|
- 0050-autoupdater-info
|
|
|
|
- 0100-hostname
|
|
|
|
- 0300-mesh-vpn
|
|
|
|
- 0400-geo-location
|
|
|
|
- 0500-contact-info
|
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
The reboot module order is:
|
2014-11-17 13:50:15 +00:00
|
|
|
|
|
|
|
- 0100-mesh-vpn
|
|
|
|
- 0900-msg-reboot
|
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
All modules are run in the gluon-web model context and have access to the same
|
|
|
|
variables as "full" gluon-web modules.
|
|
|
|
|
2014-11-17 13:50:15 +00:00
|
|
|
Wizards
|
|
|
|
-------
|
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
Wizard modules must return a function that is provided with the wizard form and an
|
|
|
|
UCI cursor. The function can create configuration sections in the form:
|
2014-11-17 13:50:15 +00:00
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
.. code-block:: lua
|
2014-11-17 13:50:15 +00:00
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
return function(form, uci)
|
|
|
|
local s = form:section(Section)
|
|
|
|
local o = s:option(Value, "hostname", "Hostname")
|
|
|
|
o.default = uci:get_first("system", "system", "hostname")
|
2014-11-17 13:50:15 +00:00
|
|
|
o.datatype = "hostname"
|
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
function o:write(data)
|
|
|
|
uci:set("system", uci:get_first("system", "system"), "hostname", data)
|
|
|
|
end
|
|
|
|
|
|
|
|
return {'system'}
|
2014-11-17 13:50:15 +00:00
|
|
|
end
|
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
The function may return a table of UCI packages to commit after the individual
|
|
|
|
fields' `write` methods have been executed. This is done to avoid committing the
|
|
|
|
packages repeatedly when multiple wizard modules modify the same package.
|
2014-11-17 13:50:15 +00:00
|
|
|
|
|
|
|
Reboot page
|
|
|
|
-----------
|
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
Reboot modules are simply executed when the reboot page is
|
|
|
|
rendered:
|
2014-11-17 13:50:15 +00:00
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
.. code-block:: lua
|
2014-11-17 13:50:15 +00:00
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
renderer.render_string("Hello World!")
|