#!/bin/sh set -eu [ -n "${DEBUG:-}" ] && set -x healthcheck_with_retry() { local container="${1:-}" podman inspect --format '{{with .Config.Healthcheck}}{{.StartPeriod}} {{.Timeout}} {{.Retries}}{{end}}' "$container" | ( read -r start_period timeout retries test -n "$start_period$timeout$retries" || return sleep "$start_period" podman-healthcheck "$container" && return count=0 while [ "$count" -lt "$retries" ]; do sleep "$timeout" podman-healthcheck "$container" && return count=$((count + 1)) done ) } main() { podman events --filter 'type=container' --filter 'event=start' --format '{{.ID}}' | while read -r container; do healthcheck_with_retry "$container" || true done } main $@