Skip to content

Commit

Permalink
Merge pull request #90 from krufab/busybox-timeout-update-fix
Browse files Browse the repository at this point in the history
Added support for new busybox timeout version
  • Loading branch information
douglas-gibbons authored Feb 2, 2020
2 parents 54d1f0b + ed77b63 commit 5fc2194
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions wait-for-it.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Use this script to test if a given TCP host/port are available
# Use this script to test if a given TCP host/port are available

WAITFORIT_cmdname=${0##*/}

Expand Down Expand Up @@ -141,16 +141,20 @@ WAITFORIT_STRICT=${WAITFORIT_STRICT:-0}
WAITFORIT_CHILD=${WAITFORIT_CHILD:-0}
WAITFORIT_QUIET=${WAITFORIT_QUIET:-0}

# check to see if timeout is from busybox?
# Check to see if timeout is from busybox?
WAITFORIT_TIMEOUT_PATH=$(type -p timeout)
WAITFORIT_TIMEOUT_PATH=$(realpath $WAITFORIT_TIMEOUT_PATH 2>/dev/null || readlink -f $WAITFORIT_TIMEOUT_PATH)

WAITFORIT_BUSYTIMEFLAG=""
if [[ $WAITFORIT_TIMEOUT_PATH =~ "busybox" ]]; then
WAITFORIT_ISBUSY=1
WAITFORIT_ISBUSY=1
# Check if busybox timeout uses -t flag
# (recent Alpine versions don't support -t anymore)
if timeout &>/dev/stdout | grep -q -e '-t '; then
WAITFORIT_BUSYTIMEFLAG="-t"

fi
else
WAITFORIT_ISBUSY=0
WAITFORIT_BUSYTIMEFLAG=""
WAITFORIT_ISBUSY=0
fi

if [[ $WAITFORIT_CHILD -gt 0 ]]; then
Expand Down

0 comments on commit 5fc2194

Please sign in to comment.