mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 04:13:31 +00:00
luci-app-cifs-mount: add SMB/CIFS mount luci
This commit is contained in:
parent
2a1f9e6fdf
commit
c3c418cdb7
18
package/lean/luci-app-cifs-mount/Makefile
Normal file
18
package/lean/luci-app-cifs-mount/Makefile
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
# Copyright (C) 2016 Openwrt.org
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI for SMB/CIFS Mount
|
||||
LUCI_DEPENDS:=+kmod-fs-cifs +kmod-nls-utf8
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_NAME:=luci-app-cifs-mount
|
||||
PKG_VERSION:=1
|
||||
PKG_RELEASE:=6
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
13
package/lean/luci-app-cifs-mount/luasrc/controller/cifs.lua
Normal file
13
package/lean/luci-app-cifs-mount/luasrc/controller/cifs.lua
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
module("luci.controller.cifs", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/cifs") then
|
||||
return
|
||||
end
|
||||
|
||||
local page
|
||||
|
||||
page = entry({"admin", "nas", "cifs"}, cbi("cifs"), _("Mount SMB NetShare"))
|
||||
page.dependent = true
|
||||
end
|
62
package/lean/luci-app-cifs-mount/luasrc/model/cbi/cifs.lua
Normal file
62
package/lean/luci-app-cifs-mount/luasrc/model/cbi/cifs.lua
Normal file
@ -0,0 +1,62 @@
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
m = Map("cifs", translate("Mount SMB/CIFS Netshare"), translate("Mount SMB/CIFS Netshare for OpenWrt"))
|
||||
|
||||
s = m:section(TypedSection, "cifs")
|
||||
s.anonymous = true
|
||||
|
||||
switch = s:option(Flag, "enabled", translate("Enable"))
|
||||
switch.rmempty = false
|
||||
|
||||
workgroup = s:option(Value, "workgroup", translate("Workgroup"))
|
||||
workgroup.default = "WORKGROUP"
|
||||
|
||||
s = m:section(TypedSection, "natshare", translate("CIFS/SMB Netshare"))
|
||||
s.anonymous = true
|
||||
s.addremove = true
|
||||
s.template = "cbi/tblsection"
|
||||
|
||||
server = s:option(Value, "server", translate("Server IP"))
|
||||
server.size = 12
|
||||
server.rmempty = false
|
||||
|
||||
name = s:option(Value, "name", translate("Share Folder"))
|
||||
name.rmempty = false
|
||||
name.size = 8
|
||||
|
||||
pth = s:option(Value, "natpath", translate("Mount Path"))
|
||||
if nixio.fs.access("/etc/config/fstab") then
|
||||
pth.titleref = luci.dispatcher.build_url("admin", "system", "fstab")
|
||||
end
|
||||
pth.rmempty = false
|
||||
pth.size = 10
|
||||
|
||||
smbver = s:option(Value, "smbver", translate("SMB Version"))
|
||||
smbver.rmempty = false
|
||||
smbver:value("1.0","SMB v1")
|
||||
smbver:value("2.0","SMB v2")
|
||||
smbver:value("3.0","SMB v3")
|
||||
smbver.default = "2.0"
|
||||
smbver.size = 3
|
||||
|
||||
agm = s:option(Value, "agm", translate("Arguments"))
|
||||
agm:value("ro", translate("Read Only"))
|
||||
agm:value("rw", translate("Read/Write"))
|
||||
agm.rmempty = true
|
||||
agm.default = "ro"
|
||||
|
||||
iocharset = s:option(Value, "iocharset", translate("Charset"))
|
||||
iocharset:value("utf8", "UTF8")
|
||||
iocharset.default = "utf8"
|
||||
iocharset.size = 2
|
||||
|
||||
users = s:option(Value, "users", translate("User"))
|
||||
users:value("guest", "Guest")
|
||||
users.rmempty = true
|
||||
users.default = "guest"
|
||||
|
||||
pwd = s:option(Value, "pwd", translate("Password"))
|
||||
pwd.rmempty = true
|
||||
pwd.size = 8
|
||||
|
||||
return m
|
42
package/lean/luci-app-cifs-mount/po/zh-cn/cifs.po
Normal file
42
package/lean/luci-app-cifs-mount/po/zh-cn/cifs.po
Normal file
@ -0,0 +1,42 @@
|
||||
msgid "Mount SMB NetShare"
|
||||
msgstr "挂载 SMB 网络共享"
|
||||
|
||||
msgid "Mount SMB/CIFS Netshare"
|
||||
msgstr "挂载 SMB/CIFS 网络共享文件夹"
|
||||
|
||||
msgid "Mount SMB/CIFS Netshare for OpenWrt"
|
||||
msgstr "可以将 SMB/CIFS 的共享文件夹挂载到本地(修改挂载后,需要重启使用这些文件夹的客户端)"
|
||||
|
||||
msgid "CIFS/SMB Netshare"
|
||||
msgstr "CIFS/SMB 文件夹共享挂载设置"
|
||||
|
||||
msgid "Server IP"
|
||||
msgstr "服务器IP"
|
||||
|
||||
msgid "Share Folder"
|
||||
msgstr "共享文件夹"
|
||||
|
||||
msgid "Mount Path"
|
||||
msgstr "挂载路径"
|
||||
|
||||
msgid "SMB Version"
|
||||
msgstr "SMB 版本"
|
||||
|
||||
msgid "Arguments"
|
||||
msgstr "挂载参数"
|
||||
|
||||
msgid "Charset"
|
||||
msgstr "字符集"
|
||||
|
||||
msgid "User"
|
||||
msgstr "用户名"
|
||||
|
||||
msgid "Password"
|
||||
msgstr "密码"
|
||||
|
||||
msgid "Read Only"
|
||||
msgstr "只读"
|
||||
|
||||
msgid "Read/Write"
|
||||
msgstr "可读/写"
|
||||
|
8
package/lean/luci-app-cifs-mount/root/etc/config/cifs
Normal file
8
package/lean/luci-app-cifs-mount/root/etc/config/cifs
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
config cifs
|
||||
option enabled '0'
|
||||
option workgroup 'WORKGROUP'
|
||||
option iocharset 'utf8'
|
||||
option delay '5'
|
||||
option mountarea '/mnt'
|
||||
|
67
package/lean/luci-app-cifs-mount/root/etc/init.d/cifs
Executable file
67
package/lean/luci-app-cifs-mount/root/etc/init.d/cifs
Executable file
@ -0,0 +1,67 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
START=45
|
||||
|
||||
ENABLED=0
|
||||
WORKGROUPD=0
|
||||
IOCHARSET=0
|
||||
GUEST=""
|
||||
USERS=""
|
||||
AGM=""
|
||||
|
||||
cifs_header() {
|
||||
local enabled
|
||||
local workgroup
|
||||
|
||||
config_get enabled $1 enabled
|
||||
config_get workgroup $1 workgroup
|
||||
|
||||
ENABLED=$enabled
|
||||
WORKGROUPD=$workgroup
|
||||
}
|
||||
|
||||
mount_natshare() {
|
||||
local server
|
||||
local name
|
||||
local natpath
|
||||
local guest
|
||||
local users
|
||||
local pwd
|
||||
local agm
|
||||
local iocharset
|
||||
local smbver
|
||||
|
||||
config_get server $1 server
|
||||
config_get name $1 name
|
||||
config_get natpath $1 natpath
|
||||
config_get guest $1 guest
|
||||
config_get users $1 users
|
||||
config_get pwd $1 pwd
|
||||
config_get agm $1 agm
|
||||
config_get iocharset $1 iocharset
|
||||
config_get smbver $1 smbver
|
||||
|
||||
mkdir -p $natpath && chmod 777 $natpath
|
||||
#echo "mount -t cifs -o vers=$smbver,user=$users,password=$pwd,iocharset=$iocharset,$agm //$server/$name $natpath"
|
||||
mount -t cifs -o vers=$smbver,user=$users,password=$pwd,iocharset=$iocharset,$agm //$server/$name $natpath
|
||||
}
|
||||
|
||||
start() {
|
||||
config_load cifs
|
||||
config_foreach cifs_header cifs
|
||||
|
||||
if [ $ENABLED == 1 ]
|
||||
then {
|
||||
config_foreach mount_natshare natshare
|
||||
#echo "Cifs Mount succeed."
|
||||
}
|
||||
fi
|
||||
}
|
||||
|
||||
stop() {
|
||||
mount | grep '//' | awk -F ' ' '{print$3}' | while read line; do
|
||||
#echo "umount -d -l $line"
|
||||
umount -d -l $line 2>/dev/null
|
||||
done
|
||||
}
|
||||
|
11
package/lean/luci-app-cifs-mount/root/etc/uci-defaults/cifs
Executable file
11
package/lean/luci-app-cifs-mount/root/etc/uci-defaults/cifs
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@cifs[-1]
|
||||
add ucitrack cifs
|
||||
set ucitrack.@cifs[-1].init=cifs
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
Loading…
Reference in New Issue
Block a user