Merge pull request #2043 from Ansuel/materialfix
[project/luci.git] / applications / luci-app-samba4 / luasrc / model / cbi / samba4.lua
1 -- Licensed to the public under the Apache License 2.0.
2
3 m = Map("samba4", translate("Network Shares"))
4
5 s = m:section(TypedSection, "samba", "Samba")
6 s.anonymous = true
7
8 s:tab("general", translate("General Settings"))
9 s:tab("template", translate("Edit Template"))
10
11 s:taboption("general", Value, "name", translate("Hostname"))
12 s:taboption("general", Value, "description", translate("Description"))
13 s:taboption("general", Value, "workgroup", translate("Workgroup"))
14 h = s:taboption("general", Flag, "homes", translate("Share home-directories"),
15 translate("Allow system users to reach their home directories via " ..
16 "network shares"))
17 h.rmempty = false
18 s:taboption("general", Flag, "disable_netbios", translate("Disable Netbios"))
19 s:taboption("general", Flag, "disable_ad_dc", translate("Disable Active Directory Domain Controller"))
20 s:taboption("general", Flag, "disable_winbind", translate("Disable Winbind"))
21
22 tmpl = s:taboption("template", Value, "_tmpl",
23 translate("Edit the template that is used for generating the samba configuration."),
24 translate("This is the content of the file '/etc/samba/smb.conf.template' from which your samba configuration will be generated. " ..
25 "Values enclosed by pipe symbols ('|') should not be changed. They get their values from the 'General Settings' tab."))
26
27 tmpl.template = "cbi/tvalue"
28 tmpl.rows = 20
29
30 function tmpl.cfgvalue(self, section)
31 return nixio.fs.readfile("/etc/samba/smb.conf.template")
32 end
33
34 function tmpl.write(self, section, value)
35 value = value:gsub("\r\n?", "\n")
36 nixio.fs.writefile("/etc/samba/smb.conf.template", value)
37 end
38
39
40 s = m:section(TypedSection, "sambashare", translate("Shared Directories")
41 , translate("Please add directories to share. Each directory refers to a folder on a mounted device."))
42 s.anonymous = true
43 s.addremove = true
44 s.template = "cbi/tblsection"
45
46 s:option(Value, "name", translate("Name"))
47 pth = s:option(Value, "path", translate("Path"))
48 if nixio.fs.access("/etc/config/fstab") then
49 pth.titleref = luci.dispatcher.build_url("admin", "system", "fstab")
50 end
51
52 s:option(Value, "users", translate("Allowed users")).rmempty = true
53
54 ro = s:option(Flag, "read_only", translate("Read-only"))
55 ro.rmempty = false
56 ro.enabled = "yes"
57 ro.disabled = "no"
58
59 br = s:option(Flag, "browseable", translate("Browseable"))
60 br.rmempty = false
61 br.default = "yes"
62 br.enabled = "yes"
63 br.disabled = "no"
64
65 go = s:option(Flag, "guest_ok", translate("Allow guests"))
66 go.rmempty = false
67 go.enabled = "yes"
68 go.disabled = "no"
69
70 gon = s:option(Flag, "guest_only", translate("Guests only"))
71 gon.rmempty = false
72 gon.enabled = "yes"
73 gon.disabled = "no"
74
75 io = s:option(Flag, "inherit_owner", translate("Inherit owner"))
76 io.rmempty = false
77 io.enabled = "yes"
78 io.disabled = "no"
79
80 cm = s:option(Value, "create_mask", translate("Create mask"))
81 cm.rmempty = true
82 cm.size = 4
83
84 dm = s:option(Value, "dir_mask", translate("Directory mask"))
85 dm.rmempty = true
86 dm.size = 4
87
88 s:option(Value, "vfs_objects", translate("Vfs objects")).rmempty = true
89
90 return m