@ -3,7 +3,6 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh
# ex: ts=8 sw=4 sts=4 et filetype=sh
PATH=/usr/sbin:/usr/bin:/sbin:/bin
PATH=/usr/sbin:/usr/bin:/sbin:/bin
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
# Huh? Empty $1?
# Huh? Empty $1?
@ -12,12 +11,16 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
# Huh? No interface config?
# Huh? No interface config?
[ ! -e /tmp/net.$1.up ] && exit 1
[ ! -e /tmp/net.$1.up ] && exit 1
# There's no sense in doing something if no (net)root info is available
# [ ! -z $2 ] means this is for manually bringing up network
# instead of real netroot; If It's called without $2, then there's
# no sense in doing something if no (net)root info is available
# or root is already there
# or root is already there
[ -e /tmp/root.info ] || exit 1
[ -e /tmp/root.info ] || exit 1
. /tmp/root.info
. /tmp/root.info
[ -d $NEWROOT/proc ] && exit 0
if [ -z "$2" ]; then
[ -z "$netroot" ] && exit 1
[ -d $NEWROOT/proc ] && exit 0
[ -z "$netroot" ] && exit 1
fi
# Let's see if we have to wait for other interfaces
# Let's see if we have to wait for other interfaces
# Note: exit works just fine, since the last interface to be
# Note: exit works just fine, since the last interface to be
@ -31,43 +34,49 @@ done
netif=$1
netif=$1
[ -e "/tmp/net.bootdev" ] && read netif < /tmp/net.bootdev
[ -e "/tmp/net.bootdev" ] && read netif < /tmp/net.bootdev
if [ -e /tmp/net.$netif.manualup ]; then
rm -f /tmp/net.$netif.manualup
fi
# Figure out the handler for root=dhcp by recalling all netroot cmdline
# Figure out the handler for root=dhcp by recalling all netroot cmdline
# handlers
# handlers when this is not called from manually network bringing up.
if [ "$netroot" = "dhcp" ] || [ "$netroot" = "dhcp6" ] ; then
if [ -z "$2" ]; then
# Unset root so we can check later
if [ "$netroot" = "dhcp" ] || [ "$netroot" = "dhcp6" ] ; then
unset root
# Unset root so we can check later
unset root
# Load dhcp options
[ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
# Load dhcp options
[ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
# If we have a specific bootdev with no dhcpoptions or empty root-path,
# we die. Otherwise we just warn
# If we have a specific bootdev with no dhcpoptions or empty root-path,
if [ -z "$new_root_path" ] ; then
# we die. Otherwise we just warn
[ -n "$BOOTDEV" ] && die "No dhcp root-path received for '$BOOTDEV'"
if [ -z "$new_root_path" ] ; then
warn "No dhcp root-path received for '$BOOTDEV' trying other interfaces if available"
[ -n "$BOOTDEV" ] && die "No dhcp root-path received for '$BOOTDEV'"
exit 1
warn "No dhcp root-path received for '$BOOTDEV' trying other interfaces if available"
fi
exit 1
fi
# Set netroot to new_root_path, so cmdline parsers don't call
# Set netroot to new_root_path, so cmdline parsers don't call
netroot=$new_root_path
netroot=$new_root_path
# FIXME!
# FIXME!
for f in $hookdir/cmdline/90*.sh; do
for f in $hookdir/cmdline/90*.sh; do
[ -f "$f" ] && . "$f";
[ -f "$f" ] && . "$f";
done
done
else
else
rootok="1"
rootok="1"
fi
fi
# Check: do we really know how to handle (net)root?
# Check: do we really know how to handle (net)root?
[ -z "$root" ] && die "No or empty root= argument"
[ -z "$root" ] && die "No or empty root= argument"
[ -z "$rootok" ] && die "Don't know how to handle 'root=$root'"
[ -z "$rootok" ] && die "Don't know how to handle 'root=$root'"
handler=${netroot%%:*}
handler=${netroot%%:*}
handler=${handler%%4}
handler=${handler%%4}
handler=$(command -v ${handler}root)
handler=$(command -v ${handler}root)
if [ -z "$netroot" ] || [ ! -e "$handler" ] ; then
if [ -z "$netroot" ] || [ ! -e "$handler" ] ; then
die "No handler for netroot type '$netroot'"
die "No handler for netroot type '$netroot'"
fi
fi
fi
# We're here, so we can assume that upping interfaces is now ok
# We're here, so we can assume that upping interfaces is now ok
@ -122,6 +131,9 @@ if [ -n "$dest" ] && ! arping -q -f -w 60 -I $netif $dest ; then
dinfo "Resolving $dest via ARP on $netif failed"
dinfo "Resolving $dest via ARP on $netif failed"
fi
fi
# exit in case manually bring up network
[ -n "$2" ] && exit 0
# Source netroot hooks before we start the handler
# Source netroot hooks before we start the handler
source_all $hookdir/netroot
source_all $hookdir/netroot