From 4ecfc66877988361d1041c924b1a006fcdb977b1 Mon Sep 17 00:00:00 2001 From: Julien Eyraud Date: Thu, 24 Feb 2022 16:36:59 +0100 Subject: [PATCH] Support docker compose v2 (#1799) --- scripts/bitwarden.sh | 12 +++++++++++- scripts/run.sh | 22 ++++++++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/scripts/bitwarden.sh b/scripts/bitwarden.sh index 280a5abec0..013e7d2836 100755 --- a/scripts/bitwarden.sh +++ b/scripts/bitwarden.sh @@ -29,6 +29,12 @@ if [ $# -eq 2 ] then OUTPUT=$2 fi +if command -v docker-compose &> /dev/null +then + dccmd='docker-compose' +else + dccmd='docker compose' +fi SCRIPTS_DIR="$OUTPUT/scripts" GITHUB_BASE_URL="https://raw.githubusercontent.com/bitwarden/server/master" @@ -40,7 +46,11 @@ KEYCONNECTORVERSION="1.0.1" echo "bitwarden.sh version $COREVERSION" docker --version -docker-compose --version +if [[ "$dccmd" == "docker compose" ]]; then + $dccmd version +else + $dccmd --version +fi echo "" diff --git a/scripts/run.sh b/scripts/run.sh index 656619ff57..98a19566c1 100755 --- a/scripts/run.sh +++ b/scripts/run.sh @@ -2,6 +2,12 @@ set -e # Setup +if command -v docker-compose &> /dev/null +then + dccmd='docker-compose' +else + dccmd='docker compose' +fi CYAN='\033[0;36m' RED='\033[1;31m' @@ -102,19 +108,19 @@ function install() { function dockerComposeUp() { dockerComposeFiles dockerComposeVolumes - docker-compose up -d + $dccmd up -d } function dockerComposeDown() { dockerComposeFiles - if [ $(docker-compose ps | wc -l) -gt 2 ]; then - docker-compose down + if [ $($dccmd ps | wc -l) -gt 2 ]; then + $dccmd down fi } function dockerComposePull() { dockerComposeFiles - docker-compose pull + $dccmd pull } function dockerComposeFiles() { @@ -181,7 +187,7 @@ function forceUpdateLetsEncrypt() { function updateDatabase() { pullSetup dockerComposeFiles - MSSQL_ID=$(docker-compose ps -q mssql) + MSSQL_ID=$($dccmd ps -q mssql) docker run -i --rm --name setup --network container:$MSSQL_ID \ -v $OUTPUT_DIR:/bitwarden --env-file $ENV_DIR/uid.env bitwarden/setup:$COREVERSION \ dotnet Setup.dll -update 1 -db 1 -os $OS -corev $COREVERSION -webv $WEBVERSION -keyconnectorv $KEYCONNECTORVERSION @@ -190,11 +196,11 @@ function updateDatabase() { function updatebw() { KEY_CONNECTOR_ENABLED=$(grep -A3 'enable_key_connector:' $OUTPUT_DIR/config.yml | tail -n1 | awk '{ print $2}') - CORE_ID=$(docker-compose ps -q admin) - WEB_ID=$(docker-compose ps -q web) + CORE_ID=$($dccmd ps -q admin) + WEB_ID=$($dccmd ps -q web) if [ "$KEY_CONNECTOR_ENABLED" = true ]; then - KEYCONNECTOR_ID=$(docker-compose ps -q key-connector) + KEYCONNECTOR_ID=$($dccmd ps -q key-connector) fi if [ $KEYCONNECTOR_ID ] &&