From 91be31e249cdd28f570c7c54570b1991ae609a9e Mon Sep 17 00:00:00 2001 From: CN_SZTL <22235437+1715173329@users.noreply.github.com> Date: Sun, 5 Apr 2020 18:31:37 +0800 Subject: [PATCH 1/3] mac80211: fix target name (#4176) --- package/kernel/mac80211/broadcom.mk | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/package/kernel/mac80211/broadcom.mk b/package/kernel/mac80211/broadcom.mk index 41320bcc12..0a6b1b6690 100644 --- a/package/kernel/mac80211/broadcom.mk +++ b/package/kernel/mac80211/broadcom.mk @@ -118,14 +118,14 @@ define KernelPackage/b43/config config PACKAGE_B43_USE_SSB select PACKAGE_kmod-ssb tristate - depends on !TARGET_bcm47xx && !TARGET_bcm63xx + depends on !TARGET_brcm47xx && !TARGET_brcm63xx default PACKAGE_kmod-b43 if PACKAGE_B43_BUSES_BCMA_AND_SSB default PACKAGE_kmod-b43 if PACKAGE_B43_BUSES_SSB config PACKAGE_B43_USE_BCMA select PACKAGE_kmod-bcma tristate - depends on !TARGET_bcm47xx && !TARGET_bcm53xx + depends on !TARGET_brcm47xx && !TARGET_bcm53xx default PACKAGE_kmod-b43 if PACKAGE_B43_BUSES_BCMA_AND_SSB default PACKAGE_kmod-b43 if PACKAGE_B43_BUSES_BCMA @@ -205,8 +205,8 @@ config PACKAGE_B43_USE_BCMA config B43_FW_SQUASH_COREREVS string "Core revisions to include" depends on B43_FW_SQUASH - default "5,6,7,8,9,10,11,13,15" if TARGET_bcm47xx_legacy - default "16,28,29,30" if TARGET_bcm47xx_mips74k + default "5,6,7,8,9,10,11,13,15" if TARGET_brcm47xx_legacy + default "16,28,29,30" if TARGET_brcm47xx_mips74k default "5,6,7,8,9,10,11,13,15,16,28,29,30" help This is a comma seperated list of core revision numbers. @@ -220,8 +220,8 @@ config PACKAGE_B43_USE_BCMA config B43_FW_SQUASH_PHYTYPES string "PHY types to include" depends on B43_FW_SQUASH - default "G,N,LP" if TARGET_bcm47xx_legacy - default "N,HT" if TARGET_bcm47xx_mips74k + default "G,N,LP" if TARGET_brcm47xx_legacy + default "N,HT" if TARGET_brcm47xx_mips74k default "G,N,LP,HT" help This is a comma seperated list of PHY types: @@ -248,15 +248,15 @@ config PACKAGE_B43_USE_BCMA This allows choosing buses that b43 should support. config PACKAGE_B43_BUSES_BCMA_AND_SSB - depends on !TARGET_bcm47xx_legacy && !TARGET_bcm47xx_mips74k && !TARGET_bcm53xx + depends on !TARGET_brcm47xx_legacy && !TARGET_brcm47xx_mips74k && !TARGET_bcm53xx bool "BCMA and SSB" config PACKAGE_B43_BUSES_BCMA - depends on !TARGET_bcm47xx_legacy + depends on !TARGET_brcm47xx_legacy bool "BCMA only" config PACKAGE_B43_BUSES_SSB - depends on !TARGET_bcm47xx_mips74k && !TARGET_bcm53xx + depends on !TARGET_brcm47xx_mips74k && !TARGET_bcm53xx bool "SSB only" endchoice @@ -281,7 +281,7 @@ config PACKAGE_B43_USE_BCMA config PACKAGE_B43_PHY_G bool "Enable support for G-PHYs" - default n if TARGET_bcm47xx_mips74k + default n if TARGET_brcm47xx_mips74k default y help Enable support for G-PHY. This includes support for the following devices: @@ -304,7 +304,7 @@ config PACKAGE_B43_USE_BCMA config PACKAGE_B43_PHY_LP bool "Enable support for LP-PHYs" - default n if TARGET_bcm47xx_mips74k + default n if TARGET_brcm47xx_mips74k default y help Enable support for LP-PHY. This includes support for the following devices: @@ -315,7 +315,7 @@ config PACKAGE_B43_USE_BCMA config PACKAGE_B43_PHY_HT bool "Enable support for HT-PHYs" - default n if TARGET_bcm47xx_legacy + default n if TARGET_brcm47xx_legacy default y help Enable support for HT-PHY. This includes support for the following devices: @@ -347,7 +347,7 @@ define KernelPackage/b43legacy URL:=https://wireless.wiki.kernel.org/en/users/drivers/b43 KCONFIG:= \ CONFIG_HW_RANDOM=y - DEPENDS+= +kmod-mac80211 +!(TARGET_bcm47xx||TARGET_bcm63xx):kmod-ssb @!TARGET_bcm47xx_mips74k +b43legacy-firmware + DEPENDS+= +kmod-mac80211 +!(TARGET_brcm47xx||TARGET_brcm63xx):kmod-ssb @!TARGET_brcm47xx_mips74k +b43legacy-firmware FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/broadcom/b43legacy/b43legacy.ko AUTOLOAD:=$(call AutoProbe,b43legacy) MENU:=1 @@ -401,7 +401,7 @@ define KernelPackage/brcmsmac $(call KernelPackage/mac80211/Default) TITLE:=Broadcom IEEE802.11n PCIe SoftMAC WLAN driver URL:=https://wireless.wiki.kernel.org/en/users/drivers/brcm80211 - DEPENDS+= +kmod-mac80211 +@DRIVER_11N_SUPPORT +!TARGET_bcm47xx:kmod-bcma +kmod-lib-cordic +kmod-lib-crc8 +kmod-brcmutil +!BRCMSMAC_USE_FW_FROM_WL:brcmsmac-firmware + DEPENDS+= +kmod-mac80211 +@DRIVER_11N_SUPPORT +!TARGET_brcm47xx:kmod-bcma +kmod-lib-cordic +kmod-lib-crc8 +kmod-brcmutil +!BRCMSMAC_USE_FW_FROM_WL:brcmsmac-firmware FILES:=$(PKG_BUILD_DIR)/drivers/net/wireless/broadcom/brcm80211/brcmsmac/brcmsmac.ko AUTOLOAD:=$(call AutoProbe,brcmsmac) MENU:=1 From 08637d8262f06b2a1661971d70c97d6fd440b87a Mon Sep 17 00:00:00 2001 From: AmadeusGhost <42570690+AmadeusGhost@users.noreply.github.com> Date: Sun, 5 Apr 2020 18:32:06 +0800 Subject: [PATCH 2/3] ar71xx: fix alloc_page_frag issue (#4184) cherry-pick from 819800ab4f90cf65dc62045a0f3d06cca57e437f --- ...c_page_frag-to-page_frag_alloc-and-_.patch | 137 ------------------ ..._frag-functions-to-__page_frag_cache.patch | 79 ---------- .../hack-4.9/202-reduce_module_size.patch | 24 --- .../640-bridge-only-accept-EAP-locally.patch | 59 +++++++- 4 files changed, 55 insertions(+), 244 deletions(-) delete mode 100644 target/linux/generic/backport-4.9/041-mm-rename-__alloc_page_frag-to-page_frag_alloc-and-_.patch delete mode 100644 target/linux/generic/backport-4.9/042-mm-rename-__page_frag-functions-to-__page_frag_cache.patch delete mode 100644 target/linux/generic/hack-4.9/202-reduce_module_size.patch diff --git a/target/linux/generic/backport-4.9/041-mm-rename-__alloc_page_frag-to-page_frag_alloc-and-_.patch b/target/linux/generic/backport-4.9/041-mm-rename-__alloc_page_frag-to-page_frag_alloc-and-_.patch deleted file mode 100644 index 03481d13c8..0000000000 --- a/target/linux/generic/backport-4.9/041-mm-rename-__alloc_page_frag-to-page_frag_alloc-and-_.patch +++ /dev/null @@ -1,137 +0,0 @@ -From: Alexander Duyck -Date: Tue, 10 Jan 2017 16:58:06 -0800 -Subject: [PATCH] mm: rename __alloc_page_frag to page_frag_alloc and - __free_page_frag to page_frag_free - -Patch series "Page fragment updates", v4. - -This patch series takes care of a few cleanups for the page fragments -API. - -First we do some renames so that things are much more consistent. First -we move the page_frag_ portion of the name to the front of the functions -names. Secondly we split out the cache specific functions from the -other page fragment functions by adding the word "cache" to the name. - -Finally I added a bit of documentation that will hopefully help to -explain some of this. I plan to revisit this later as we get things -more ironed out in the near future with the changes planned for the DMA -setup to support eXpress Data Path. - -This patch (of 3): - -This patch renames the page frag functions to be more consistent with -other APIs. Specifically we place the name page_frag first in the name -and then have either an alloc or free call name that we append as the -suffix. This makes it a bit clearer in terms of naming. - -In addition we drop the leading double underscores since we are -technically no longer a backing interface and instead the front end that -is called from the networking APIs. - -Link: http://lkml.kernel.org/r/20170104023854.13451.67390.stgit@localhost.localdomain -Signed-off-by: Alexander Duyck -Signed-off-by: Andrew Morton -Signed-off-by: Linus Torvalds ---- - ---- a/include/linux/gfp.h -+++ b/include/linux/gfp.h -@@ -531,9 +531,9 @@ extern void free_hot_cold_page_list(stru - struct page_frag_cache; - extern void __page_frag_drain(struct page *page, unsigned int order, - unsigned int count); --extern void *__alloc_page_frag(struct page_frag_cache *nc, -- unsigned int fragsz, gfp_t gfp_mask); --extern void __free_page_frag(void *addr); -+extern void *page_frag_alloc(struct page_frag_cache *nc, -+ unsigned int fragsz, gfp_t gfp_mask); -+extern void page_frag_free(void *addr); - - #define __free_page(page) __free_pages((page), 0) - #define free_page(addr) free_pages((addr), 0) ---- a/include/linux/skbuff.h -+++ b/include/linux/skbuff.h -@@ -2477,7 +2477,7 @@ static inline struct sk_buff *netdev_all - - static inline void skb_free_frag(void *addr) - { -- __free_page_frag(addr); -+ page_frag_free(addr); - } - - void *napi_alloc_frag(unsigned int fragsz); ---- a/mm/page_alloc.c -+++ b/mm/page_alloc.c -@@ -3949,8 +3949,8 @@ void __page_frag_drain(struct page *page - } - EXPORT_SYMBOL(__page_frag_drain); - --void *__alloc_page_frag(struct page_frag_cache *nc, -- unsigned int fragsz, gfp_t gfp_mask) -+void *page_frag_alloc(struct page_frag_cache *nc, -+ unsigned int fragsz, gfp_t gfp_mask) - { - unsigned int size = PAGE_SIZE; - struct page *page; -@@ -4001,19 +4001,19 @@ refill: - - return nc->va + offset; - } --EXPORT_SYMBOL(__alloc_page_frag); -+EXPORT_SYMBOL(page_frag_alloc); - - /* - * Frees a page fragment allocated out of either a compound or order 0 page. - */ --void __free_page_frag(void *addr) -+void page_frag_free(void *addr) - { - struct page *page = virt_to_head_page(addr); - - if (unlikely(put_page_testzero(page))) - __free_pages_ok(page, compound_order(page)); - } --EXPORT_SYMBOL(__free_page_frag); -+EXPORT_SYMBOL(page_frag_free); - - static void *make_alloc_exact(unsigned long addr, unsigned int order, - size_t size) ---- a/net/core/skbuff.c -+++ b/net/core/skbuff.c -@@ -369,7 +369,7 @@ static void *__netdev_alloc_frag(unsigne - - local_irq_save(flags); - nc = this_cpu_ptr(&netdev_alloc_cache); -- data = __alloc_page_frag(nc, fragsz, gfp_mask); -+ data = page_frag_alloc(nc, fragsz, gfp_mask); - local_irq_restore(flags); - return data; - } -@@ -393,7 +393,7 @@ static void *__napi_alloc_frag(unsigned - { - struct napi_alloc_cache *nc = this_cpu_ptr(&napi_alloc_cache); - -- return __alloc_page_frag(&nc->page, fragsz, gfp_mask); -+ return page_frag_alloc(&nc->page, fragsz, gfp_mask); - } - - void *napi_alloc_frag(unsigned int fragsz) -@@ -445,7 +445,7 @@ struct sk_buff *__netdev_alloc_skb(struc - local_irq_save(flags); - - nc = this_cpu_ptr(&netdev_alloc_cache); -- data = __alloc_page_frag(nc, len, gfp_mask); -+ data = page_frag_alloc(nc, len, gfp_mask); - pfmemalloc = nc->pfmemalloc; - - local_irq_restore(flags); -@@ -509,7 +509,7 @@ struct sk_buff *__napi_alloc_skb(struct - if (sk_memalloc_socks()) - gfp_mask |= __GFP_MEMALLOC; - -- data = __alloc_page_frag(&nc->page, len, gfp_mask); -+ data = page_frag_alloc(&nc->page, len, gfp_mask); - if (unlikely(!data)) - return NULL; - diff --git a/target/linux/generic/backport-4.9/042-mm-rename-__page_frag-functions-to-__page_frag_cache.patch b/target/linux/generic/backport-4.9/042-mm-rename-__page_frag-functions-to-__page_frag_cache.patch deleted file mode 100644 index cb2bdfc7ee..0000000000 --- a/target/linux/generic/backport-4.9/042-mm-rename-__page_frag-functions-to-__page_frag_cache.patch +++ /dev/null @@ -1,79 +0,0 @@ -From: Alexander Duyck -Date: Tue, 10 Jan 2017 16:58:09 -0800 -Subject: [PATCH] mm: rename __page_frag functions to __page_frag_cache, drop - order from drain - -This patch does two things. - -First it goes through and renames the __page_frag prefixed functions to -__page_frag_cache so that we can be clear that we are draining or -refilling the cache, not the frags themselves. - -Second we drop the order parameter from __page_frag_cache_drain since we -don't actually need to pass it since all fragments are either order 0 or -must be a compound page. - -Link: http://lkml.kernel.org/r/20170104023954.13451.5678.stgit@localhost.localdomain -Signed-off-by: Alexander Duyck -Signed-off-by: Andrew Morton -Signed-off-by: Linus Torvalds ---- - ---- a/include/linux/gfp.h -+++ b/include/linux/gfp.h -@@ -529,8 +529,7 @@ extern void free_hot_cold_page(struct pa - extern void free_hot_cold_page_list(struct list_head *list, bool cold); - - struct page_frag_cache; --extern void __page_frag_drain(struct page *page, unsigned int order, -- unsigned int count); -+extern void __page_frag_cache_drain(struct page *page, unsigned int count); - extern void *page_frag_alloc(struct page_frag_cache *nc, - unsigned int fragsz, gfp_t gfp_mask); - extern void page_frag_free(void *addr); ---- a/mm/page_alloc.c -+++ b/mm/page_alloc.c -@@ -3914,8 +3914,8 @@ EXPORT_SYMBOL(free_pages); - * drivers to provide a backing region of memory for use as either an - * sk_buff->head, or to be used in the "frags" portion of skb_shared_info. - */ --static struct page *__page_frag_refill(struct page_frag_cache *nc, -- gfp_t gfp_mask) -+static struct page *__page_frag_cache_refill(struct page_frag_cache *nc, -+ gfp_t gfp_mask) - { - struct page *page = NULL; - gfp_t gfp = gfp_mask; -@@ -3935,19 +3935,20 @@ static struct page *__page_frag_refill(s - return page; - } - --void __page_frag_drain(struct page *page, unsigned int order, -- unsigned int count) -+void __page_frag_cache_drain(struct page *page, unsigned int count) - { - VM_BUG_ON_PAGE(page_ref_count(page) == 0, page); - - if (page_ref_sub_and_test(page, count)) { -+ unsigned int order = compound_order(page); -+ - if (order == 0) - free_hot_cold_page(page, false); - else - __free_pages_ok(page, order); - } - } --EXPORT_SYMBOL(__page_frag_drain); -+EXPORT_SYMBOL(__page_frag_cache_drain); - - void *page_frag_alloc(struct page_frag_cache *nc, - unsigned int fragsz, gfp_t gfp_mask) -@@ -3958,7 +3959,7 @@ void *page_frag_alloc(struct page_frag_c - - if (unlikely(!nc->va)) { - refill: -- page = __page_frag_refill(nc, gfp_mask); -+ page = __page_frag_cache_refill(nc, gfp_mask); - if (!page) - return NULL; - diff --git a/target/linux/generic/hack-4.9/202-reduce_module_size.patch b/target/linux/generic/hack-4.9/202-reduce_module_size.patch deleted file mode 100644 index e486386777..0000000000 --- a/target/linux/generic/hack-4.9/202-reduce_module_size.patch +++ /dev/null @@ -1,24 +0,0 @@ -From fd66884da2f96d2a7ea73f58b1b86251b959a913 Mon Sep 17 00:00:00 2001 -From: Felix Fietkau -Date: Fri, 7 Jul 2017 16:56:19 +0200 -Subject: kernel: strip unnecessary symbol table information from kernel modules - -reduces default squashfs size on ar71xx by about 4k - -lede-commit: 058d331a39077f159ca8922f1f422a1346d6aa67 -Signed-off-by: Felix Fietkau ---- - Makefile | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - ---- a/Makefile -+++ b/Makefile -@@ -398,7 +398,7 @@ KBUILD_AFLAGS_KERNEL := - KBUILD_CFLAGS_KERNEL := - KBUILD_AFLAGS_MODULE := -DMODULE - KBUILD_CFLAGS_MODULE := -DMODULE --KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds -+KBUILD_LDFLAGS_MODULE = -T $(srctree)/scripts/module-common.lds $(if $(CONFIG_PROFILING),,-s) - GCC_PLUGINS_CFLAGS := - CLANG_FLAGS := - diff --git a/target/linux/generic/hack-4.9/640-bridge-only-accept-EAP-locally.patch b/target/linux/generic/hack-4.9/640-bridge-only-accept-EAP-locally.patch index ba87420b32..3a71f68b8b 100644 --- a/target/linux/generic/hack-4.9/640-bridge-only-accept-EAP-locally.patch +++ b/target/linux/generic/hack-4.9/640-bridge-only-accept-EAP-locally.patch @@ -7,9 +7,8 @@ When bridging, do not forward EAP frames to other ports, only deliver them locally, regardless of the state. Signed-off-by: Felix Fietkau ---- - net/bridge/br_input.c | 7 +++++-- - 1 file changed, 5 insertions(+), 2 deletions(-) +[add disable_eap_hack sysfs attribute] +Signed-off-by: Etienne Champetier --- a/net/bridge/br_input.c +++ b/net/bridge/br_input.c @@ -19,7 +18,7 @@ Signed-off-by: Felix Fietkau + BR_INPUT_SKB_CB(skb)->brdev = br->dev; + -+ if (skb->protocol == htons(ETH_P_PAE)) ++ if (skb->protocol == htons(ETH_P_PAE) && !br->disable_eap_hack) + return br_pass_frame_up(skb); + if (p->state == BR_STATE_LEARNING) @@ -30,3 +29,55 @@ Signed-off-by: Felix Fietkau if (IS_ENABLED(CONFIG_INET) && skb->protocol == htons(ETH_P_ARP)) br_do_proxy_arp(skb, br, vid, p); +--- a/net/bridge/br_private.h ++++ b/net/bridge/br_private.h +@@ -295,6 +295,8 @@ struct net_bridge + u16 group_fwd_mask; + u16 group_fwd_mask_required; + ++ bool disable_eap_hack; ++ + /* STP */ + bridge_id designated_root; + bridge_id bridge_id; +--- a/net/bridge/br_sysfs_br.c ++++ b/net/bridge/br_sysfs_br.c +@@ -169,6 +169,30 @@ static ssize_t group_fwd_mask_store(stru + } + static DEVICE_ATTR_RW(group_fwd_mask); + ++static ssize_t disable_eap_hack_show(struct device *d, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct net_bridge *br = to_bridge(d); ++ return sprintf(buf, "%u\n", br->disable_eap_hack); ++} ++ ++static int set_disable_eap_hack(struct net_bridge *br, unsigned long val) ++{ ++ br->disable_eap_hack = !!val; ++ ++ return 0; ++} ++ ++static ssize_t disable_eap_hack_store(struct device *d, ++ struct device_attribute *attr, ++ const char *buf, ++ size_t len) ++{ ++ return store_bridge_parm(d, buf, len, set_disable_eap_hack); ++} ++static DEVICE_ATTR_RW(disable_eap_hack); ++ + static ssize_t priority_show(struct device *d, struct device_attribute *attr, + char *buf) + { +@@ -780,6 +804,7 @@ static struct attribute *bridge_attrs[] + &dev_attr_ageing_time.attr, + &dev_attr_stp_state.attr, + &dev_attr_group_fwd_mask.attr, ++ &dev_attr_disable_eap_hack.attr, + &dev_attr_priority.attr, + &dev_attr_bridge_id.attr, + &dev_attr_root_id.attr, From 5e9e8d8536f1c4d5c7041f5c676227172557d1aa Mon Sep 17 00:00:00 2001 From: Aes64X <47932152+Aes64X@users.noreply.github.com> Date: Sun, 5 Apr 2020 18:34:14 +0800 Subject: [PATCH 3/3] =?UTF-8?q?package=EF=BC=9Aadd=20nfs=20mount=20luci=20?= =?UTF-8?q?(#4171)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package/lean/luci-app-nfs/Makefile | 17 +++++ .../luci-app-nfs/luasrc/controller/nfs.lua | 8 ++ .../luci-app-nfs/luasrc/model/cbi/nfs.lua | 70 +++++++++++++++++ package/lean/luci-app-nfs/po/zh-cn/nfs.po | 32 ++++++++ package/lean/luci-app-nfs/root/etc/config/nfs | 6 ++ package/lean/luci-app-nfs/root/etc/init.d/nfs | 75 +++++++++++++++++++ .../luci-app-nfs/root/etc/uci-defaults/nfs | 14 ++++ 7 files changed, 222 insertions(+) create mode 100644 package/lean/luci-app-nfs/Makefile create mode 100644 package/lean/luci-app-nfs/luasrc/controller/nfs.lua create mode 100644 package/lean/luci-app-nfs/luasrc/model/cbi/nfs.lua create mode 100644 package/lean/luci-app-nfs/po/zh-cn/nfs.po create mode 100644 package/lean/luci-app-nfs/root/etc/config/nfs create mode 100755 package/lean/luci-app-nfs/root/etc/init.d/nfs create mode 100644 package/lean/luci-app-nfs/root/etc/uci-defaults/nfs diff --git a/package/lean/luci-app-nfs/Makefile b/package/lean/luci-app-nfs/Makefile new file mode 100644 index 0000000000..e834be11d4 --- /dev/null +++ b/package/lean/luci-app-nfs/Makefile @@ -0,0 +1,17 @@ +# 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:=+nfs-utils +nfs-kernel-server +nfs-kernel-server-utils +mount-utils +LUCI_PKGARCH:=all +PKG_VERSION:=1.1 +PKG_RELEASE:=1 + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature + diff --git a/package/lean/luci-app-nfs/luasrc/controller/nfs.lua b/package/lean/luci-app-nfs/luasrc/controller/nfs.lua new file mode 100644 index 0000000000..9807fb2130 --- /dev/null +++ b/package/lean/luci-app-nfs/luasrc/controller/nfs.lua @@ -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 diff --git a/package/lean/luci-app-nfs/luasrc/model/cbi/nfs.lua b/package/lean/luci-app-nfs/luasrc/model/cbi/nfs.lua new file mode 100644 index 0000000000..8559298ae5 --- /dev/null +++ b/package/lean/luci-app-nfs/luasrc/model/cbi/nfs.lua @@ -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 diff --git a/package/lean/luci-app-nfs/po/zh-cn/nfs.po b/package/lean/luci-app-nfs/po/zh-cn/nfs.po new file mode 100644 index 0000000000..e35c2e8d5e --- /dev/null +++ b/package/lean/luci-app-nfs/po/zh-cn/nfs.po @@ -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 "延迟时间" diff --git a/package/lean/luci-app-nfs/root/etc/config/nfs b/package/lean/luci-app-nfs/root/etc/config/nfs new file mode 100644 index 0000000000..7395846563 --- /dev/null +++ b/package/lean/luci-app-nfs/root/etc/config/nfs @@ -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' diff --git a/package/lean/luci-app-nfs/root/etc/init.d/nfs b/package/lean/luci-app-nfs/root/etc/init.d/nfs new file mode 100755 index 0000000000..889d121940 --- /dev/null +++ b/package/lean/luci-app-nfs/root/etc/init.d/nfs @@ -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 +} diff --git a/package/lean/luci-app-nfs/root/etc/uci-defaults/nfs b/package/lean/luci-app-nfs/root/etc/uci-defaults/nfs new file mode 100644 index 0000000000..f7aa1397be --- /dev/null +++ b/package/lean/luci-app-nfs/root/etc/uci-defaults/nfs @@ -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