fix: Increase sleep

This commit is contained in:
Kroese 2023-11-08 04:21:07 +01:00 committed by GitHub
parent 899687d3f2
commit 8e41b4e567

View File

@ -4,22 +4,23 @@ set -Eeuo pipefail
info () { echo -e "\E[1;34m\E[1;36m $1\E[0m" ; } info () { echo -e "\E[1;34m\E[1;36m $1\E[0m" ; }
error () { echo -e >&2 "\E[1;31m ERROR: $1\E[0m" ; } error () { echo -e >&2 "\E[1;31m ERROR: $1\E[0m" ; }
sleep 1
retry=true retry=true
while [ "$retry" = true ] while [ "$retry" = true ]
do do
sleep 2
# Retrieve IP from guest VM # Retrieve IP from guest VM
RESPONSE=$(curl -s -m 16 -S http://127.0.0.1:2210/read?command=10 2>&1) RESPONSE=$(curl -s -m 16 -S http://127.0.0.1:2210/read?command=10 2>&1)
if [[ ! "${RESPONSE}" =~ "\"success\"" ]] ; then if [[ ! "${RESPONSE}" =~ "\"success\"" ]] ; then
error "Failed to connect to guest: $RESPONSE" && exit 1 error "Failed to connect to guest: $RESPONSE" && continue
fi fi
# Retrieve the HTTP port number # Retrieve the HTTP port number
if [[ ! "${RESPONSE}" =~ "\"http_port\"" ]] ; then if [[ ! "${RESPONSE}" =~ "\"http_port\"" ]] ; then
error "Failed to parse response from guest: $RESPONSE" && exit 1 error "Failed to parse response from guest: $RESPONSE" && continue
fi fi
rest=${RESPONSE#*http_port} rest=${RESPONSE#*http_port}
@ -27,11 +28,11 @@ do
rest=${rest%%,*} rest=${rest%%,*}
PORT=${rest%%\"*} PORT=${rest%%\"*}
[ -z "${PORT}" ] && error "Guest has not set a portnumber yet.." && sleep 3 && continue [ -z "${PORT}" ] && continue
# Retrieve the IP address # Retrieve the IP address
if [[ ! "${RESPONSE}" =~ "eth0" ]] ; then if [[ ! "${RESPONSE}" =~ "eth0" ]] ; then
error "Failed to parse response from guest: $RESPONSE" && exit 1 error "Failed to parse response from guest: $RESPONSE" && continue
fi fi
rest=${RESPONSE#*eth0} rest=${RESPONSE#*eth0}
@ -40,7 +41,7 @@ do
rest=${rest#*\"} rest=${rest#*\"}
IP=${rest%%\"*} IP=${rest%%\"*}
[ -z "${IP}" ] && error "Guest has not received an IP yet.." && sleep 3 && continue [ -z "${IP}" ] && continue
retry=false retry=false
@ -57,5 +58,3 @@ info "--------------------------------------------------------"
info " You can now login to DSM at ${MSG}" info " You can now login to DSM at ${MSG}"
info "--------------------------------------------------------" info "--------------------------------------------------------"
echo "" echo ""
exit 0