From 707701df743e2d17b54a947aed8053f22ed98c53 Mon Sep 17 00:00:00 2001 From: Manuel Munz Date: Wed, 13 Apr 2011 15:14:42 +0000 Subject: applications/luci-samba: Add textbox to edit the template for config generation (#122) --- applications/luci-samba/luasrc/model/cbi/samba.lua | 28 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'applications/luci-samba') diff --git a/applications/luci-samba/luasrc/model/cbi/samba.lua b/applications/luci-samba/luasrc/model/cbi/samba.lua index b73c29e07d..91526374a4 100644 --- a/applications/luci-samba/luasrc/model/cbi/samba.lua +++ b/applications/luci-samba/luasrc/model/cbi/samba.lua @@ -18,13 +18,33 @@ m = Map("samba", translate("Network Shares")) s = m:section(TypedSection, "samba", "Samba") s.anonymous = true -s:option(Value, "name", translate("Hostname")) -s:option(Value, "description", translate("Description")) -s:option(Value, "workgroup", translate("Workgroup")) -s:option(Flag, "homes", translate("Share home-directories"), +s:tab("general", translate("General Settings")) +s:tab("template", translate("Edit Template")) + +s:taboption("general", Value, "name", translate("Hostname")) +s:taboption("general", Value, "description", translate("Description")) +s:taboption("general", Value, "workgroup", translate("Workgroup")) +s:taboption("general", Value, "homes", translate("Share home-directories"), translate("Allow system users to reach their home directories via " .. "network shares")) +tmpl = s:taboption("template", Value, "_tmpl", + translate("Edit the template that is used for generating the samba configuration."), + translate("This is the content of the file '/etc/samba/smb.conf.template' from which your samba configuration will be generated. " .. + "Values enclosed by pipe symbols ('|') should not be changed. They get their values from the 'General Settings' tab.")) + +tmpl.template = "cbi/tvalue" +tmpl.rows = 20 + +function tmpl.cfgvalue(self, section) + return nixio.fs.readfile("/etc/samba/smb.conf.template") +end + +function tmpl.write(self, section, value) + value = value:gsub("\r\n?", "\n") + nixio.fs.writefile("//etc/samba/smb.conf.template", value) +end + s = m:section(TypedSection, "sambashare", translate("Shared Directories")) s.anonymous = true -- cgit v1.2.3