samba.lua 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. s:taboption("general", Value, "homes", translate("Share home-directories"),
  13. translate("Allow system users to reach their home directories via " ..
  14. "network shares"))
  15. tmpl = s:taboption("template", Value, "_tmpl",
  16. translate("Edit the template that is used for generating the samba configuration."),
  17. translate("This is the content of the file '/etc/samba/smb.conf.template' from which your samba configuration will be generated. " ..
  18. "Values enclosed by pipe symbols ('|') should not be changed. They get their values from the 'General Settings' tab."))
  19. tmpl.template = "cbi/tvalue"
  20. tmpl.rows = 20
  21. function tmpl.cfgvalue(self, section)
  22. return nixio.fs.readfile("/etc/samba/smb.conf.template")
  23. end
  24. function tmpl.write(self, section, value)
  25. value = value:gsub("\r\n?", "\n")
  26. nixio.fs.writefile("//etc/samba/smb.conf.template", value)
  27. end
  28. s = m:section(TypedSection, "sambashare", translate("Shared Directories"))
  29. s.anonymous = true
  30. s.addremove = true
  31. s.template = "cbi/tblsection"
  32. s:option(Value, "name", translate("Name"))
  33. pth = s:option(Value, "path", translate("Path"))
  34. if nixio.fs.access("/etc/config/fstab") then
  35. pth.titleref = luci.dispatcher.build_url("admin", "system", "fstab")
  36. end
  37. s:option(Value, "users", translate("Allowed users")).rmempty = true
  38. ro = s:option(Flag, "read_only", translate("Read-only"))
  39. ro.rmempty = false
  40. ro.enabled = "yes"
  41. ro.disabled = "no"
  42. go = s:option(Flag, "guest_ok", translate("Allow guests"))
  43. go.rmempty = false
  44. go.enabled = "yes"
  45. go.disabled = "no"
  46. cm = s:option(Value, "create_mask", translate("Create mask"),
  47. translate("Mask for new files"))
  48. cm.rmempty = true
  49. cm.size = 4
  50. dm = s:option(Value, "dir_mask", translate("Directory mask"),
  51. translate("Mask for new directories"))
  52. dm.rmempty = true
  53. dm.size = 4
  54. return m