netifd: read udhcpc user scripts from directory
authorLeon M. George <leon@georgemail.eu>
Tue, 23 Mar 2021 10:02:36 +0000 (11:02 +0100)
committerRafał Miłecki <rafal@milecki.pl>
Wed, 26 May 2021 06:32:54 +0000 (08:32 +0200)
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@georgemail.eu>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com> [PKG_RELEASE increase]
(cherry picked from commit 467c32600cc575fcb67c5f01ad32e02141220ceb)

package/network/config/netifd/Makefile
package/network/config/netifd/files/lib/netifd/dhcp.script

index e4720aa821520de031725bcf130f9e8e187a34fc..7d916b69392fcedff21f39c6920bf2d2ae26683d 100644 (file)
@@ -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
 
index 6585b641d6bfc5aa6acf0dd7237d7a2fadbe5e66..e46005d84c634da2816740dc13ff685116903db6 100755 (executable)
@@ -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