From 7b2737bf5fbb1c5fa597f60d4adbe80521e56717 Mon Sep 17 00:00:00 2001 From: nachoparker Date: Mon, 18 Jun 2018 15:00:37 +0200 Subject: nc-static-IP: autodetect default interface --- etc/ncp-config.d/nc-static-IP.sh | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'etc') diff --git a/etc/ncp-config.d/nc-static-IP.sh b/etc/ncp-config.d/nc-static-IP.sh index 30f5e9bd..25e089d9 100644 --- a/etc/ncp-config.d/nc-static-IP.sh +++ b/etc/ncp-config.d/nc-static-IP.sh @@ -18,6 +18,8 @@ configure() local GW="$( ip r | grep "default via" | awk '{ print $3 }' )" local DNS="$( grep nameserver /etc/resolv.conf | head -1 | awk '{ print $2 }' )" [[ "$DNS" == "" ]] && DNS="$GW" + local IFACE="$( ip r | grep "default via" | awk '{ print $5 }' | head -1 )" + [[ "$IFACE" == "" ]] && { echo "Couldn't find default interface"; exit 1; } ## DHCPCD [[ -f /etc/dhcpcd.conf ]] && { @@ -34,7 +36,7 @@ configure() cat >> /etc/dhcpcd.conf < /etc/network/interfaces <