Use "ip" command and identify using MAC addresses (DEB)

pull/4/head
Javi Fontan 11 years ago
parent 3c27734e77
commit a1d2ae29e2

@ -74,10 +74,6 @@ get_interfaces() {
$IFCMD | grep ^eth | sed 's/ *Link encap:Ethernet.*HWaddr /-/g' $IFCMD | grep ^eth | sed 's/ *Link encap:Ethernet.*HWaddr /-/g'
} }
get_dev() {
echo $1 | cut -d'-' -f 1
}
get_mac() { get_mac() {
echo $1 | cut -d'-' -f 2 echo $1 | cut -d'-' -f 2
} }
@ -132,6 +128,24 @@ EOT
echo "" 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() gen_network_configuration()
{ {
cat <<EOT cat <<EOT
@ -140,12 +154,13 @@ iface lo inet loopback
EOT EOT
IFACES=`get_interfaces` INTERFACE_MAC=$(get_interface_mac)
CONTEXT_INTERFACES=$(get_context_interfaces)
for i in $IFACES; do for interface in $CONTEXT_INTERFACES; do
MAC=`get_mac $i` UPCASE_DEV=$interface
DEV=`get_dev $i` MAC=$(get_iface_var "MAC")
UPCASE_DEV=`upcase $DEV` DEV=$(get_dev "$INTERFACE_MAC" "$MAC")
IP=$(get_ip) IP=$(get_ip)
NETWORK=$(get_network) NETWORK=$(get_network)

Loading…
Cancel
Save