From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steve Kenton Date: Sat, 14 Feb 2015 10:18:47 -0600 Subject: [Buildroot] [PATCH v4] Allow a single DHCP configuration via the system configuration submenu In-Reply-To: <98184085.31058823.1422895105455.JavaMail.root@openwide.fr> References: <98184085.31058823.1422895105455.JavaMail.root@openwide.fr> Message-ID: <54DF7567.7090308@ou.edu> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: buildroot@busybox.net >> >>> +config BR2_SIMPLE_DHCP >> >> We're not completely consist with this, but the new system options >> are >> called BR2_SYSTEM_*, so I've renamed to the option. >> On this topic, what about the following idea? If the interface name is blank do not perform DHCP as currently If the interface name is "*" then run something like this script to automatically find and use the first network interface for DHCP I'd like to be able to use the same BR config on slightly different boards that may sometimes have different network interface names/orders The kernel handles that OK with modules so maybe buildroot could to? Steve #!/bin/bash interfaces="/tmp/interfaces" # The on-the-fly generated interfaces file # This is only used for the BR2_SYSTEM_DHCP "simple single interface dhcp" option. # Many systems only have a single network interface, so auto-find/use it by default. # If there are in fact multiple network interfaces the first non-loop interface # listed in /sys/class/net will be used as the default DHCP configured interface. # As an aid to debugging on new systems all other interfaces found are added to the # generated $interfaces file with DHCP enabled but only the first one is brought up. # Run "ifup -a -i $interfaces" as an alternate to the default /etc/network/interfaces # if [ $# -gt 0 ]; then # be our own mapping script echo "default" # will always be the first interface exit 0 fi first="" echo "# Auto-generated by $(readlink -f $0)" > $interfaces echo "auto lo" >> $interfaces echo "iface lo inet loopback" >> $interfaces echo "" >> $interfaces for interface in $(ls --hide=lo* /sys/class/net); do if [ "$first" == "" ]; then first=$interface echo "auto $first" >> $interfaces else # This is only used to help troubleshoot any additional network interfaces later on echo "iface $interface inet dhcp" >> $interfaces fi echo "" >> $interfaces done # This is the only network interface that needs to be brought up for the simple case # The mapping to default instead of using the physical inteface name is intentional # so that all modifications and documentation will refer to the constant name "default" echo "iface default inet dhcp" >> $interfaces echo "" >> $interfaces # Map the first physical network interface to the logical default interface echo "mapping $first" >> $interfaces echo " script $(readlink -f $0)" >> $interfaces # We don't need any map statements since it's always going to be "default"