]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
netroot: Only start interface configuration if really needed
authorPhilippe Seewer <philippe.seewer@bfh.ch>
Tue, 16 Jun 2009 17:26:35 +0000 (19:26 +0200)
committerPhilippe Seewer <philippe.seewer@bfh.ch>
Wed, 17 Jun 2009 06:37:40 +0000 (08:37 +0200)
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.

modules.d/40network/60-net.rules [deleted file]
modules.d/40network/install
modules.d/40network/net-genrules.sh [new file with mode: 0755]
modules.d/40network/parse-ip-opts.sh

diff --git a/modules.d/40network/60-net.rules b/modules.d/40network/60-net.rules
deleted file mode 100644 (file)
index 6c79508..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-ACTION=="add", SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}"
-ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/netroot $env{INTERFACE}"
index cb9359e95caf6c5c6aec5524bb90f674152796e3..0b76cbd76473d39749ec8408d4e266d06be67087 100755 (executable)
@@ -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 (executable)
index 0000000..ae5d38f
--- /dev/null
@@ -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
index df1a071e62bf63573fcd06e2bb5c8697f0216cae..d87c851e6bdce10ae40c74f816936618e48ff992 100755 (executable)
@@ -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"