From da2c0b2200148ae5754f00ac2e7953b4b55eb88f Mon Sep 17 00:00:00 2001 From: nacho Date: Wed, 19 Sep 2018 18:13:15 -0600 Subject: [PATCH] autodetect default interface --- qemu-pi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qemu-pi.sh b/qemu-pi.sh index 729f8b0..fce07c9 100755 --- a/qemu-pi.sh +++ b/qemu-pi.sh @@ -28,7 +28,6 @@ IMG=$1 KERNEL=kernel-qemu-4.4.34-jessie NO_NETWORK=1 # set to 1 to skip network configuration -IFACE=enp3s0 # interface that we currently use for internet BRIDGE=br0 # name for the bridge we will create to share network with the raspbian img MAC='52:54:be:36:42:a9' # comment this line for random MAC (maybe annoying if on DHCP) BINARY_PATH=/usr/bin # path prefix for binaries @@ -38,6 +37,7 @@ NO_GRAPHIC=0 # set to 1 to start in no graphic mode type qemu-system-arm &>/dev/null || { echo "QEMU ARM not found" ; exit 1; } test -f $IMG && test -f $KERNEL || { echo "$IMG or $KERNEL not found"; exit 1; } +IFACE="$( ip r | grep "default via" | awk '{ print $5 }' | head -1 )" [[ "$IFACE" == "" ]] || [[ "$BRIDGE" == "" ]] && NO_NETWORK=1 # some more checks