echo "$line"
done >/tmp/dhclient.$netif.dhcpopts
echo online > /sys/class/net/$netif/uevent
- initqueue --onetime --name netroot-$netif netroot $netif
+
+ if [ -e /tmp/net.$netif.manualup ]; then
+ /sbin/netroot $netif -m
+ rm -f /tmp/net.$netif.manualup
+ else
+ initqueue --onetime --name netroot-$netif netroot $netif
+ fi
;;
*) echo "dhcp: $reason";;
esac
# We don't need to check for ip= errors here, that is handled by the
# cmdline parser script
#
+# without $2 means this is for real netroot case
+# or it is for manually bring up network ie. for kdump scp vmcore
PATH=/usr/sbin:/usr/bin:/sbin:/bin
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+export PS4="ifup.$1.$$ + "
+exec >>/run/initramfs/loginit.pipe 2>>/run/initramfs/loginit.pipe
+type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+
+# Huh? No $1?
+[ -z "$1" ] && exit 1
+
+# $netif reads easier than $1
+netif=$1
+
+# enslave this interface to bond?
+if [ -e /tmp/bond.info ]; then
+ . /tmp/bond.info
+ for slave in $bondslaves ; do
+ if [ "$netif" = "$slave" ] ; then
+ netif=$bondname
+ fi
+ done
+fi
+
+# bridge this interface?
+if [ -e /tmp/bridge.info ]; then
+ . /tmp/bridge.info
+ if [ "$netif" = "$ethname" ]; then
+ if [ "$netif" = "$bondname" ] && [ -n "$DO_BOND_SETUP" ] ; then
+ : # We need to really setup bond (recursive call)
+ else
+ netif="$bridgename"
+ fi
+ fi
+fi
+
+# bail immediately if the interface is already up
+# or we don't need the network
+[ -f "/tmp/net.$netif.up" ] && exit 0
+[ -f "/tmp/root.info" ] || exit 0
+. /tmp/root.info
+
+# disable manual ifup while netroot is set for simplifying our logic
+# in netroot case we prefer netroot to bringup $netif automaticlly
+[ -n "$2" ] && [ -z "$netroot" ] && manualup="$2"
+[ -z "$netroot" ] && [ -z "$manualup" ] && exit 0
+[ -n "$manualup" ] && >/tmp/net.$netif.manualup
# Run dhclient
do_dhcp() {
echo online > /sys/class/net/$netif/uevent
- initqueue --onetime --name netroot-$netif netroot $netif
+ if [ -n "$manualup" ]; then
+ /sbin/netroot $netif -m
+ else
+ initqueue --onetime --name netroot-$netif netroot $netif
+ fi
}
# Handle static ip configuration
fi >> /tmp/net.$netif.resolv.conf
echo online > /sys/class/net/$netif/uevent
- initqueue --onetime --name netroot-$netif netroot $netif
-}
-
-export PS4="ifup.$1.$$ + "
-exec >>/run/initramfs/loginit.pipe 2>>/run/initramfs/loginit.pipe
-type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
-
-# Huh? No $1?
-[ -z "$1" ] && exit 1
-
-# $netif reads easier than $1
-netif=$1
-
-# enslave this interface to bond?
-if [ -e /tmp/bond.info ]; then
- . /tmp/bond.info
- for slave in $bondslaves ; do
- if [ "$netif" = "$slave" ] ; then
- netif=$bondname
- fi
- done
-fi
-
-# bridge this interface?
-if [ -e /tmp/bridge.info ]; then
- . /tmp/bridge.info
- if [ "$netif" = "$ethname" ]; then
- if [ "$netif" = "$bondname" ] && [ -n "$DO_BOND_SETUP" ] ; then
- : # We need to really setup bond (recursive call)
- else
- netif="$bridgename"
- fi
+ if [ -n "$manualup" ]; then
+ /sbin/netroot $netif -m
+ else
+ initqueue --onetime --name netroot-$netif netroot $netif
fi
-fi
-
-# bail immediately if the interface is already up
-# or we don't need the network
-[ -f "/tmp/net.$netif.up" ] && exit 0
-[ -f "/tmp/root.info" ] || exit 0
-. /tmp/root.info
-[ -z "$netroot" ] && exit 0
+}
# loopback is always handled the same way
if [ "$netif" = "lo" ] ; then
esac
break
done
-
exit 0
# ex: ts=8 sw=4 sts=4 et filetype=sh
PATH=/usr/sbin:/usr/bin:/sbin:/bin
-
type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
# Huh? Empty $1?
# Huh? No interface config?
[ ! -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
[ -e /tmp/root.info ] || exit 1
. /tmp/root.info
-[ -d $NEWROOT/proc ] && exit 0
-[ -z "$netroot" ] && exit 1
+if [ -z "$2" ]; then
+ [ -d $NEWROOT/proc ] && exit 0
+ [ -z "$netroot" ] && exit 1
+fi
# Let's see if we have to wait for other interfaces
# Note: exit works just fine, since the last interface to be
netif=$1
[ -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
-# handlers
-if [ "$netroot" = "dhcp" ] || [ "$netroot" = "dhcp6" ] ; then
- # Unset root so we can check later
- unset root
-
- # 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 [ -z "$new_root_path" ] ; then
- [ -n "$BOOTDEV" ] && die "No dhcp root-path received for '$BOOTDEV'"
- warn "No dhcp root-path received for '$BOOTDEV' trying other interfaces if available"
- exit 1
- fi
+# handlers when this is not called from manually network bringing up.
+if [ -z "$2" ]; then
+ if [ "$netroot" = "dhcp" ] || [ "$netroot" = "dhcp6" ] ; then
+ # Unset root so we can check later
+ unset root
+
+ # 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 [ -z "$new_root_path" ] ; then
+ [ -n "$BOOTDEV" ] && die "No dhcp root-path received for '$BOOTDEV'"
+ warn "No dhcp root-path received for '$BOOTDEV' trying other interfaces if available"
+ exit 1
+ fi
- # Set netroot to new_root_path, so cmdline parsers don't call
- netroot=$new_root_path
+ # Set netroot to new_root_path, so cmdline parsers don't call
+ netroot=$new_root_path
- # FIXME!
- for f in $hookdir/cmdline/90*.sh; do
- [ -f "$f" ] && . "$f";
- done
-else
- rootok="1"
-fi
+ # FIXME!
+ for f in $hookdir/cmdline/90*.sh; do
+ [ -f "$f" ] && . "$f";
+ done
+ else
+ rootok="1"
+ fi
-# Check: do we really know how to handle (net)root?
-[ -z "$root" ] && die "No or empty root= argument"
-[ -z "$rootok" ] && die "Don't know how to handle 'root=$root'"
+ # Check: do we really know how to handle (net)root?
+ [ -z "$root" ] && die "No or empty root= argument"
+ [ -z "$rootok" ] && die "Don't know how to handle 'root=$root'"
-handler=${netroot%%:*}
-handler=${handler%%4}
-handler=$(command -v ${handler}root)
-if [ -z "$netroot" ] || [ ! -e "$handler" ] ; then
- die "No handler for netroot type '$netroot'"
+ handler=${netroot%%:*}
+ handler=${handler%%4}
+ handler=$(command -v ${handler}root)
+ if [ -z "$netroot" ] || [ ! -e "$handler" ] ; then
+ die "No handler for netroot type '$netroot'"
+ fi
fi
# We're here, so we can assume that upping interfaces is now ok
dinfo "Resolving $dest via ARP on $netif failed"
fi
+# exit in case manually bring up network
+[ -n "$2" ] && exit 0
+
# Source netroot hooks before we start the handler
source_all $hookdir/netroot