[openwrt/openwrt] netifd: read udhcpc user scripts from directory

LEDE Commits lede-commits at lists.infradead.org
Sat Apr 17 20:13:52 BST 2021


dedeckeh pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/467c32600cc575fcb67c5f01ad32e02141220ceb

commit 467c32600cc575fcb67c5f01ad32e02141220ceb
Author: Leon M. George <leon at georgemail.eu>
AuthorDate: Tue Mar 23 11:02:36 2021 +0100

    netifd: read udhcpc user scripts from directory
    
    Placeholder DHCP user scripts were added recently.
    
    These files make package-based installations of such scripts more difficult.
    Pull user callbacks from directories instead to allow packages and users to
    install co-existing scripts more easily.
    
    References:
    130118f7a netifd: add a udhcpc.user placeholder script
    
    Signed-off-by: Leon M. George <leon at georgemail.eu>
    Signed-off-by: Hans Dedecker <dedeckeh at gmail.com> [PKG_RELEASE increase]
---
 package/network/config/netifd/Makefile                     | 4 +++-
 package/network/config/netifd/files/lib/netifd/dhcp.script | 3 +++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/package/network/config/netifd/Makefile b/package/network/config/netifd/Makefile
index e4720aa821..7d916b6939 100644
--- a/package/network/config/netifd/Makefile
+++ b/package/network/config/netifd/Makefile
@@ -1,7 +1,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=netifd
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=$(PROJECT_GIT)/project/netifd.git
@@ -27,6 +27,7 @@ endef
 
 define Package/netifd/conffiles
 /etc/udhcpc.user
+/etc/udhcpc.user.d/
 endef
 
 TARGET_CFLAGS += \
@@ -44,6 +45,7 @@ define Package/netifd/install
 	$(INSTALL_DIR) $(1)/sbin
 	$(INSTALL_BIN) $(PKG_BUILD_DIR)/netifd $(1)/sbin/
 	$(CP) ./files/* $(1)/
+	$(INSTALL_DIR) $(1)/etc/udhcpc.user.d/
 	$(CP) $(PKG_BUILD_DIR)/scripts/* $(1)/lib/netifd/
 endef
 
diff --git a/package/network/config/netifd/files/lib/netifd/dhcp.script b/package/network/config/netifd/files/lib/netifd/dhcp.script
index 6585b641d6..e46005d84c 100755
--- a/package/network/config/netifd/files/lib/netifd/dhcp.script
+++ b/package/network/config/netifd/files/lib/netifd/dhcp.script
@@ -112,5 +112,8 @@ esac
 
 # user rules
 [ -f /etc/udhcpc.user ] && . /etc/udhcpc.user "$@"
+for f in /etc/udhcpc.user.d/*; do
+	[ -f "$f" ] && (. "$f" "$@")
+done
 
 exit 0



More information about the lede-commits mailing list