File tree 1 file changed +19
-8
lines changed
1 file changed +19
-8
lines changed Original file line number Diff line number Diff line change @@ -105,14 +105,25 @@ fix_eth1_static_ip() {
105
105
ip link set dev eth1 down
106
106
ip addr flush dev eth1
107
107
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
116
127
fi
117
128
118
129
# Make sure we do have a DNS resolution
You can’t perform that action at this time.
0 commit comments