0100-hostname.lua 542 B

123456789101112131415161718192021
  1. local cbi = require "luci.cbi"
  2. local i18n = require "luci.i18n"
  3. local uci = luci.model.uci.cursor()
  4. local M = {}
  5. function M.section(form)
  6. local s = form:section(cbi.SimpleSection, nil, nil)
  7. local o = s:option(cbi.Value, "_hostname", i18n.translate("Node name"))
  8. o.value = uci:get_first("system", "system", "hostname")
  9. o.rmempty = false
  10. o.datatype = "hostname"
  11. end
  12. function M.handle(data)
  13. uci:set("system", uci:get_first("system", "system"), "hostname", data._hostname)
  14. uci:save("system")
  15. uci:commit("system")
  16. end
  17. return M