package/busybox: Add facility for DHCP hooks
authorJeremy Kerr <jk@ozlabs.org>
Tue, 17 Jun 2014 05:21:47 +0000 (13:21 +0800)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Fri, 2 Jan 2015 18:24:57 +0000 (19:24 +0100)
The (u)dhcpc hook installed by the busybox package configures the
network and exits. If we want to do anything further with a DHCP lease,
we'd have to replace the script entirely.

This change introduces a .d directory for hooks (based on the script
filename), which are executed after the interface configuration. This
allows packages to drop a script file in the .d directory to perform
actions on DHCP events.

We'll use this in a later change to notify petitboot of DHCP boot
information.

[Thomas: update to latest Buildroot, fix indentation.]

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Acked-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
package/busybox/busybox.mk
package/busybox/udhcpc.script

index 8e75e1f840ff8d7fe9083271654094550208faba..f68a2f8a42d28ef7818c4923c1f2472a1bf88473 100644 (file)
@@ -212,6 +212,8 @@ define BUSYBOX_INSTALL_TARGET_CMDS
        $(BUSYBOX_MAKE_ENV) $(MAKE) $(BUSYBOX_MAKE_OPTS) -C $(@D) install
        $(INSTALL) -m 0755 -D package/busybox/udhcpc.script \
                $(TARGET_DIR)/usr/share/udhcpc/default.script
+       $(INSTALL) -m 0755 -d \
+               $(TARGET_DIR)/usr/share/udhcpc/default.script.d
        $(BUSYBOX_INSTALL_MDEV_CONF)
 endef
 
index e23d1f1e0fe448be023443b64ee8f78bd6366c3a..50c52e6fe3e5fb6eeb17b638920de2ec875ea192 100755 (executable)
@@ -64,4 +64,10 @@ case "$1" in
                ;;
 esac
 
+HOOK_DIR="$0.d"
+for hook in "${HOOK_DIR}/"*; do
+    [ -f "${hook}" -a -x "${hook}" ] || continue
+    "${hook}" "${@}"
+done
+
 exit 0