Bug#504753: debian-installer: autodetect correct network card [PATCH]
Package: debian-installer
using PXElinux, if you add "IPAPPEND=3" in the pxelinux.cfg,
/proc/cmdline will contain the boot adapter's MAC address.
Using this we can automatically detect which card the box PXEbooted
from. This removes the need for us to hardcode eth0 on some servers,
eth1 on others, eth5 on yet others.
I use the attached script (/bin/set-bootif) run from
/lib/debian-installer-startup.d/S32set-bootif:
#!/bin/sh
/bin/set-bootif
Adrian
--
Email: adrian@smop.co.uk -*- GPG key available on public key servers
Debian GNU/Linux - the maintainable distribution -*- www.debian.org
#!/bin/sh
# if PXELINUX has IPAPPEND set, use that MAC address
# written by Adrian Bridgett from code in d-i/bin/env2debconf
export DEBIAN_FRONTEND=none
. /usr/share/debconf/confmodule
bootif=`sed 's/.*BOOTIF=\([-a-z0-9]*\).*/\1/; t; d' /proc/cmdline`
if [ "$bootif" ]; then
interface_found=""
# bootif is 01-00-19-b9-e1-c6-94, convert to MAC
mac=${bootif#01-}
mac=`echo $mac | sed 's/-/:/g'`
echo "Found bootif $bootif, looking for MAC $mac"
cd /sys/class/net
for interface in *; do
if [ `cat $interface/address` = "$mac" ]; then
echo "Found matching interface $interface"
interface_found=$interface
db_set netcfg/choose_interface $interface
# must mark question as seen otherwise you are reprompted
db_fset netcfg/choose_interface seen true
fi
done
if [ ! "$interface_found" ]; then
echo "No matching interface for MAC $mac"
fi
fi
Reply to: