From patchwork Wed Dec 17 16:15:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jeremy Rosen X-Patchwork-Id: 422305 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (whitealder.osuosl.org [140.211.166.138]) by ozlabs.org (Postfix) with ESMTP id 184771400DD for ; Thu, 18 Dec 2014 03:16:06 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 6193791329; Wed, 17 Dec 2014 16:16:05 +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 sCjpaeYcZkdz; Wed, 17 Dec 2014 16:16:04 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id E5AC590DF8; Wed, 17 Dec 2014 16:16:03 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from hemlock.osuosl.org (hemlock.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 768D91C2A63 for ; Wed, 17 Dec 2014 16:16:02 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 6003994D0B for ; Wed, 17 Dec 2014 16:16:02 +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 9bsDh4HcuSHa for ; Wed, 17 Dec 2014 16:16:00 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-wg0-f48.google.com (mail-wg0-f48.google.com [74.125.82.48]) by hemlock.osuosl.org (Postfix) with ESMTPS id 1BDB794CE1 for ; Wed, 17 Dec 2014 16:16:00 +0000 (UTC) Received: by mail-wg0-f48.google.com with SMTP id y19so20635668wgg.21 for ; Wed, 17 Dec 2014 08:15:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=IKw9lGLxWqQXHrtfqEBYfuK+51pXQnmtinqaQvSIGOo=; b=tjGETJkNww9n5pZPJOm2LCKlRvuiqOypBio60d3QTPP0TTaKc/xnS6d0+QEwp1zOf6 IDDdc6s9F+yceQYCA1fcgnJ0XCsrXC6A90WxpLJ2biVKbMaxnXVDz6dyAkjdoia6JFZR v2ek93W0nzveHhtSTLSHS26EiVMO6boIs4FGOiYKx4CWaRxiTv3zx+T3IPuf0KxtiUz8 TyzE/hDCof9AbQr815G+r2W8fS61wXRlIeF7RnNTvTsSwZqE1W2/3/bMrCeqjBS7MZUv LqctePLeCWgAoXIHabvC7sV/1ip6rh6HGJIeLHg5p+rmBpyGAuXF7a8MfZcqWEdJeiI5 D2Ag== X-Received: by 10.180.84.98 with SMTP id x2mr15682682wiy.14.1418832958538; Wed, 17 Dec 2014 08:15:58 -0800 (PST) Received: from pcrosen.daviel.openwide.fr. ([193.56.60.161]) by mx.google.com with ESMTPSA id r3sm21489607wic.10.2014.12.17.08.15.57 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 17 Dec 2014 08:15:58 -0800 (PST) From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rosen?= To: buildroot@uclibc.org Date: Wed, 17 Dec 2014 17:15:46 +0100 Message-Id: <1418832946-28337-1-git-send-email-jeremy.rosen@openwide.fr> X-Mailer: git-send-email 2.1.3 MIME-Version: 1.0 Subject: [Buildroot] [PATCH] Allow a single DHCP configuration via the system configuration submenu X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 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" This patch allows the setup of simple a single interface to be automatically brought up and configured via DHCP on system startup. The interface name can be set via a configuration option. This patch does not support systemd-networkd, any complex network configuration should be done via overlay of /etc/network/interfaces or the relevant networkd configuration file Signed-off-by: Jérémy Rosen --- support/scripts/generate-network-config.sh | 24 ++++++++++++++++++++++++ system/Config.in | 18 ++++++++++++++++++ system/skeleton/etc/network/interfaces | 4 ---- system/system.mk | 5 +++++ 4 files changed, 47 insertions(+), 4 deletions(-) create mode 100755 support/scripts/generate-network-config.sh delete mode 100644 system/skeleton/etc/network/interfaces diff --git a/support/scripts/generate-network-config.sh b/support/scripts/generate-network-config.sh new file mode 100755 index 0000000..92f8d16 --- /dev/null +++ b/support/scripts/generate-network-config.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +export BR2_SIMPLE_DHCP=$(sed -r -e "/^BR2_SIMPLE_DHCP=(.*)$/!d;" -e 's//\1/;' $BR2_CONFIG) + +export BR2_SIMPLE_DHCP_INTERFACE="$(sed -r -e "/^BR2_SIMPLE_DHCP_INTERFACE=\"(.*)\"$/!d;" -e 's//\1/;' $BR2_CONFIG)" + +do_generate_interfaces () +{ + echo "# interface file auto-generated by buildroot" + echo + echo "auto lo" + echo "iface lo inet loopback" + echo + + if [ -z "$BR2_SIMPLE_DHCP" ] ; then + return + fi + + echo "auto $BR2_SIMPLE_DHCP_INTERFACE" + echo "iface $BR2_SIMPLE_DHCP_INTERFACE inet dhcp" +} + +mkdir -p $TARGET_DIR/etc/network/ +do_generate_interfaces > $TARGET_DIR/etc/network/interfaces diff --git a/system/Config.in b/system/Config.in index a3b7aff..10a81e9 100644 --- a/system/Config.in +++ b/system/Config.in @@ -324,6 +324,24 @@ config BR2_TARGET_GENERIC_REMOUNT_ROOTFS_RW endif # BR2_ROOTFS_SKELETON_DEFAULT +config BR2_SIMPLE_DHCP + bool "automatic network configuration via DHCP" + default n + depends on !BR2_PACKAGE_SYSTEMD_NETWORKD + help + Automatically do a DHCP request on startup on selected interface at + startup. For more complicated setups use an overlay. + +comment "automatic network configuration via DHCP is not compatible with networkd" + depends on BR2_PACKAGE_SYSTEMD_NETWORKD + +config BR2_SIMPLE_DHCP_INTERFACE + string "name of the physical network interface to run DHCP on" + depends on BR2_SIMPLE_DHCP + default eth0 + help + The name of the network interface to configure automatically + config BR2_TARGET_TZ_INFO bool "Install timezone info" # No timezone for musl; only for uClibc or (e)glibc. diff --git a/system/skeleton/etc/network/interfaces b/system/skeleton/etc/network/interfaces deleted file mode 100644 index 218b82c..0000000 --- a/system/skeleton/etc/network/interfaces +++ /dev/null @@ -1,4 +0,0 @@ -# Configure Loopback -auto lo -iface lo inet loopback - diff --git a/system/system.mk b/system/system.mk index e4a3160..bb933f6 100644 --- a/system/system.mk +++ b/system/system.mk @@ -38,6 +38,11 @@ ifneq ($(TARGET_GENERIC_ROOT_PASSWD),) TARGETS += host-mkpasswd endif +define SIMPLE_NETWORK + $(TOPDIR)/support/scripts/generate-network-config.sh $(TARGET_DIR) +endef +TARGET_FINALIZE_HOOKS += SIMPLE_NETWORK + ifeq ($(BR2_ROOTFS_SKELETON_DEFAULT),y) define SYSTEM_ROOT_PASSWD