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
parent
1b31fc140b
commit
761ffdddb9
|
@ -1,2 +0,0 @@
|
|||
ACTION=="add", SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}"
|
||||
ACTION=="online", SUBSYSTEM=="net", RUN+="/sbin/netroot $env{INTERFACE}"
|
|
@ -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"
|
||||
|
|
|
@ -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
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue