Last active
July 7, 2025 14:02
-
-
Save scolton99/13d8cd24c53b1a8acc8246fee0fe8c80 to your computer and use it in GitHub Desktop.
Script for DAPS to wait for a service to come available on a certain port before returning
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MAX_ATTEMPTS=120 | |
if [[ -z "$1" ]]; then | |
HOST="localhost" | |
else | |
HOST="$1" | |
fi | |
if [[ -z "$2" ]]; then | |
PORT="1636" | |
else | |
PORT="$2" | |
fi | |
ATTEMPTS=1 | |
while : ; do | |
nc -w 1 -z "$HOST" "$PORT" | |
STATUS=$? | |
[[ $STATUS -eq 1 && $ATTEMPTS -lt $MAX_ATTEMPTS ]] || exit $STATUS | |
((ATTEMPTS=ATTEMPTS+1)) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment