server.lua 810 B

123456789101112131415161718192021222324252627282930
  1. -- Copyright 2016 Eric Luehrsen <ericluehrsen@hotmail.com>
  2. -- Licensed to the public under the Apache License 2.0.
  3. local m3, s3, frm
  4. local filename = "/etc/unbound/unbound_srv.conf"
  5. local description = translatef("Here you may edit the 'server:' clause in an internal 'include:'")
  6. description = description .. " (" .. filename .. ")"
  7. m3 = SimpleForm("editing", nil)
  8. m3:append(Template("unbound/css-editing"))
  9. m3.submit = translate("Save")
  10. m3.reset = false
  11. s3 = m3:section(SimpleSection, "Unbound Server Conf", description)
  12. frm = s3:option(TextValue, "data")
  13. frm.datatype = "string"
  14. frm.rows = 20
  15. function frm.cfgvalue()
  16. return nixio.fs.readfile(filename) or ""
  17. end
  18. function frm.write(self, section, data)
  19. return nixio.fs.writefile(filename, luci.util.trim(data:gsub("\r\n", "\n")))
  20. end
  21. return m3