]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
netroot: Add pxelinux BOOTIF support
authorPhilippe Seewer <philippe.seewer@bfh.ch>
Tue, 16 Jun 2009 17:35:03 +0000 (19:35 +0200)
committerPhilippe Seewer <philippe.seewer@bfh.ch>
Wed, 17 Jun 2009 06:37:40 +0000 (08:37 +0200)
Having BOOTIF as an argument is a clear pointer which interface should be
used for netroot. This changes network rule generation accordingly.

modules.d/40network/net-genrules.sh
modules.d/40network/parse-ip-opts.sh

index ae5d38f167c6b14d9bbb6b9d207fcea04dec46bb..0768975ef0f181d125bb1e13e9b4be78025092d1 100755 (executable)
@@ -1,10 +1,30 @@
 #!/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
index d87c851e6bdce10ae40c74f816936618e48ff992..4a3de342885eda9431da79d20f693ff1b7b4eb4b 100755 (executable)
@@ -34,6 +34,13 @@ if getarg ip= >/dev/null ; then
     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"