Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
Use "ip" command and identify using MAC addresses (DEB)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfontan committed Jul 14, 2014
1 parent 3c27734 commit a1d2ae2
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions base_deb/etc/one-context.d/00-network
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 <<EOT
Expand All @@ -140,12 +154,13 @@ iface lo inet loopback
EOT

IFACES=`get_interfaces`
INTERFACE_MAC=$(get_interface_mac)
CONTEXT_INTERFACES=$(get_context_interfaces)

for i in $IFACES; do
MAC=`get_mac $i`
DEV=`get_dev $i`
UPCASE_DEV=`upcase $DEV`
for interface in $CONTEXT_INTERFACES; do
UPCASE_DEV=$interface
MAC=$(get_iface_var "MAC")
DEV=$(get_dev "$INTERFACE_MAC" "$MAC")

IP=$(get_ip)
NETWORK=$(get_network)
Expand Down

0 comments on commit a1d2ae2

Please sign in to comment.