[Libguestfs] [PATCH v2] appliance init: find NIC name for dhcpcd

Cédric Bosdonnat cbosdonnat at suse.com
Wed Jul 29 08:35:00 UTC 2015


dhcpcd requires an interface name as parameter to work. We are now
getting it from /proc/sys/net/ipv4/conf/ folder children. dhclient
on Debian also has the problem, thus use the guessed interface name
for it too.
---
 appliance/init | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/appliance/init b/appliance/init
index cca62e7..d5a428d 100755
--- a/appliance/init
+++ b/appliance/init
@@ -108,10 +108,11 @@ ip addr add 127.0.0.1/8 brd + dev lo scope host
 ip link set dev lo up
 
 if test "$guestfs_network" = 1; then
+    iface=$(ls -I all -I default -I lo /proc/sys/net/ipv4/conf)
     if dhclient --version >/dev/null 2>&1; then
-        dhclient
+        dhclient $iface
     else
-        dhcpcd
+        dhcpcd $iface
     fi
 fi
 
-- 
2.1.4




More information about the Libguestfs mailing list