Skip to content

Commit a6dda41

Browse files
authored
Merge pull request #893 from xx4h/improve-reliability
Wait up to 20 seconds for IP address
2 parents f63213d + 6393d4d commit a6dda41

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

Vagrant/logger_bootstrap.sh

+19-8
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,25 @@ fix_eth1_static_ip() {
105105
ip link set dev eth1 down
106106
ip addr flush dev eth1
107107
ip link set dev eth1 up
108-
ETH1_IP=$(ip -4 addr show eth1 | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | head -1)
109-
if [ "$ETH1_IP" == "192.168.56.105" ]; then
110-
echo "[$(date +%H:%M:%S)]: The static IP has been fixed and set to 192.168.56.105"
111-
else
112-
echo "[$(date +%H:%M:%S)]: Failed to fix the broken static IP for eth1. Exiting because this will cause problems with other VMs."
113-
echo "[$(date +%H:%M:%S)]: eth1's current IP address is $ETH1_IP"
114-
exit 1
115-
fi
108+
counter=0
109+
while :; do
110+
ETH1_IP=$(ip -4 addr show eth1 | grep -oP '(?<=inet\s)\d+(\.\d+){3}' | head -1)
111+
if [ "$ETH1_IP" == "192.168.56.105" ]; then
112+
echo "[$(date +%H:%M:%S)]: The static IP has been fixed and set to 192.168.56.105"
113+
break
114+
else
115+
if [ $counter -le 20 ]; then
116+
let counter=counter+1
117+
echo "[$(date +%H:%M:%S)]: Waiting for IP $counter/20 seconds"
118+
sleep 1
119+
continue
120+
else
121+
echo "[$(date +%H:%M:%S)]: Failed to fix the broken static IP for eth1. Exiting because this will cause problems with other VMs."
122+
echo "[$(date +%H:%M:%S)]: eth1's current IP address is $ETH1_IP"
123+
exit 1
124+
fi
125+
fi
126+
done
116127
fi
117128

118129
# Make sure we do have a DNS resolution

0 commit comments

Comments
 (0)