github.com/drud/ddev@v1.21.5-alpha1.0.20230226034409-94fcc4b94453/containers/ddev-ssh-agent/files/healthcheck.sh (about)

     1  #!/bin/bash
     2  
     3  # ddev-ssh-agent healthcheck
     4  
     5  set -eo pipefail
     6  sleeptime=59
     7  
     8  # Make sure that both socat and ssh-agent are running
     9  # Since docker doesn't provide a lazy period for startup,
    10  # we track health. If the last check showed healthy
    11  # as determined by existence of /tmp/healthy, then
    12  # sleep at startup. This requires the timeout to be set
    13  # higher than the sleeptime used here.
    14  if [ -f /tmp/healthy ]; then
    15      printf "container was previously healthy, so sleeping ${sleeptime} seconds before continuing healthcheck...  "
    16      sleep ${sleeptime}
    17  fi
    18  if killall -0 socat ssh-agent; then
    19      printf "healthy"
    20      touch /tmp/healthy
    21      exit 0
    22  fi
    23  rm -f /tmp/healthy
    24  exit 1
    25