6cf9f3edae4906be100d997283d0b0ed5672d2ca
4 'require tools.widgets as widgets';
9 L
.resolveDefault(fs
.stat('/sbin/block'), null),
10 L
.resolveDefault(fs
.stat('/etc/config/fstab'), null),
11 L
.resolveDefault(fs
.exec('/usr/sbin/ksmbd.mountd', ['-V']), {}).then(function(res
) { return L
.toArray((res
.stdout
|| '').match(/version
: (\S
+)/))[1] }),
12 L
.resolveDefault(fs
.exec('/sbin/modinfo', ['ksmbd']), {}).then(function(res
) { return L
.toArray((res
.stdout
|| '').match(/version:\t(\S+)/))[1] }),
15 render: function(stats
) {
19 m
= new form
.Map('ksmbd', _('Network Shares'));
25 v
= v
+ ' Kmod: ' + stats
[3].trim();
27 s
= m
.section(form
.TypedSection
, 'globals', 'Ksmbd: ' + v
);
30 s
.tab('general', _('General Settings'));
31 s
.tab('template', _('Edit Template'));
33 s
.taboption('general', widgets
.NetworkSelect
, 'interface', _('Interface'),
34 _('Listen only on the given interface or, if unspecified, on lan'));
36 o
= s
.taboption('general', form
.Value
, 'workgroup', _('Workgroup'));
37 o
.placeholder
= 'WORKGROUP';
39 o
= s
.taboption('general', form
.Value
, 'description', _('Description'));
40 o
.placeholder
= 'Ksmbd on OpenWrt';
42 o
= s
.taboption('general', form
.Flag
, 'allow_legacy_protocols', _('Allow legacy (insecure) protocols/authentication.'),
43 _('Allow legacy smb(v1)/Lanman connections, needed for older devices without smb(v2.1/3) support.'));
45 o
= s
.taboption('template', form
.TextValue
, '_tmpl',
46 _('Edit the template that is used for generating the ksmbd configuration.'),
47 _("This is the content of the file '/etc/ksmbd/smb.conf.template' from which your ksmbd configuration will be generated. \
48 Values enclosed by pipe symbols ('|') should not be changed. They get their values from the 'General Settings' tab."));
50 o
.cfgvalue = function(section_id
) {
51 return fs
.trimmed('/etc/ksmbd/smb.conf.template');
53 o
.write = function(section_id
, formvalue
) {
54 return fs
.write('/etc/ksmbd/smb.conf.template', formvalue
.trim().replace(/\r\n/g
, '\n') + '\n');
58 s
= m
.section(form
.TableSection
, 'share', _('Shared Directories'),
59 _('Please add directories to share. Each directory refers to a folder on a mounted device.'));
63 s
.option(form
.Value
, 'name', _('Name'));
64 o
= s
.option(form
.Value
, 'path', _('Path'));
65 if (stats
[0] && stats
[1]) {
66 o
.titleref
= L
.url('admin', 'system', 'mounts');
69 o
= s
.option(form
.Flag
, 'browseable', _('Browse-able'));
74 o
= s
.option(form
.Flag
, 'read_only', _('Read-only'));
77 o
.default = 'no'; // smb.conf default is 'yes'
80 s
.option(form
.Flag
, 'force_root', _('Force Root'));
82 o
= s
.option(form
.Value
, 'users', _('Allowed users'));
85 o
= s
.option(form
.Flag
, 'guest_ok', _('Allow guests'));
88 o
.default = 'yes'; // smb.conf default is 'no'
91 o
= s
.option(form
.Flag
, 'inherit_owner', _('Inherit owner'));
96 o
= s
.option(form
.Flag
, 'hide_dot_files', _('Hide dot files'));
101 o
= s
.option(form
.Value
, 'create_mask', _('Create mask'));
103 o
.default = '0666'; // smb.conf default is '0744'
104 o
.placeholder
= '0666';
107 o
= s
.option(form
.Value
, 'dir_mask', _('Directory mask'));
109 o
.default = '0777'; // smb.conf default is '0755'
110 o
.placeholder
= '0777';