Skip to content

Commit

Permalink
use loop for waiting for active network device
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Lange committed Aug 4, 2015
1 parent 299b256 commit 09eafb9
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lib/get-boot-info
Expand Up @@ -64,12 +64,19 @@ setnet() {

# get network parameters
# first get first active network device
local dev dummy
dev=$(ip ad show up | awk -F': ' '/^[0-9]/ && ! / lo:/ {print $2;exit}')
if [ -z "$dev" ]; then
sleep 3 # if interface needs some time to come up
dev=$(ip ad show up | awk -F': ' '/^[0-9]/ && ! / lo:/ {print $2;exit}')
fi
local dev dummy n

n=0
until [ $n = 7 ]; do
dev=$(ip ad show up | awk -F': ' '/^[0-9]/ && ! / lo:/ {print $2;exit}')
if [ -z "$dev" ]; then
sleep 2 # if interface needs some time to come up
else
break
fi
n=$(($n + 1))
done

read IPADDR NETMASK BROADCAST dummy<<<$(ifdata -p $dev)
GATEWAYS=$(ip route | awk '/^default/ {print $3}')

Expand Down

0 comments on commit 09eafb9

Please sign in to comment.