Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save osamaAbdullah/34665cb3022478ea0d9f649fca37df1a to your computer and use it in GitHub Desktop.
Save osamaAbdullah/34665cb3022478ea0d9f649fca37df1a to your computer and use it in GitHub Desktop.
wait_for_dependencies
#!/bin/sh
SERVICES=$(echo "$DEPENDENCIES" | tr "|" "\n")
resolve()
{
for SERVICE in $SERVICES; do
ip=$(nslookup "$SERVICE" | awk '/^Address: / { print $2 }')
if echo "$ip" | grep -Eq "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b"; then
echo "$SERVICE ===> $ip"
else
echo "can not revolve $SERVICE --XX--"
sleep 0.1
resolve
fi
done
}
resolve
exec "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment