From 38165c5568b29d95e9e778bfe23ed72928f3e9d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Heleno?= Date: Fri, 15 Mar 2024 09:56:15 -0300 Subject: [PATCH] feat: Container runtime detection (#38) --- bin/phpctl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/bin/phpctl b/bin/phpctl index 2c58b6b..a15142e 100755 --- a/bin/phpctl +++ b/bin/phpctl @@ -9,9 +9,21 @@ fi PHP_VERSION=${PHP_VERSION:-82} PHPCTL_IMAGE=${PHPCTL_IMAGE:-opencodeco/phpctl:php$PHP_VERSION} PHPCTL_TTY=${PHPCTL_TTY:--it} -PHPCTL_RUNTIME=${PHPCTL_RUNTIME:-docker} +PHPCTL_RUNTIME=${PHPCTL_RUNTIME:-detect} PHPCTL_USER=${PHPCTL_USER:-root} +if [ "${PHPCTL_RUNTIME}" == "detect" ]; then + PHPCTL_RUNTIME= + if command -v docker > /dev/null 2>&1; then + PHPCTL_RUNTIME=docker + elif command -v podman > /dev/null 2>&1; then + PHPCTL_RUNTIME=podman + else + echo "Could not find neither \"docker\" nor \"podman\", aborting" + exit 1 + fi +fi + for file in "$PHPCTL_DIR"/src/*.sh; do # shellcheck source=src/php.sh . "$file"