From: Philippe Seewer Date: Tue, 16 Jun 2009 17:26:35 +0000 (+0200) Subject: netroot: Only start interface configuration if really needed X-Git-Tag: 0.1~39 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=761ffdddb917f2ae777f5d04a32c16fb94467103;p=thirdparty%2Fdracut.git netroot: Only start interface configuration if really needed Currently network configuration is launched by udev as soon as it discovers a driver. This isn't such a good idea since we don't know if network configuration is actually required. Change this by writing the udev rules on the fly if required. --- diff --git a/modules.d/40network/60-net.rules b/modules.d/40network/60-net.rules deleted file mode 100644 index 6c7950819..000000000 --- a/modules.d/40network/60-net.rules +++ /dev/null @@ -1,2 +0,0 @@ -ACTION=="add", SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}" -ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/netroot $env{INTERFACE}" diff --git a/modules.d/40network/install b/modules.d/40network/install index cb9359e95..0b76cbd76 100755 --- a/modules.d/40network/install +++ b/modules.d/40network/install @@ -15,7 +15,7 @@ inst "$moddir/netroot" "/sbin/netroot" inst "$moddir/dhclient-script" "/sbin/dhclient-script" inst "$moddir/dhclient.conf" "/etc/dhclient.conf" instmods ecb arc4 -inst_rules "$moddir/60-net.rules" +inst_hook pre-udev 60 "$moddir/net-genrules.sh" inst_hook cmdline 91 "$moddir/dhcp-root.sh" inst_hook cmdline 99 "$moddir/parse-ip-opts.sh" inst_hook pre-pivot 10 "$moddir/kill-dhclient.sh" diff --git a/modules.d/40network/net-genrules.sh b/modules.d/40network/net-genrules.sh new file mode 100755 index 000000000..ae5d38f16 --- /dev/null +++ b/modules.d/40network/net-genrules.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +# 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' + 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 df1a071e6..d87c851e6 100755 --- a/modules.d/40network/parse-ip-opts.sh +++ b/modules.d/40network/parse-ip-opts.sh @@ -26,6 +26,14 @@ ip_to_var() { esac } +# Check if ip= lines should be used +if getarg ip= >/dev/null ; then + if [ -z "$netroot" ] ; then + echo "Warning: No netboot configured, ignoring ip= lines" + return; + fi +fi + # Warn if defaulting to ip=dhcp if [ -n "$netroot" ] && [ -z "$(getarg ip=)" ] ; then warn "No ip= argument(s) for netroot provided, defaulting to DHCP"