[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#535008: configure_networking: support BOOTIF variable set by pxelinux



Package: initramfs-tools
Version: 0.93.3
Severity: wishlist
Tags: patch

when booting thin clients with multiple network cards, initramfs-tools/ipconfig
have a hard time figuring out which interface to use. attached is a patch which
sets DEVICE to the interface matching the mac address that pxelinux passes when
using the IPAPPEND 2 or 3 options.

diff --git a/scripts/functions b/scripts/functions
index 77de8f3..ec0ffd2 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -258,6 +258,19 @@ parse_numeric() {
 
 configure_networking()
 {
+
+	# pxelinux sets BOOTIF to a value based on the mac address of the network
+	# card used to PXE boot, so use this value for DEVICE rather than a
+	# hard-coded device name from initramfs.conf. this facilitates network
+	# booting when machines may have multiple network cards.
+	if [ -n "${BOOTIF}" ]; then
+		normal_mac=$(echo $BOOTIF | sed -e 's,^01-,,g' -e 's,-,:,g' | tr [a-z] [A-Z])
+		new_device=$(ifconfig -a | awk "/$normal_mac/"'{print $1}')
+		if [ -n "$new_device" ]; then
+			DEVICE="$new_device"
+		fi
+	fi
+
 	# networking already configured thus bail out
 	[ -n "${DEVICE}" ] && [ -e /tmp/net-"${DEVICE}".conf ] && return 0

 
live well,
  vagrant



Reply to: