From: Philippe Seewer Date: Tue, 16 Jun 2009 17:35:03 +0000 (+0200) Subject: netroot: Add pxelinux BOOTIF support X-Git-Tag: 0.1~38 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3029be4df8a8b5abdab2a4a96c7fd80de4686427;p=platform%2Fupstream%2Fdracut.git netroot: Add pxelinux BOOTIF support Having BOOTIF as an argument is a clear pointer which interface should be used for netroot. This changes network rule generation accordingly. --- diff --git a/modules.d/40network/net-genrules.sh b/modules.d/40network/net-genrules.sh index ae5d38f..0768975 100755 --- a/modules.d/40network/net-genrules.sh +++ b/modules.d/40network/net-genrules.sh @@ -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 diff --git a/modules.d/40network/parse-ip-opts.sh b/modules.d/40network/parse-ip-opts.sh index d87c851..4a3de34 100755 --- a/modules.d/40network/parse-ip-opts.sh +++ b/modules.d/40network/parse-ip-opts.sh @@ -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"