From a1d2ae29e2ab6bd074102282a641cf9c08279a6a Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Mon, 14 Jul 2014 11:49:27 +0200 Subject: [PATCH] Use "ip" command and identify using MAC addresses (DEB) --- base_deb/etc/one-context.d/00-network | 33 +++++++++++++++++++-------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/base_deb/etc/one-context.d/00-network b/base_deb/etc/one-context.d/00-network index a23bbf1..a00026c 100755 --- a/base_deb/etc/one-context.d/00-network +++ b/base_deb/etc/one-context.d/00-network @@ -74,10 +74,6 @@ get_interfaces() { $IFCMD | grep ^eth | sed 's/ *Link encap:Ethernet.*HWaddr /-/g' } -get_dev() { - echo $1 | cut -d'-' -f 1 -} - get_mac() { echo $1 | cut -d'-' -f 2 } @@ -132,6 +128,24 @@ EOT echo "" } +get_interface_mac() +{ + ip link show | awk '/^[0-9]+: [[:alnum:]]+:/ { device=$2; gsub(/:/, "",device)} /link\/ether/ { print device " " $2 }' +} + +get_context_interfaces() +{ + env | grep -E "^ETH[0-9]+_MAC=" | sed 's/_.*$//' | sort +} + +get_dev() +{ + list="$1" + mac="$2" + + echo "$list" | grep "$mac" | cut -d' ' -f1 | tail -n1 +} + gen_network_configuration() { cat <