summaryrefslogtreecommitdiff
path: root/global/overlay/usr/local/bin/ping-check
blob: 26c99ed9e1544419132c9a029dacd34a453ba6a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env bash
#
# Ping until reply or MAX_TRIES. One try == 1s.
#

MAX_TRIES=10
LOGTAG="sunet_docker_ping_check"

count=0
until ping -c1 $1 &> /dev/null
do
    if [ $count -gt $MAX_TRIES ]
    then
        logger -t "$LOGTAG" "No response from $1 after $MAX_TRIES tries."
        exit 1
    fi
    sleep 1
    count=$[$count+1]
done