meta-digi-dey: init-ifupdown: Allow to configure interfaces file.

The interfaces file is now dynamically created for eth0, eth1 and wlan0. By
default they are configured if enabled in the machine features, and have
the same static configuration as before.

The static IPs can be configured as follows:

ETHn_STATIC_IP = "<ip address>"
ETHn_STATIC_NETMASK = "<netmask>"
ETHn_STATIC_GATEWAY = "<gateway>"

WLAN0_STATIC_IP = "<ip address>"
WLAN0_STATIC_NETMASK = "<netmask>"

To configure dynamic IPs you can use the following configuration in your
local.conf:

ETHn_DHCP = "dhcp"
WLAN0_DHCP = "dhcp"

https://jira.digi.com/browse/DEL-1178

Signed-off-by: Alex Gonzalez <alex.gonzalez@digi.com>
This commit is contained in:
Alex Gonzalez 2014-09-09 15:40:47 +02:00
parent c89c0f8443
commit 8e7e7124d9
9 changed files with 71 additions and 47 deletions

View File

@ -30,6 +30,22 @@ HAVE_GUI = "${@base_contains('DISTRO_FEATURES', 'x11', '1', '', d)}"
HAVE_EXAMPLE = "${@base_contains('IMAGE_FEATURES', 'dey-examples', '1', '', d)}"
IS_KERNEL_2X = "${@base_version_less_or_equal('PREFERRED_VERSION_linux-dey', '2.6.35.14', '1', '', d)}"
#
# Ethernet configuration used in recipes
#
# ETHx_MODE, WLANx_MODE accepted values: 'dhcp' or 'static'
#
ETH0_MODE ?= "static"
ETH0_STATIC_IP ?= "192.168.42.30"
ETH0_STATIC_NETMASK ?= "255.255.255.0"
ETH0_STATIC_GATEWAY ?= "192.168.42.1"
ETH1_MODE ?= "static"
ETH1_STATIC_IP ?= "192.168.44.30"
ETH1_STATIC_NETMASK ?= "255.255.255.0"
WLAN0_MODE ?= "static"
WLAN0_STATIC_IP ?= "192.168.43.30"
WLAN0_STATIC_NETMASK ?= "255.255.255.0"
# Digi BSP default settings
IMAGE_CLASSES = "image_types_digi"

View File

@ -1,36 +1,2 @@
## The loopback interface
auto lo
iface lo inet loopback
auto eth0
## eth0 static config
iface eth0 inet static
address 192.168.42.30
netmask 255.255.255.0
gateway 192.168.42.1
## eth0 dhcp config
#iface eth0 inet dhcp
# udhcpc_opts -b
#auto eth1
## eth1 static config
iface eth1 inet static
address 192.168.44.30
netmask 255.255.255.0
## eth1 dhcp config
#iface eth1 inet dhcp
# udhcpc_opts -b
#auto wlan0
## wlan0 static config
iface wlan0 inet static
address 192.168.43.30
netmask 255.255.255.0
wpa-driver ##WPA_DRIVER##
wpa-conf /etc/wpa_supplicant.conf
## wlan0 dhcp config
#iface wlan0 inet dhcp
# udhcpc_opts -b

View File

@ -0,0 +1,4 @@
auto eth0
iface eth0 inet dhcp
udhcpc_opts -b

View File

@ -0,0 +1,6 @@
auto eth0
iface eth0 inet static
address ##ETH0_STATIC_IP##
netmask ##ETH0_STATIC_NETMASK##
gateway ##ETH0_STATIC_GATEWAY##

View File

@ -0,0 +1,4 @@
auto eth1
iface eth1 inet dhcp
udhcpc_opts -b

View File

@ -0,0 +1,5 @@
auto eth1
iface eth1 inet static
address ##ETH1_STATIC_IP##
netmask ##ETH1_STATIC_NETMASK##

View File

@ -0,0 +1,6 @@
auto wlan0
iface wlan0 inet dhcp
udhcpc_opts -b
wpa-driver ##WPA_DRIVER##
wpa-conf /etc/wpa_supplicant.conf

View File

@ -0,0 +1,7 @@
auto wlan0
iface wlan0 inet static
address ##WLAN0_STATIC_IP##
netmask ##WLAN0_STATIC_NETMASK##
wpa-driver ##WPA_DRIVER##
wpa-conf /etc/wpa_supplicant.conf

View File

@ -2,24 +2,34 @@
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}-${PV}:"
SRC_URI_append = " \
file://interfaces.eth0.static \
file://interfaces.eth0.dhcp \
file://interfaces.eth1.static \
file://interfaces.eth1.dhcp \
file://interfaces.wlan0.static \
file://interfaces.wlan0.dhcp"
SRC_URI_append_mx5 = " file://ifup"
WPA_DRIVER ?= "wext"
do_install_append() {
# Enable or disable second ethernet interface
if [ -n "${HAVE_EXT_ETH}" ]; then
sed -i -e '/^.*auto eth1.*/cauto eth1' ${D}${sysconfdir}/network/interfaces
else
sed -i -e '/^.*auto eth1.*/c#auto eth1' ${D}${sysconfdir}/network/interfaces
fi
# Enable or disable wifi interface
if [ -n "${HAVE_WIFI}" ]; then
sed -i -e '/^.*auto wlan0.*/cauto wlan0' ${D}${sysconfdir}/network/interfaces
else
sed -i -e '/^.*auto wlan0.*/c#auto wlan0' ${D}${sysconfdir}/network/interfaces
fi
# Configure wpa_supplicant driver
# Create 'interfaces' file dynamically
cat ${WORKDIR}/interfaces.eth0.${ETH0_MODE} >> ${D}${sysconfdir}/network/interfaces
[ -n "${HAVE_EXT_ETH}" ] && cat ${WORKDIR}/interfaces.eth1.${ETH1_MODE} >> ${D}${sysconfdir}/network/interfaces
[ -n "${HAVE_WIFI}" ] && cat ${WORKDIR}/interfaces.wlan0.${WLAN0_MODE} >> ${D}${sysconfdir}/network/interfaces
# Replace interface parameters
sed -i -e 's,##ETH0_STATIC_IP##,${ETH0_STATIC_IP},g' ${D}${sysconfdir}/network/interfaces
sed -i -e 's,##ETH0_STATIC_NETMASK##,${ETH0_STATIC_NETMASK},g' ${D}${sysconfdir}/network/interfaces
sed -i -e 's,##ETH0_STATIC_GATEWAY##,${ETH0_STATIC_GATEWAY},g' ${D}${sysconfdir}/network/interfaces
sed -i -e 's,##ETH1_STATIC_IP##,${ETH1_STATIC_IP},g' ${D}${sysconfdir}/network/interfaces
sed -i -e 's,##ETH1_STATIC_NETMASK##,${ETH1_STATIC_NETMASK},g' ${D}${sysconfdir}/network/interfaces
sed -i -e 's,##ETH1_STATIC_GATEWAY##,${ETH1_STATIC_GATEWAY},g' ${D}${sysconfdir}/network/interfaces
sed -i -e 's,##WLAN0_STATIC_IP##,${WLAN0_STATIC_IP},g' ${D}${sysconfdir}/network/interfaces
sed -i -e 's,##WLAN0_STATIC_NETMASK##,${WLAN0_STATIC_NETMASK},g' ${D}${sysconfdir}/network/interfaces
sed -i -e 's,##WLAN0_STATIC_GATEWAY##,${WLAN0_STATIC_GATEWAY},g' ${D}${sysconfdir}/network/interfaces
sed -i -e "s,##WPA_DRIVER##,${WPA_DRIVER},g" ${D}${sysconfdir}/network/interfaces
}