Commit 899687d3 authored by Kroese's avatar Kroese Committed by GitHub
Browse files

fix: Retry if needed

parent 2d97bc1c
Loading
Loading
Loading
Loading
+32 −24
Original line number Diff line number Diff line
@@ -5,6 +5,10 @@ info () { echo -e "\E[1;34m❯\E[1;36m $1\E[0m" ; }
error () { echo -e >&2 "\E[1;31m❯ ERROR: $1\E[0m" ; }

sleep 1
retry=true

while [ "$retry" = true ]
do

  # Retrieve IP from guest VM
  RESPONSE=$(curl -s -m 16 -S http://127.0.0.1:2210/read?command=10 2>&1)
@@ -23,7 +27,7 @@ rest=${rest#*:}
  rest=${rest%%,*}
  PORT=${rest%%\"*}

[ -z "${PORT}" ] && error "Guest has not set a portnumber yet.." && exit 1
  [ -z "${PORT}" ] && error "Guest has not set a portnumber yet.." && sleep 3 && continue

  # Retrieve the IP address
  if [[ ! "${RESPONSE}" =~ "eth0" ]] ; then
@@ -36,7 +40,11 @@ rest=${rest#*:}
  rest=${rest#*\"}
  IP=${rest%%\"*}

[ -z "${IP}" ] && error "Guest has not received an IP yet.." && exit 1
  [ -z "${IP}" ] && error "Guest has not received an IP yet.." && sleep 3 && continue

  retry=false

done

if [[ "$IP" == "20.20"* ]]; then
  MSG="port ${PORT}"