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