From 2253204393ffe2d8c1c961b1f47d4e94a15c7014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lison=20Fernandes?= Date: Wed, 20 Nov 2024 16:50:20 +0000 Subject: [PATCH 1/4] Revert "BREAKING CHANGE: remove support for deprecated `docker-compose` CLI (#301)" This reverts commit 846523760d4425d9ef2cc5f4d174f32a8ae70ad5. --- bitwarden.sh | 18 +++++++++++------- run.sh | 24 ++++++++++++------------ 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/bitwarden.sh b/bitwarden.sh index 8b03510..2f7c42b 100755 --- a/bitwarden.sh +++ b/bitwarden.sh @@ -2,9 +2,9 @@ set -e cat << "EOF" - _ _ _ _ -| |__ (_) |___ ____ _ _ __ __| | ___ _ __ -| '_ \| | __\ \ /\ / / _` | '__/ _` |/ _ \ '_ \ + _ _ _ _ +| |__ (_) |___ ____ _ _ __ __| | ___ _ __ +| '_ \| | __\ \ /\ / / _` | '__/ _` |/ _ \ '_ \ | |_) | | |_ \ V V / (_| | | | (_| | __/ | | | |_.__/|_|\__| \_/\_/ \__,_|_| \__,_|\___|_| |_| @@ -33,7 +33,7 @@ if [ "$EUID" -eq 0 ]; then echo -e "Continuing...." ;; *) - exit 1 + exit 1 ;; esac fi @@ -68,7 +68,11 @@ KEYCONNECTORVERSION="2024.8.0" echo "bitwarden.sh version $COREVERSION" docker --version -docker compose version +if [[ "$dccmd" == "docker compose" ]]; then + $dccmd version +else + $dccmd --version +fi echo "" @@ -151,7 +155,7 @@ function compressLogs() { exit 1 fi fi - + # Validate end date format and order if [ -n "$END_DATE" ]; then validateDateFormat "$END_DATE" "end" @@ -257,7 +261,7 @@ case $1 in $SCRIPTS_DIR/run.sh uninstall $OUTPUT ;; "compresslogs") - checkOutputDirExists + checkOutputDirExists compressLogs $OUTPUT $2 $3 ;; "help") diff --git a/run.sh b/run.sh index 1c207b8..50d3cdb 100755 --- a/run.sh +++ b/run.sh @@ -2,13 +2,13 @@ set -e # Setup -if ! docker compose version &> /dev/null +if command -v docker-compose &> /dev/null then - echo "Error: 'docker compose' is not installed. Please install Docker Compose." - exit 1 + dccmd='docker-compose' +else + dccmd='docker compose' fi - CYAN='\033[0;36m' RED='\033[1;31m' NC='\033[0m' # No Color @@ -108,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() { @@ -191,7 +191,7 @@ function updateDatabase() { # only use container network driver if using the included mssql image if grep -q 'Data Source=tcp:mssql,1433' "$ENV_DIR/global.override.env" then - MSSQL_ID=$(docker compose ps -q mssql) + MSSQL_ID=$($dccmd ps -q mssql) local docker_network_args="--network container:$MSSQL_ID" fi @@ -203,11 +203,11 @@ function updateDatabase() { function updatebw() { KEY_CONNECTOR_ENABLED=$(grep 'enable_key_connector:' $OUTPUT_DIR/config.yml | 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 ] && From e6991a254ad440a0450d06d5f99664b0ef787cc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lison=20Fernandes?= Date: Fri, 22 Nov 2024 12:34:56 +0000 Subject: [PATCH 2/4] Default to docker compose --- bitwarden.sh | 6 +++--- run.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bitwarden.sh b/bitwarden.sh index 2f7c42b..33d19cf 100755 --- a/bitwarden.sh +++ b/bitwarden.sh @@ -50,11 +50,11 @@ if [ $# -eq 2 ] then OUTPUT=$2 fi -if command -v docker-compose &> /dev/null +if command -v docker compose &> /dev/null then - dccmd='docker-compose' -else dccmd='docker compose' +else + dccmd='docker-compose' fi SCRIPTS_DIR="$OUTPUT/scripts" diff --git a/run.sh b/run.sh index 50d3cdb..f154ed4 100755 --- a/run.sh +++ b/run.sh @@ -2,11 +2,11 @@ set -e # Setup -if command -v docker-compose &> /dev/null +if command -v docker compose &> /dev/null then - dccmd='docker-compose' -else dccmd='docker compose' +else + dccmd='docker-compose' fi CYAN='\033[0;36m' From 6a4d1459bde9cb0a3064918a82f8865af68efaf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lison=20Fernandes?= Date: Fri, 22 Nov 2024 13:05:34 +0000 Subject: [PATCH 3/4] Add editorconfig from bitwarden/gh-actions --- .editorconfig | 18 ++++++++++++++++++ bitwarden.sh | 12 ++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..1895dae --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +# EditorConfig is awesome: http://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Don't use tabs for indentation. +[*] +indent_size = 4 +indent_style = space +tab_width = 4 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +guidelines = 120 + +[*.{json,yml}] +indent_size = 2 diff --git a/bitwarden.sh b/bitwarden.sh index 33d19cf..81bf7ca 100755 --- a/bitwarden.sh +++ b/bitwarden.sh @@ -2,9 +2,9 @@ set -e cat << "EOF" - _ _ _ _ -| |__ (_) |___ ____ _ _ __ __| | ___ _ __ -| '_ \| | __\ \ /\ / / _` | '__/ _` |/ _ \ '_ \ + _ _ _ _ +| |__ (_) |___ ____ _ _ __ __| | ___ _ __ +| '_ \| | __\ \ /\ / / _` | '__/ _` |/ _ \ '_ \ | |_) | | |_ \ V V / (_| | | | (_| | __/ | | | |_.__/|_|\__| \_/\_/ \__,_|_| \__,_|\___|_| |_| @@ -33,7 +33,7 @@ if [ "$EUID" -eq 0 ]; then echo -e "Continuing...." ;; *) - exit 1 + exit 1 ;; esac fi @@ -155,7 +155,7 @@ function compressLogs() { exit 1 fi fi - + # Validate end date format and order if [ -n "$END_DATE" ]; then validateDateFormat "$END_DATE" "end" @@ -261,7 +261,7 @@ case $1 in $SCRIPTS_DIR/run.sh uninstall $OUTPUT ;; "compresslogs") - checkOutputDirExists + checkOutputDirExists compressLogs $OUTPUT $2 $3 ;; "help") From f62f655615fadc008e656c29b797a4d9a6c31fd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lison=20Fernandes?= Date: Wed, 27 Nov 2024 16:39:21 +0000 Subject: [PATCH 4/4] Add logs --- bitwarden.sh | 9 ++++++--- run.sh | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/bitwarden.sh b/bitwarden.sh index 5128052..e219e39 100755 --- a/bitwarden.sh +++ b/bitwarden.sh @@ -50,11 +50,14 @@ if [ $# -eq 2 ] then OUTPUT=$2 fi -if command -v docker compose &> /dev/null -then +if docker compose &> /dev/null; then dccmd='docker compose' -else +elif command -v docker-compose &> /dev/null; then dccmd='docker-compose' + echo "docker compose not found, falling back to docker-compose." +else + echo "Error: Neither 'docker compose' nor 'docker-compose' commands were found. Please install Docker Compose." >&2 + exit 1 fi SCRIPTS_DIR="$OUTPUT/scripts" diff --git a/run.sh b/run.sh index f154ed4..57d2f9f 100755 --- a/run.sh +++ b/run.sh @@ -2,11 +2,14 @@ set -e # Setup -if command -v docker compose &> /dev/null -then +if docker compose &> /dev/null; then dccmd='docker compose' -else +elif command -v docker-compose &> /dev/null; then dccmd='docker-compose' + echo "docker compose not found, falling back to docker-compose." +else + echo "Error: Neither 'docker compose' nor 'docker-compose' commands were found. Please install Docker Compose." >&2 + exit 1 fi CYAN='\033[0;36m'