diff options
6 files changed, 137 insertions, 8 deletions
diff --git a/applications/luci-app-cifsd/Makefile b/applications/luci-app-cifsd/Makefile new file mode 100644 index 0000000000..ef725a7050 --- /dev/null +++ b/applications/luci-app-cifsd/Makefile @@ -0,0 +1,10 @@ +# This is free software, licensed under the Apache License, Version 2.0 . + +include $(TOPDIR)/rules.mk + +LUCI_TITLE:=Network Shares - CIFSD CIFS/SMB kernel fileserver +LUCI_DEPENDS:=+cifsd-tools + +include ../../luci.mk + +# call BuildPackage - OpenWrt buildroot signature diff --git a/applications/luci-app-cifsd/htdocs/luci-static/resources/view/cifsd.js b/applications/luci-app-cifsd/htdocs/luci-static/resources/view/cifsd.js new file mode 100644 index 0000000000..de346c1db7 --- /dev/null +++ b/applications/luci-app-cifsd/htdocs/luci-static/resources/view/cifsd.js @@ -0,0 +1,96 @@ +'use strict'; +'require fs'; +'require form'; +'require tools.widgets as widgets'; + +return L.view.extend({ + load: function() { + return Promise.all([ + L.resolveDefault(fs.stat('/sbin/block'), null), + L.resolveDefault(fs.stat('/etc/config/fstab'), null), + ]); + }, + render: function(stats) { + var m, s, o; + + m = new form.Map('cifsd', _('Network Shares')); + + s = m.section(form.TypedSection, 'globals'); + s.anonymous = true; + + s.tab('general', _('General Settings')); + s.tab('template', _('Edit Template')); + + s.taboption('general', widgets.NetworkSelect, 'interface', _('Interface'), + _('Listen only on the given interface or, if unspecified, on lan')); + + o = s.taboption('general', form.Value, 'workgroup', _('Workgroup')); + o.placeholder = 'WORKGROUP'; + + o = s.taboption('general', form.Value, 'description', _('Description')); + o.placeholder = 'Cifsd on OpenWrt'; + + o = s.taboption('template', form.TextValue, '_tmpl', + _('Edit the template that is used for generating the samba configuration.'), + _("This is the content of the file '/etc/cifs/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.")); + o.rows = 20; + o.cfgvalue = function(section_id) { + return fs.trimmed('/etc/cifs/smb.conf.template'); + }; + o.write = function(section_id, formvalue) { + return fs.write('/etc/cifs/smb.conf.template', formvalue.trim().replace(/\r\n/g, '\n') + '\n'); + }; + + + s = m.section(form.TableSection, 'share', _('Shared Directories'), + _('Please add directories to share. Each directory refers to a folder on a mounted device.')); + s.anonymous = true; + s.addremove = true; + + s.option(form.Value, 'name', _('Name')); + o = s.option(form.Value, 'path', _('Path')); + if (stats[0] && stats[1]) { + o.titleref = L.url('admin', 'system', 'mounts'); + } + + o = s.option(form.Flag, 'browseable', _('Browse-able')); + o.enabled = 'yes'; + o.disabled = 'no'; + o.default = 'yes'; + + o = s.option(form.Flag, 'read_only', _('Read-only')); + o.enabled = 'yes'; + o.disabled = 'no'; + o.default = 'yes'; + + s.option(form.Flag, 'force_root', _('Force Root')); + + o = s.option(form.Value, 'users', _('Allowed users')); + o.rmempty = true; + + o = s.option(form.Flag, 'guest_ok', _('Allow guests')); + o.enabled = 'yes'; + o.disabled = 'no'; + o.default = 'no'; + + o = s.option(form.Flag, 'inherit_owner', _('Inherit owner')); + o.enabled = 'yes'; + o.disabled = 'no'; + o.default = 'no'; + + s.option(form.Flag, 'hide_dot_files', _('Hide dot files')); + + o = s.option(form.Value, 'create_mask', _('Create mask')); + o.rmempty = true; + o.maxlength = 4; + o.placeholder = '0666'; + + o = s.option(form.Value, 'dir_mask', _('Directory mask')); + o.rmempty = true; + o.maxlength = 4; + o.placeholder = '0777'; + + return m.render(); + } +}); diff --git a/applications/luci-app-cifsd/luasrc/controller/cifsd.lua b/applications/luci-app-cifsd/luasrc/controller/cifsd.lua new file mode 100644 index 0000000000..de3f9b0f92 --- /dev/null +++ b/applications/luci-app-cifsd/luasrc/controller/cifsd.lua @@ -0,0 +1,11 @@ +-- Licensed to the public under the Apache License 2.0. + +module("luci.controller.cifsd", package.seeall) + +function index() + if not nixio.fs.access("/etc/config/cifsd") then + return + end + + entry({"admin", "services", "cifsd"}, view("cifsd"), _("Network Shares")).dependent = true +end diff --git a/applications/luci-app-cifsd/root/usr/share/rpcd/acl.d/luci-app-cifsd.json b/applications/luci-app-cifsd/root/usr/share/rpcd/acl.d/luci-app-cifsd.json new file mode 100644 index 0000000000..6efebe98e1 --- /dev/null +++ b/applications/luci-app-cifsd/root/usr/share/rpcd/acl.d/luci-app-cifsd.json @@ -0,0 +1,15 @@ +{ + "luci-app-cifsd": { + "description": "Grant access to LuCI app cifsd", + "read": { + "file": { + "/etc/cifs/smb.conf.template": [ "read" ] + } + }, + "write": { + "file": { + "/etc/cifs/smb.conf.template": [ "write" ] + } + } + } +} diff --git a/modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json b/modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json index f811fb99ea..b3c4013782 100644 --- a/modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json +++ b/modules/luci-base/root/usr/share/rpcd/acl.d/luci-base.json @@ -36,7 +36,7 @@ "/proc/mtd": [ "read" ], "/proc/partitions": [ "read" ], "/proc/sys/kernel/hostname": [ "read" ], - "/sys/devices/virtual/ubi/*/name": [ "read" ] + "/proc/mounts": [ "read" ] }, "ubus": { "file": [ "list", "read", "stat" ], diff --git a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js index 61e021c28a..d18246b6be 100644 --- a/modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js +++ b/modules/luci-mod-system/htdocs/luci-static/resources/view/system/flash.js @@ -143,18 +143,14 @@ var mapdata = { actions: {}, config: {} }; return L.view.extend({ load: function() { - var max_ubi = 2, max_ubi_vol = 4; var tasks = [ L.resolveDefault(fs.stat('/lib/upgrade/platform.sh'), {}), fs.trimmed('/proc/sys/kernel/hostname'), fs.trimmed('/proc/mtd'), - fs.trimmed('/proc/partitions') + fs.trimmed('/proc/partitions'), + fs.trimmed('/proc/mounts') ]; - for (var i = 0; i < max_ubi; i++) - for (var j = 0; j < max_ubi_vol; j++) - tasks.push(fs.trimmed('/sys/devices/virtual/ubi/ubi%d/ubi%d_%d/name'.format(i, i, j))); - return Promise.all(tasks); }, @@ -428,7 +424,8 @@ return L.view.extend({ hostname = rpc_replies[1], procmtd = rpc_replies[2], procpart = rpc_replies[3], - has_rootfs_data = (procmtd.match(/"rootfs_data"/) != null) || rpc_replies.slice(4).filter(function(n) { return n == 'rootfs_data' })[0], + procmounts = rpc_replies[4], + has_rootfs_data = (procmtd.match(/"rootfs_data"/) != null) || (procmounts.match("overlayfs:\/overlay \/ ") != null), storage_size = findStorageSize(procmtd, procpart), m, s, o, ss; |