Use "ip address show dev" to fix matching interfaces with dynamic IP

This should fix DHCP-managed interfaces from getting thrown a:
"no IP found for $IFACE" error message

2: wlp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether d0:57:7b:8f:21:59 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.40/24 brd 192.168.1.255 scope global dynamic wlp1s0
       valid_lft 76951sec preferred_lft 76951sec
    inet6 fe80::8aa8:51b1:4088:d7c0/64 scope link
       valid_lft forever preferred_lft forever
This commit is contained in:
Vincent Legoll 2017-08-11 12:13:27 +02:00
parent d3ee6402f6
commit 4d148f1a09
1 changed files with 1 additions and 1 deletions

View File

@ -41,7 +41,7 @@ test -f $IMG && test -f $KERNEL || { echo "$IMG or $KERNEL not found"; exit; }
# some more checks # some more checks
[[ "$NO_NETWORK" != "1" ]] && { [[ "$NO_NETWORK" != "1" ]] && {
IP=$( ip address | grep "global $IFACE" | grep -oP '\d{1,3}(.\d{1,3}){3}' | head -1 ) IP=$( ip address show dev "$IFACE" | grep global | grep -oP '\d{1,3}(.\d{1,3}){3}' | head -1 )
[[ "$IP" == "" ]] && { echo "no IP found for $IFACE"; NO_NETWORK=1; } [[ "$IP" == "" ]] && { echo "no IP found for $IFACE"; NO_NETWORK=1; }
type brctl &>/dev/null || { echo "brctl is not installed"; NO_NETWORK=1; } type brctl &>/dev/null || { echo "brctl is not installed"; NO_NETWORK=1; }
modprobe tun &>/dev/null modprobe tun &>/dev/null