Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jeremy Rosen <jeremy.rosen@openwide.fr>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] Allow a single DHCP configuration via the system configuration submenu
Date: Wed, 17 Dec 2014 17:37:24 +0100 (CET)	[thread overview]
Message-ID: <1864913624.29395872.1418834244256.JavaMail.root@openwide.fr> (raw)
In-Reply-To: <CAHXCMMJChcAoT5trA7cHOE5aM61enT8ukiMg8gXOvMwBxXo0qA@mail.gmail.com>


Hey Samuel


----- Mail original -----
> Hi Jeremy,
> 
> On Wed, Dec 17, 2014 at 5:15 PM, J?r?my Rosen
> <jeremy.rosen@openwide.fr> wrote:
> > 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 <jeremy.rosen@openwide.fr>
> > ---
> >  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
> 
> IIRC, comment does not support help message, but it could be
> worthwhile to document somewhere how to do this in the systemd case,
> without needing reading the git log ;-)
> 

well, the answer is "the usual way, use overlays" and "read the man
page for networkd".

systemd in general has pretty good set of docs, and we don't document
most of the ways to customize your image. BR users are supposed to
know system configuration (we don't document /etc/network/interfaces)

so I personally think it's not really needed, but if you think it's
really necessary and you tell me where to add a note, I can write
something... I have a good understanding of networkd with my previous
attempt at network configuration


> > +
> > +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
> > --
> > 2.1.3
> >
> > _______________________________________________
> > buildroot mailing list
> > buildroot at busybox.net
> > http://lists.busybox.net/mailman/listinfo/buildroot
> 
> Regards,
> 
> --
> Samuel
> 

  reply	other threads:[~2014-12-17 16:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-17 16:15 [Buildroot] [PATCH] Allow a single DHCP configuration via the system configuration submenu Jérémy Rosen
2014-12-17 16:30 ` Samuel Martin
2014-12-17 16:37   ` Jeremy Rosen [this message]
2014-12-17 20:29 ` Thomas Petazzoni
2014-12-18  8:04   ` Jeremy Rosen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1864913624.29395872.1418834244256.JavaMail.root@openwide.fr \
    --to=jeremy.rosen@openwide.fr \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox