#!/bin/sh
# bind eth* by mac addresses at least in the order 
# they appear right now (so that it's consistent
# across reboots); see also
# https://bugzilla.altlinux.org/show_bug.cgi?id=14872

. install2-init-functions

bind_by_mac()
{
	MAC="`ip li sh dev $1 | fgrep 'link/ether' | sed 's#^ *link/ether ##' | cut -d' ' -f1`"
	[ -z "$MAC" ] || echo "$1	mac $MAC" >> "$destdir/etc/iftab"
}

IFS=': '
ip li | fgrep -B1 link/ether \
| while read num iface junk; do
	bind_by_mac "$iface"
	read nextline
done
