config-mode.rst 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. Config Mode
  2. ===========
  3. The `Config Mode` consists of several modules that provide a range of different
  4. condiguration options:
  5. gluon-config-mode-core
  6. This modules provides the core functionality for the config mode.
  7. All modules must depend on it.
  8. gluon-config-mode-hostname
  9. Provides a hostname field.
  10. gluon-config-mode-autoupdater
  11. Informs whether the autoupdater is enabled.
  12. gluon-config-mode-mesh-vpn
  13. Allows toggling of mesh-vpn-fastd and setting a bandwidth limit.
  14. gluon-config-mode-geo-location
  15. Enables the user to set the geographical location of the node.
  16. gluon-config-mode-contact-info
  17. Adds a field where the user can provide contact information.
  18. Writing Config Mode modules
  19. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  20. Config mode modules are located at ``/lib/gluon/config-mode/wizard`` and
  21. ``/lib/gluon/config-mode/reboot``. Modules are named like ``0000-name.lua`` and
  22. are executed in lexical order. In the standard package set, the
  23. order is, for wizard modules:
  24. - 0050-autoupdater-info
  25. - 0100-hostname
  26. - 0300-mesh-vpn
  27. - 0400-geo-location
  28. - 0500-contact-info
  29. The reboot module order is:
  30. - 0100-mesh-vpn
  31. - 0900-msg-reboot
  32. All modules are run in the gluon-web model context and have access to the same
  33. variables as "full" gluon-web modules.
  34. Wizards
  35. -------
  36. Wizard modules must return a function that is provided with the wizard form and an
  37. UCI cursor. The function can create configuration sections in the form:
  38. .. code-block:: lua
  39. return function(form, uci)
  40. local s = form:section(Section)
  41. local o = s:option(Value, "hostname", "Hostname")
  42. o.default = uci:get_first("system", "system", "hostname")
  43. o.datatype = "hostname"
  44. function o:write(data)
  45. uci:set("system", uci:get_first("system", "system"), "hostname", data)
  46. end
  47. return {'system'}
  48. end
  49. The function may return a table of UCI packages to commit after the individual
  50. fields' `write` methods have been executed. This is done to avoid committing the
  51. packages repeatedly when multiple wizard modules modify the same package.
  52. Reboot page
  53. -----------
  54. Reboot modules are simply executed when the reboot page is
  55. rendered:
  56. .. code-block:: lua
  57. renderer.render_string("Hello World!")