🌴 Sync 2026-03-05 23:51:42

This commit is contained in:
github-actions[bot] committed 2026-03-05 23:51:42 +08:00
1 parent 97c049ed0a
commit 0acff03804
14253 files changed
+3893239

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
# 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-compat +nfs-utils +nfs-kernel-server +nfs-kernel-server-utils +mount-utils
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature
+10
View File
@@ -0,0 +1,10 @@
module("luci.controller.nfs", package.seeall)
function index()
if not nixio.fs.access("/etc/config/nfs") then
return
end
local page = entry({"admin", "nas", "nfs"}, cbi("nfs"), _("NFS Manage"), 5)
page.dependent = true
page.acl_depends = { "luci-app-nfs" }
end
+70
View File
@@ -0,0 +1,70 @@
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
local apply = luci.http.formvalue("cbi.apply")
if apply then
io.popen("/etc/init.d/nfs reload")
end
return m
+1
View File
@@ -0,0 +1 @@
zh_Hans
+32
View File
@@ -0,0 +1,32 @@
msgid ""
msgstr ""
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 "延迟时间"
+6
View 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'
+75
View File
@@ -0,0 +1,75 @@
#!/bin/sh /etc/rc.common
START=45
STOP=99
NAME="nfs"
nfs_share() {
local enabled path clients options
config_get_bool enabled "$1" enabled 0
for opt in path clients options
do
config_get "$opt" "$1" "$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 enabled target source options delay
config_get_bool enabled "$1" enabled 0
for opt in target source options delay
do
config_get "$opt" "$1" "$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
}
@@ -0,0 +1,11 @@
{
"luci-app-nfs": {
"description": "Grant UCI access for luci-app-nfs",
"read": {
"uci": [ "nfs" ]
},
"write": {
"uci": [ "nfs" ]
}
}
}
@@ -0,0 +1,4 @@
{
"config": "nfs",
"init": "nfs"
}