Skip to content

Instantly share code, notes, and snippets.

@withinboredom
Created October 16, 2015 18:33
Show Gist options
  • Save withinboredom/989a801d2d5d8c52b8bd to your computer and use it in GitHub Desktop.
Save withinboredom/989a801d2d5d8c52b8bd to your computer and use it in GitHub Desktop.
function getAgents() {
getIp "nginx"
echo "$dockerip www.thecassinagroup.dev" >> /etc/hosts
retry=10
while [ true ]
do
retry=$(expr $retry - 1)
if [ "$retry" == "0" ]
then
echo "Unable to get agent subdomains, this might be a missing or incorrect hosts entry"
return
fi
status=$(curl --max-time 10 -sL -w "%{http_code}\\n" "http://$tenantId/api/agents?json=true&retry=$retry" -o /dev/null)
if [ "$status" == "200" ]
then
break
fi
echo "site not available yet, trying again after 10s, got code: $status"
sleep 10
done
echo "Retrieving agents..."
curl -so agents.json --verbose http://$tenantId/api/agents/?json=true\&retry=$retry
echo "Processing agents..."
echo
cat agents.json | jq --raw-output '.[][].Alias' | while read agent
do
echo "$DISPLAYIP $agent${tenantId#www}"
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment