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