Skip to content

Commit

Permalink
Add a runtime detection & selection of available container runtime (#815
Browse files Browse the repository at this point in the history
)

* Add a runtime detection & selection of available container runtime

* Fix styling
  • Loading branch information
danielszot authored Nov 21, 2024
1 parent d29a9ac commit 1071f5d
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions devops/scripts/asa/run_asa.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

set -e

# Tested and supported runtimes: podman, docker
CONTAINER_RUNTIME="docker"

DISTROS=("ubuntu22" "centos8")
SUPPORTED_RUNTIMES=("docker" "podman")

function command_exists() {
command -v "$1" >/dev/null 2>&1
}

function echo_header {
echo ""
Expand All @@ -17,7 +19,23 @@ function echo_header {
echo "============================================================="
}

if ! dpkg --list ${CONTAINER_RUNTIME} > /dev/null && ! rpm -q ${CONTAINER_RUNTIME} > /dev/null; then
# Loop through the supported runtimes and select the first one that is present
for RUNTIME in "${SUPPORTED_RUNTIMES[@]}"; do
if command_exists "${RUNTIME}"; then
CONTAINER_RUNTIME="${RUNTIME}"
break
fi
done

# Check if a container runtime was found
if [ -z "${CONTAINER_RUNTIME}" ]; then
echo "No supported container runtime found. One of the following is required: " "${SUPPORTED_RUNTIMES[@]}"
exit 1
else
echo "Using container runtime: ${CONTAINER_RUNTIME}"
fi

if ! dpkg --list "${CONTAINER_RUNTIME}" > /dev/null && ! rpm -q "${CONTAINER_RUNTIME}" > /dev/null; then
echo "Install prerequisites first: ${CONTAINER_RUNTIME}"
exit 1
fi
Expand Down

0 comments on commit 1071f5d

Please sign in to comment.