]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
network/netroot.sh: better handling of $netroot and dhcp
authorHarald Hoyer <harald@redhat.com>
Thu, 10 Sep 2015 11:23:32 +0000 (13:23 +0200)
committerHarald Hoyer <harald@redhat.com>
Thu, 10 Sep 2015 11:23:32 +0000 (13:23 +0200)
if $netroot is emtpy, get it from cmdline

check cmdline directly for root=dhcp(6) and netroot=dhcp(6)

modules.d/40network/netroot.sh

index 8f6945fe8f457b9838188bcc10a38d236bd59af3..3aa5a0d2da3431ccab9792690c512357e8ef8f72 100755 (executable)
@@ -14,6 +14,11 @@ command -v setup_net >/dev/null || . /lib/net-lib.sh
 # no sense in doing something if no (net)root info is available
 # or root is already there
 [ -d $NEWROOT/proc ] && exit 0
+
+if [ -z "$netroot" ]; then
+    netroot=$(getarg netroot=)
+fi
+
 [ -z "$netroot" ] && exit 1
 
 # Set or override primary interface
@@ -35,7 +40,7 @@ esac
 # Figure out the handler for root=dhcp by recalling all netroot cmdline
 # handlers when this is not called from manually network bringing up.
 if [ -z "$2" ]; then
-    if [ "$netroot" = "dhcp" ] || [ "$netroot" = "dhcp6" ] ; then
+    if getarg "root=dhcp" || getarg "netroot=dhcp" || getarg "root=dhcp6" || getarg "netroot=dhcp6"; then
         # Load dhcp options
         [ -e /tmp/dhclient.$netif.dhcpopts ] && . /tmp/dhclient.$netif.dhcpopts
 
@@ -47,6 +52,8 @@ if [ -z "$2" ]; then
             exit 1
         fi
 
+        rm -f -- $hookdir/initqueue/finished/dhcp.sh
+
         # Set netroot to new_root_path, so cmdline parsers don't call
         netroot=$new_root_path
 
@@ -76,9 +83,7 @@ source_hook netroot $netif
 
 # 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
-    rm -f -- $hookdir/initqueue/finished/dhcp.sh
-    # Network rootfs mount successful - save interface info for ifcfg etc.
-    save_netinfo $netif
-fi
+[ -n "$handler" ] && "$handler" "$netif" "$netroot" "$NEWROOT"
+save_netinfo $netif
+
 exit 0