#!/bin/bash
#
# eth2em-map.sh: Example script to create mapping of ethN name to
#	emX or pXpY names on deplyments that currently use ethN names.
#
# Copyright (C) 2011-2012 Dell, Inc.
# by Charles Rose <charles_rose@dell.com>
#
# http://linux.dell.com/biosdevname/scripts
#
# Usage:
#	# ./eth2em-map.sh
#
# Output to STDOUT
# 
# Output format is:
#  <ethN> <emN|pXpY> <MAC>
#
# <ethN>: is the older (traditional) name used by the kernel
# <emX|pXpY>: is the new name of the interface
# <MAC>: MAC address of the interface
#

if [ -x /sbin/biosdevname ] >/dev/null 2>&1; then
	/sbin/biosdevname
	[ $? -ne 0 ] && exit 1 # hardware/firmware do not support biosdevname
else
	echo "/sbin/biosdevname not found."
	exit 1
fi

if [ $(biosdevname -d|grep -c eth) == "0" ]; then
	echo "You do not seem to have ethN names."
else
	biosdevname -d  | awk '/BIOS device/ {new=$3} /Kernel name/ {old=$3}
		/Assigned MAC/ {mac=$4; print old" "new" "mac}'
fi
