Repeatedly fetching a URL until the response contains "state: INIT"
Inconsistent logic

In one place the script checks http://$HOSTNAME:8080/beat,
in another, it checks for a local process listening on port 8080.
This only makes sense if $HOSTNAME the name of the local machine.
It will make more sense to replace $HOSTNAME with hard-coded localhost.

Use exit code directly

Instead of this:


DATA=$(wget -O - -q -t 1 http://$HOSTNAME:8080/beat)
if [ $? -eq 0 ]
then
    break



You could use the exit code directly like this:

if DATA=$(wget -O - -q -t 1 http://$HOSTNAME:8080/beat)
then
    break


Another way:

DATA=$(wget -O - -q -t 1 http://$HOSTNAME:8080/beat) &amp;&amp; break


Math in Bash

Instead of this:


let RETRY-=1



There are slightly simpler alternatives:

((RETRY -= 1))
((RETRY--))