From de258d0ec2bd729673c467855868789dbb5d62d3 Mon Sep 17 00:00:00 2001 From: Tommy Date: Sun, 20 Nov 2022 04:45:54 -0500 Subject: [PATCH] Support Docker Compose v2 (#2) This commit adds detection for Docker Compose v2 (a.k.a. `docker-compose-plugin`) and uses the proper command (either `docker-compose` or `docker compose`) to run the containers. Co-authored-by: Michael Baudino --- init-certificate.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/init-certificate.sh b/init-certificate.sh index cfa81f1..9cdf1cd 100755 --- a/init-certificate.sh +++ b/init-certificate.sh @@ -1,7 +1,11 @@ #!/bin/bash -if ! [ -x "$(command -v docker-compose)" ]; then - echo 'Error: docker-compose is not installed.' >&2 +if [ -x "$(command -v docker-compose)" ]; then + DOCKER_COMPOSE_CMD="docker-compose" +elif docker compose version; then + DOCKER_COMPOSE_CMD="docker compose" +else + echo 'Error: neither docker-compose (v1) nor docker-compose-plugin (v2) is installed.' >&2 exit 1 fi @@ -32,7 +36,7 @@ for domain in "${domains[@]}"; do domain_args="$domain_args -d $domain" done -docker-compose run -p 80:80 --rm --entrypoint "\ +${DOCKER_COMPOSE_CMD} run -p 80:80 --rm --entrypoint "\ sh -c \"certbot certonly --standalone \ --register-unsafely-without-email \ $domain_args \ @@ -40,4 +44,4 @@ docker-compose run -p 80:80 --rm --entrypoint "\ --force-renewal && \ ln -fs /etc/letsencrypt/live/$domains/ /etc/letsencrypt/active\"" certbot echo -echo "After running 'docker-compose up --detach' you can share your proxy as: https://signal.tube/#$domains" +echo "After running '${DOCKER_COMPOSE_CMD} up --detach' you can share your proxy as: https://signal.tube/#$domains"