configmode.rst 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. Config Mode
  2. ===========
  3. As of 2014.4 `gluon-config-mode` consists of several modules.
  4. gluon-config-mode-core
  5. This modules provides the core functionality for the config mode.
  6. All modules must depend on it.
  7. gluon-config-mode-hostname
  8. Provides a hostname field.
  9. gluon-config-mode-autoupdater
  10. Informs whether the autoupdater is enabled.
  11. gluon-config-mode-mesh-vpn
  12. Allows toggling of mesh-vpn-fastd and setting a bandwidth limit.
  13. gluon-config-mode-geo-location
  14. Enables the user to set the geographical location of the node.
  15. gluon-config-mode-contact-info
  16. Adds a field where the user can provide contact information.
  17. In order to get a config mode close to the one found in 2014.3.x you may add
  18. these modules to your `site.mk`:
  19. gluon-config-mode-hostname,
  20. gluon-config-mode-autoupdater,
  21. gluon-config-mode-mesh-vpn,
  22. gluon-config-mode-geo-location,
  23. gluon-config-mode-contact-info
  24. Writing Config Mode Modules
  25. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  26. Config mode modules are located at `/lib/gluon/config-mode/wizard` and
  27. `/lib/gluon/config-mode/reboot`. Modules are named like `0000-name.lua` and
  28. are executed in lexical order. If you take the standard set of modules, the
  29. order is, for wizard modules:
  30. - 0050-autoupdater-info
  31. - 0100-hostname
  32. - 0300-mesh-vpn
  33. - 0400-geo-location
  34. - 0500-contact-info
  35. While for reboot modules it is:
  36. - 0100-mesh-vpn
  37. - 0900-msg-reboot
  38. Wizards
  39. -------
  40. Wizard modules return a UCI section. A simple module capable of changing the
  41. hostname might look like this::
  42. local cbi = require "luci.cbi"
  43. local uci = luci.model.uci.cursor()
  44. local M = {}
  45. function M.section(form)
  46. local s = form:section(cbi.SimpleSection, nil, nil)
  47. local o = s:option(cbi.Value, "_hostname", "Hostname")
  48. o.value = uci:get_first("system", "system", "hostname")
  49. o.rmempty = false
  50. o.datatype = "hostname"
  51. end
  52. function M.handle(data)
  53. uci:set("system", uci:get_first("system", "system"), "hostname", data._hostname)
  54. uci:save("system")
  55. uci:commit("system")
  56. end
  57. return M
  58. Reboot page
  59. -----------
  60. Reboot modules return a function that will be called when the page is to be
  61. rendered or nil (i.e. the module is skipped)::
  62. if no_hello_world_today then
  63. return nil
  64. else
  65. return function ()
  66. luci.template.render_string("Hello World!")
  67. end
  68. end