From patchwork Tue Jun 17 05:21:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Kerr X-Patchwork-Id: 360316 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from hemlock.osuosl.org (hemlock.osuosl.org [140.211.166.133]) by ozlabs.org (Postfix) with ESMTP id CCF10140099 for ; Tue, 17 Jun 2014 15:22:22 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 7EAFE9334F; Tue, 17 Jun 2014 05:22:17 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YB4smdrrFpW3; Tue, 17 Jun 2014 05:22:16 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 0F9E18B28E; Tue, 17 Jun 2014 05:22:14 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 6B5C21BF95B for ; Tue, 17 Jun 2014 05:22:04 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 67E648AD80 for ; Tue, 17 Jun 2014 05:22:04 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id GdWkvvoGbqFU for ; Tue, 17 Jun 2014 05:22:04 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ozlabs.org (ozlabs.org [103.22.144.67]) by whitealder.osuosl.org (Postfix) with ESMTPS id C92FE8AD2D for ; Tue, 17 Jun 2014 05:22:03 +0000 (UTC) Received: by ozlabs.org (Postfix, from userid 1023) id 39BEB1400D5; Tue, 17 Jun 2014 15:21:59 +1000 (EST) MIME-Version: 1.0 Message-Id: <1402982507.184367.599670173206.1.gpush@pablo> In-Reply-To: <1402982507.183937.570365596242.0.gpush@pablo> To: buildroot@busybox.net From: Jeremy Kerr Date: Tue, 17 Jun 2014 13:21:47 +0800 Subject: [Buildroot] [PATCH 1/7 v3] package/busybox: Add facility for DHCP hooks X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: buildroot-bounces@busybox.net 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. Signed-off-by: Jeremy Kerr Reviewed-by: "Yann E. MORIN" Acked-by: Arnout Vandecappelle (Essensium/Mind) --- package/busybox/busybox.mk | 2 ++ package/busybox/udhcpc.script | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk index c368b80..bddeb63 100644 --- a/package/busybox/busybox.mk +++ b/package/busybox/busybox.mk @@ -222,6 +222,8 @@ define BUSYBOX_INSTALL_TARGET_CMDS if [ ! -f $(TARGET_DIR)/usr/share/udhcpc/default.script ]; then \ $(INSTALL) -m 0755 -D package/busybox/udhcpc.script \ $(TARGET_DIR)/usr/share/udhcpc/default.script; \ + $(INSTALL) -m 755 -d \ + $(TARGET_DIR)/usr/share/udhcpc/default.script.d; \ fi $(BUSYBOX_INSTALL_MDEV_SCRIPT) $(BUSYBOX_INSTALL_MDEV_CONF) diff --git a/package/busybox/udhcpc.script b/package/busybox/udhcpc.script index e23d1f1..50c52e6 100755 --- a/package/busybox/udhcpc.script +++ b/package/busybox/udhcpc.script @@ -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