#!/bin/sh
+# pxelinux provides macaddr '-' separated, but we need ':'
+fix_bootif() {
+ local macaddr=${1##??-}
+ local IFS='-'
+ macaddr=$(for i in ${macaddr} ; do echo -n $i:; done)
+ macaddr=${macaddr%:}
+ echo $macaddr
+}
+
# Don't continue if we don't need network
[ -z "$netroot" ] && return;
# Write udev rules
{
- printf 'ACTION=="add", SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}"\n'
+
+# BOOTIF says everything, use only that one
+ BOOTIF=$(getarg 'BOOTIF=')
+ if [ -n "$BOOTIF" ] ; then
+ BOOTIF=$(fix_bootif "$BOOTIF")
+ printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$BOOTIF"
+ else
+ printf 'ACTION=="add", SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}"\n'
+ fi
+
+ # Udev event 'online' only gets fired from ifup/dhclient-script.
+ # No special rules required
printf 'ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/netroot $env{INTERFACE}"\n'
} > /etc/udev/rules.d/60-net.rules
fi
fi
+# Don't mix BOOTIF=macaddr from pxelinux and ip= lines
+getarg ip= >/dev/null && getarg BOOTIF= >/dev/null && \
+ die "Mixing BOOTIF and ip= lines is dangerous"
+
+# No more parsing stuff, BOOTIF says everything
+[ -n "$(getarg BOOTIF)" ] && return
+
# Warn if defaulting to ip=dhcp
if [ -n "$netroot" ] && [ -z "$(getarg ip=)" ] ; then
warn "No ip= argument(s) for netroot provided, defaulting to DHCP"