From patchwork Thu Jan 16 08:52:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Kerr X-Patchwork-Id: 311642 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (silver.osuosl.org [140.211.166.136]) by ozlabs.org (Postfix) with ESMTP id 609292C009E for ; Thu, 16 Jan 2014 19:53:22 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 5EEBA314D5; Thu, 16 Jan 2014 08:53:21 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NkodcT2FRyRx; Thu, 16 Jan 2014 08:53:18 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 260F932FE5; Thu, 16 Jan 2014 08:52:54 +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 8CE6C1BF966 for ; Thu, 16 Jan 2014 08:52:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 8BE498C5CD for ; Thu, 16 Jan 2014 08:52:41 +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 COYnVHUdbBBU for ; Thu, 16 Jan 2014 08:52:39 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from ozlabs.org (ozlabs.org [203.10.76.45]) by whitealder.osuosl.org (Postfix) with ESMTPS id E9DB18C64A for ; Thu, 16 Jan 2014 08:52:38 +0000 (UTC) Received: by ozlabs.org (Postfix, from userid 1023) id CA3B72C00A6; Thu, 16 Jan 2014 19:52:35 +1100 (EST) MIME-Version: 1.0 Message-Id: <1389862338.917966.273409717366.1.gpush@pablo> In-Reply-To: <1389862338.917573.283530987294.0.gpush@pablo> To: From: Jeremy Kerr Date: Thu, 16 Jan 2014 16:52:18 +0800 Subject: [Buildroot] [RFC, PATCH 1/8] 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 --- package/busybox/busybox.mk | 2 ++ package/busybox/udhcpc.script | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/package/busybox/busybox.mk b/package/busybox/busybox.mk index f6f542e2..6ff5f3da 100644 --- a/package/busybox/busybox.mk +++ b/package/busybox/busybox.mk @@ -200,6 +200,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 43742fbd..8930d4a8 100755 --- a/package/busybox/udhcpc.script +++ b/package/busybox/udhcpc.script @@ -63,4 +63,13 @@ case "$1" in ;; esac +HOOK_DIR="$0.d" +if [ -d "$HOOK_DIR" ] +then + for HOOK in $HOOK_DIR/*; do + $HOOK "$@" + done +fi + + exit 0