parent
ae48c01089
commit
9b593a88b0
18
package/lean/luci-app-nfs/Makefile
Normal file
18
package/lean/luci-app-nfs/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 support for nfs
|
||||
LUCI_DEPENDS:=
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_NAME:=luci-app-nfs
|
||||
PKG_VERSION:=1.0
|
||||
PKG_RELEASE:=1
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
|
8
package/lean/luci-app-nfs/luasrc/controller/nfs.lua
Normal file
8
package/lean/luci-app-nfs/luasrc/controller/nfs.lua
Normal file
@ -0,0 +1,8 @@
|
||||
module("luci.controller.nfs", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/nfs") then
|
||||
return
|
||||
end
|
||||
entry({"admin", "nas", "nfs"}, cbi("nfs"), _("NFS Manage"), 5).dependent = true
|
||||
end
|
65
package/lean/luci-app-nfs/luasrc/model/cbi/nfs.lua
Normal file
65
package/lean/luci-app-nfs/luasrc/model/cbi/nfs.lua
Normal file
@ -0,0 +1,65 @@
|
||||
local fs = require "nixio.fs"
|
||||
|
||||
m = Map("nfs", translate("NFS Manage"))
|
||||
|
||||
-- NFS Share --
|
||||
s = m:section(TypedSection, "share", translate("Shared Directories"))
|
||||
s.anonymous = true
|
||||
s.addremove = true
|
||||
s.template = "cbi/tblsection"
|
||||
|
||||
en = s:option(Flag, "enabled", translate("Enable"))
|
||||
en.rmempty = false
|
||||
en.default = "1"
|
||||
|
||||
ph1 = s:option(Value, "path", translate("Path"))
|
||||
ph1.placeholder = "/mnt"
|
||||
ph1.rmempty = false
|
||||
ph1.optional = false
|
||||
|
||||
ct = s:option(Value, "clients", translate("Clients"))
|
||||
ct.placeholder = "192.168.1.0/24"
|
||||
ct.rmempty = false
|
||||
ct.optional = false
|
||||
|
||||
op = s:option(Value, "options", translate("options"))
|
||||
op.placeholder = "rw,sync,root_squash,all_squash,insecure,no_subtree_check"
|
||||
op.rmempty = false
|
||||
op.optional = false
|
||||
|
||||
-- NFS Mount --
|
||||
c = m:section(TypedSection, "mount", translate("Mounted Points"))
|
||||
c.anonymous = true
|
||||
c.addremove = true
|
||||
c.template = "cbi/tblsection"
|
||||
|
||||
en = c:option(Flag, "enabled", translate("Enable"))
|
||||
en.default = "1"
|
||||
en.rmempty = false
|
||||
|
||||
sr = c:option(Value, "source", translate("source"))
|
||||
sr.placeholder = "192.168.1.1:/mnt/*"
|
||||
sr.rmempty = false
|
||||
sr.optional = false
|
||||
|
||||
ph2 = c:option(Value, "target", translate("target"))
|
||||
ph2.placeholder = "/mnt/nfs/*"
|
||||
ph2.rmempty = false
|
||||
ph2.optional = false
|
||||
|
||||
op = c:option(Value, "options", translate("options"))
|
||||
op.placeholder = "rw,nolock"
|
||||
op.rmempty = false
|
||||
op.optional = false
|
||||
|
||||
de = c:option(Value, "delay", translate("delay"))
|
||||
de.placeholder = "5"
|
||||
de.rmempty = false
|
||||
de.optional = false
|
||||
|
||||
if nixio.fs.access("/etc/config/fstab") then
|
||||
ph1.titleref = luci.dispatcher.build_url("admin", "system", "mounts")
|
||||
ph2.titleref = luci.dispatcher.build_url("admin", "system", "mounts")
|
||||
end
|
||||
|
||||
return m
|
44
package/lean/luci-app-nfs/po/zh_Hans/nfs.po
Normal file
44
package/lean/luci-app-nfs/po/zh_Hans/nfs.po
Normal file
@ -0,0 +1,44 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: \n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-03-1\n"
|
||||
"PO-Revision-Date: 2016-03-1 21:36+0800\n"
|
||||
"Last-Translator: leenchan\n"
|
||||
"Language: zh_CN\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"Language-Team: \n"
|
||||
"X-Generator: Poedit 1.8.1\n"
|
||||
|
||||
msgid "NFS Manage"
|
||||
msgstr "NFS 管理"
|
||||
|
||||
msgid "Shared Directories"
|
||||
msgstr "共享目录"
|
||||
|
||||
msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "Path"
|
||||
msgstr "路径"
|
||||
|
||||
msgid "Clients"
|
||||
msgstr "允许的客户端"
|
||||
|
||||
msgid "Mounted Points"
|
||||
msgstr "已挂载的目录"
|
||||
|
||||
msgid "source"
|
||||
msgstr "源目录"
|
||||
|
||||
msgid "target"
|
||||
msgstr "挂载到"
|
||||
|
||||
msgid "options"
|
||||
msgstr "选项"
|
||||
|
||||
msgid "delay"
|
||||
msgstr "延迟时间"
|
BIN
package/lean/luci-app-nfs/po/zh_Hans/nfs.zh-cn.lmo
Normal file
BIN
package/lean/luci-app-nfs/po/zh_Hans/nfs.zh-cn.lmo
Normal file
Binary file not shown.
6
package/lean/luci-app-nfs/root/etc/config/nfs
Normal file
6
package/lean/luci-app-nfs/root/etc/config/nfs
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
config share
|
||||
option enabled '0'
|
||||
option path '/mnt'
|
||||
option clients '*'
|
||||
option options 'rw,sync,root_squash,all_squash,insecure,no_subtree_check'
|
86
package/lean/luci-app-nfs/root/etc/init.d/nfs
Normal file
86
package/lean/luci-app-nfs/root/etc/init.d/nfs
Normal file
@ -0,0 +1,86 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
START=45
|
||||
STOP=99
|
||||
NAME="nfs"
|
||||
|
||||
nfs_share() {
|
||||
local config="$1"
|
||||
local enabled
|
||||
local path
|
||||
local clients
|
||||
local options
|
||||
|
||||
config_get_bool enabled "$config" enabled 0
|
||||
|
||||
for opt in path clients options
|
||||
do
|
||||
config_get "$opt" "$config" "$opt"
|
||||
done
|
||||
|
||||
if [ "$enabled" = 1 ]; then
|
||||
grep -qs $path /etc/exports
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "$path\t$clients($options)" >>/etc/exports
|
||||
exportfs -r
|
||||
fi
|
||||
elif [ "$enabled" = 0 ]; then
|
||||
exportfs -u | grep -qs $path
|
||||
if [ $? -eq 0 ]; then
|
||||
exportfs -u $clients:$path
|
||||
fi
|
||||
fi
|
||||
exportfs -r
|
||||
}
|
||||
|
||||
nfs_share_stop() {
|
||||
exportfs -au &>/dev/null
|
||||
}
|
||||
|
||||
nfs_mount() {
|
||||
local config="$1"
|
||||
local enabled
|
||||
local target
|
||||
local source
|
||||
local options
|
||||
local delay
|
||||
|
||||
config_get_bool enabled "$config" enabled 0
|
||||
|
||||
for opt in target source options delay
|
||||
do
|
||||
config_get "$opt" "$config" "$opt"
|
||||
done
|
||||
|
||||
if [ "$enabled" = 1 ]; then
|
||||
if [ "$delay" -a $delay -gt 0 ]; then
|
||||
logger "NetMount: Sleep $delay seconds before mount"
|
||||
sleep $delay
|
||||
fi
|
||||
grep -qs $target /proc/mounts
|
||||
if [ $? -ne 0 ]; then
|
||||
mkdir -p $target
|
||||
logger "NetMount: Mounting $source in $target"
|
||||
mount -t nfs -o $options $source $target
|
||||
fi
|
||||
elif [ "$enabled" = 0 ]; then
|
||||
if grep -qs $target /proc/mounts; then
|
||||
umount -fr $target
|
||||
sleep $delay
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
config_load "$NAME"
|
||||
config_foreach nfs_share share
|
||||
config_foreach nfs_mount mount
|
||||
}
|
||||
|
||||
stop() {
|
||||
nfs_share_stop
|
||||
}
|
||||
|
||||
restart() {
|
||||
echo > /etc/exports
|
||||
start
|
||||
}
|
14
package/lean/luci-app-nfs/root/etc/uci-defaults/nfs
Normal file
14
package/lean/luci-app-nfs/root/etc/uci-defaults/nfs
Normal file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete ucitrack.@nfs[-1]
|
||||
add ucitrack nfs
|
||||
set ucitrack.@nfs[-1].init=nfs
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
/etc/init.d/nfs enable && /etc/init.d/nfs restart
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
|
||||
exit 0
|
Loading…
x
Reference in New Issue
Block a user