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.
master
Philippe Seewer 2009-06-16 19:26:35 +02:00
parent 1b31fc140b
commit 761ffdddb9
4 changed files with 19 additions and 3 deletions

View File

@ -1,2 +0,0 @@
ACTION=="add", SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}"
ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/netroot $env{INTERFACE}"

View File

@ -15,7 +15,7 @@ inst "$moddir/netroot" "/sbin/netroot"
inst "$moddir/dhclient-script" "/sbin/dhclient-script" inst "$moddir/dhclient-script" "/sbin/dhclient-script"
inst "$moddir/dhclient.conf" "/etc/dhclient.conf" inst "$moddir/dhclient.conf" "/etc/dhclient.conf"
instmods ecb arc4 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 91 "$moddir/dhcp-root.sh"
inst_hook cmdline 99 "$moddir/parse-ip-opts.sh" inst_hook cmdline 99 "$moddir/parse-ip-opts.sh"
inst_hook pre-pivot 10 "$moddir/kill-dhclient.sh" inst_hook pre-pivot 10 "$moddir/kill-dhclient.sh"

View File

@ -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

View File

@ -26,6 +26,14 @@ ip_to_var() {
esac 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 # Warn if defaulting to ip=dhcp
if [ -n "$netroot" ] && [ -z "$(getarg ip=)" ] ; then if [ -n "$netroot" ] && [ -z "$(getarg ip=)" ] ; then
warn "No ip= argument(s) for netroot provided, defaulting to DHCP" warn "No ip= argument(s) for netroot provided, defaulting to DHCP"