samba.lua 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. -- Copyright 2008 Steven Barth <steven@midlink.org>
  2. -- Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
  3. -- Licensed to the public under the Apache License 2.0.
  4. m = Map("samba", translate("Network Shares"))
  5. s = m:section(TypedSection, "samba", "Samba")
  6. s.anonymous = true
  7. s:tab("general", translate("General Settings"))
  8. s:tab("template", translate("Edit Template"))
  9. s:taboption("general", Value, "name", translate("Hostname"))
  10. s:taboption("general", Value, "description", translate("Description"))
  11. s:taboption("general", Value, "workgroup", translate("Workgroup"))
  12. h = s:taboption("general", Flag, "homes", translate("Share home-directories"),
  13. translate("Allow system users to reach their home directories via " ..
  14. "network shares"))
  15. h.rmempty = false
  16. tmpl = s:taboption("template", Value, "_tmpl",
  17. translate("Edit the template that is used for generating the samba configuration."),
  18. translate("This is the content of the file '/etc/samba/smb.conf.template' from which your samba configuration will be generated. " ..
  19. "Values enclosed by pipe symbols ('|') should not be changed. They get their values from the 'General Settings' tab."))
  20. tmpl.template = "cbi/tvalue"
  21. tmpl.rows = 20
  22. function tmpl.cfgvalue(self, section)
  23. return nixio.fs.readfile("/etc/samba/smb.conf.template")
  24. end
  25. function tmpl.write(self, section, value)
  26. value = value:gsub("\r\n?", "\n")
  27. nixio.fs.writefile("//etc/samba/smb.conf.template", value)
  28. end
  29. s = m:section(TypedSection, "sambashare", translate("Shared Directories")
  30. , translate("Please add directories to share. Each directory refers to a folder on a mounted device."))
  31. s.anonymous = true
  32. s.addremove = true
  33. s.template = "cbi/tblsection"
  34. s:option(Value, "name", translate("Name"))
  35. pth = s:option(Value, "path", translate("Path"))
  36. if nixio.fs.access("/etc/config/fstab") then
  37. pth.titleref = luci.dispatcher.build_url("admin", "system", "fstab")
  38. end
  39. s:option(Value, "users", translate("Allowed users")).rmempty = true
  40. ro = s:option(Flag, "read_only", translate("Read-only"))
  41. ro.rmempty = false
  42. ro.enabled = "yes"
  43. ro.disabled = "no"
  44. br = s:option(Flag, "browseable", translate("Browseable"))
  45. br.rmempty = false
  46. br.default = "yes"
  47. br.enabled = "yes"
  48. br.disabled = "no"
  49. go = s:option(Flag, "guest_ok", translate("Allow guests"))
  50. go.rmempty = false
  51. go.enabled = "yes"
  52. go.disabled = "no"
  53. cm = s:option(Value, "create_mask", translate("Create mask"),
  54. translate("Mask for new files"))
  55. cm.rmempty = true
  56. cm.size = 4
  57. dm = s:option(Value, "dir_mask", translate("Directory mask"),
  58. translate("Mask for new directories"))
  59. dm.rmempty = true
  60. dm.size = 4
  61. return m