> /tmp/net.$netif.did-setup
}
+save_netinfo() {
+ local netif="$1" IFACES="" f="" i=""
+ [ -e /tmp/net.ifaces ] && read IFACES < /tmp/net.ifaces
+ # Add $netif to the front of IFACES (if it's not there already).
+ set -- "$netif"
+ for i in $IFACES; do [ "$i" != "$netif" ] && set -- "$@" "$i"; done
+ IFACES="$*"
+ for i in $IFACES; do
+ for f in /tmp/dhclient.$i.*; do
+ [ -f $f ] && cp -f $f /tmp/net.${f#/tmp/dhclient.}
+ done
+ done
+ echo $IFACES > /tmp/.net.ifaces.new
+ mv /tmp/.net.ifaces.new /tmp/net.ifaces
+}
+
set_ifname() {
local name="$1" mac="$2" num=0 n=""
# if it's already set, return the existing name
# Run the handler; don't store the root, it may change from device to device
# XXX other variables to export?
if $handler $netif $netroot $NEWROOT; then
- # Network rootfs mount successful
- for iface in $IFACES ; do
- [ -f /tmp/dhclient.$iface.lease ] && cp /tmp/dhclient.$iface.lease /tmp/net.$iface.lease
- [ -f /tmp/dhclient.$iface.dhcpopts ] && cp /tmp/dhclient.$iface.dhcpopts /tmp/net.$iface.dhcpopts
- done
-
- # Save used netif for later use
- [ ! -f /tmp/net.ifaces ] && echo $netif > /tmp/net.ifaces
+ # Network rootfs mount successful - save interface info for ifcfg etc.
+ save_netinfo $netif
else
warn "Mounting root via '$netif' failed"
# If we're trying with multiple interfaces, put that one down.