Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 24 additions & 26 deletions compose-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -323,34 +323,32 @@ function checkFolders() {
return $EXIT_CODE
}

function composeVersion() {
#Checking whether "set -e" shell option should be restored after Compose version check
FLAG_SET=false
if [[ $SHELLOPTS =~ errexit ]]; then
set +e
FLAG_SET=true
function checkComposeVersion() {
# Check Docker CLI availability
if ! command -v docker >/dev/null 2>&1; then
echo "Docker is not installed or not available in PATH. Please install Docker." >&2
return 1
fi

#Checking Compose V1 availablity
docker-compose version >/dev/null 2>&1
if [ $? -eq 0 ]; then status_v1=true; else status_v1=false; fi

#Checking Compose V2 availablity
docker compose version >/dev/null 2>&1
if [ $? -eq 0 ]; then status_v2=true; else status_v2=false; fi

COMPOSE_VERSION=""

if $status_v2 ; then
COMPOSE_VERSION="V2"
elif $status_v1 ; then
COMPOSE_VERSION="V1"
else
echo "Docker Compose plugin is not detected. Please check your environment." >&2
exit 1
# Check Docker Compose v2+ availability (plugin)
if ! docker compose version >/dev/null 2>&1; then
echo "Docker Compose v2 or newer is required. 'docker compose' (the Compose plugin) was not detected. Please update Docker to the latest version." >&2
return 1
fi
return 0
}

echo $COMPOSE_VERSION
# Initialize Compose command on sourcing/executing this file
# Respect TB_SKIP_COMPOSE_CHECK=true to disable the check for helper scripts
if [ "${BASH_SOURCE[0]}" != "$0" ]; then
# Sourced: return on failure
if [ "${TB_SKIP_COMPOSE_CHECK}" != "true" ]; then
checkComposeVersion || return $?
fi
else
# Executed directly: exit on failure
if [ "${TB_SKIP_COMPOSE_CHECK}" != "true" ]; then
checkComposeVersion || exit $?
fi
fi

if $FLAG_SET ; then set -e; fi
}
1 change: 1 addition & 0 deletions docker-check-log-folders.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#

set -e
export TB_SKIP_COMPOSE_CHECK=true
source compose-utils.sh
if checkFolders "$@" ; then
echo "------"
Expand Down
1 change: 1 addition & 0 deletions docker-create-log-folders.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@
#

set -e
export TB_SKIP_COMPOSE_CHECK=true
source compose-utils.sh
checkFolders --create "$@"
26 changes: 2 additions & 24 deletions docker-install-tb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ set -e

source compose-utils.sh

COMPOSE_VERSION=$(composeVersion) || exit $?

DEPLOYMENT_FOLDER=$(deploymentFolder) || exit $?

MAIN_SERVICE_NAME=$(mainServiceName) || exit $?
Expand All @@ -81,17 +79,7 @@ if [ ! -z "${ADDITIONAL_STARTUP_SERVICES// }" ]; then
-f docker-compose.yml ${ADDITIONAL_CACHE_ARGS} ${ADDITIONAL_COMPOSE_ARGS} ${ADDITIONAL_COMPOSE_QUEUE_ARGS} ${ADDITIONAL_COMPOSE_EDQS_ARGS} \
up -d ${ADDITIONAL_STARTUP_SERVICES}"

case $COMPOSE_VERSION in
V2)
docker compose $COMPOSE_ARGS
;;
V1)
docker-compose $COMPOSE_ARGS
;;
*)
# unknown option
;;
esac
docker compose $COMPOSE_ARGS
fi

COMPOSE_ARGS="\
Expand All @@ -100,16 +88,6 @@ COMPOSE_ARGS="\
run --no-deps --rm -e INSTALL_TB=true -e LOAD_DEMO=${loadDemo} \
${MAIN_SERVICE_NAME}"

case $COMPOSE_VERSION in
V2)
docker compose $COMPOSE_ARGS
;;
V1)
docker-compose $COMPOSE_ARGS
;;
*)
# unknown option
;;
esac
docker compose $COMPOSE_ARGS

cd ~-
14 changes: 1 addition & 13 deletions docker-remove-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ set -e

source compose-utils.sh

COMPOSE_VERSION=$(composeVersion) || exit $?

DEPLOYMENT_FOLDER=$(deploymentFolder) || exit $?

ADDITIONAL_COMPOSE_QUEUE_ARGS=$(additionalComposeQueueArgs) || exit $?
Expand All @@ -55,16 +53,6 @@ COMPOSE_ARGS="\
-f docker-compose.yml ${ADDITIONAL_CACHE_ARGS} ${ADDITIONAL_COMPOSE_ARGS} ${ADDITIONAL_COMPOSE_QUEUE_ARGS} ${ADDITIONAL_COMPOSE_MONITORING_ARGS} ${ADDITIONAL_COMPOSE_EDQS_ARGS} \
down -v"

case $COMPOSE_VERSION in
V2)
docker compose $COMPOSE_ARGS
;;
V1)
docker-compose $COMPOSE_ARGS
;;
*)
# unknown option
;;
esac
docker compose $COMPOSE_ARGS

cd ~-
14 changes: 1 addition & 13 deletions docker-start-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ set -e

source compose-utils.sh

COMPOSE_VERSION=$(composeVersion) || exit $?

DEPLOYMENT_FOLDER=$(deploymentFolder) || exit $?

ADDITIONAL_COMPOSE_QUEUE_ARGS=$(additionalComposeQueueArgs) || exit $?
Expand All @@ -55,16 +53,6 @@ COMPOSE_ARGS="\
-f docker-compose.yml ${ADDITIONAL_CACHE_ARGS} ${ADDITIONAL_COMPOSE_ARGS} ${ADDITIONAL_COMPOSE_QUEUE_ARGS} ${ADDITIONAL_COMPOSE_MONITORING_ARGS} ${ADDITIONAL_COMPOSE_EDQS_ARGS} \
up -d"

case $COMPOSE_VERSION in
V2)
docker compose $COMPOSE_ARGS
;;
V1)
docker-compose --compatibility $COMPOSE_ARGS
;;
*)
# unknown option
;;
esac
docker compose $COMPOSE_ARGS

cd ~-
14 changes: 1 addition & 13 deletions docker-stop-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ set -e

source compose-utils.sh

COMPOSE_VERSION=$(composeVersion) || exit $?

DEPLOYMENT_FOLDER=$(deploymentFolder) || exit $?

ADDITIONAL_COMPOSE_QUEUE_ARGS=$(additionalComposeQueueArgs) || exit $?
Expand All @@ -53,16 +51,6 @@ COMPOSE_ARGS="\
-f docker-compose.yml ${ADDITIONAL_CACHE_ARGS} ${ADDITIONAL_COMPOSE_ARGS} ${ADDITIONAL_COMPOSE_QUEUE_ARGS} ${ADDITIONAL_COMPOSE_MONITORING_ARGS} ${ADDITIONAL_COMPOSE_EDQS_ARGS} \
stop"

case $COMPOSE_VERSION in
V2)
docker compose $COMPOSE_ARGS
;;
V1)
docker-compose $COMPOSE_ARGS
;;
*)
# unknown option
;;
esac
docker compose $COMPOSE_ARGS

cd ~-
17 changes: 2 additions & 15 deletions docker-update-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ set -e

source compose-utils.sh

COMPOSE_VERSION=$(composeVersion) || exit $?

DEPLOYMENT_FOLDER=$(deploymentFolder) || exit $?

ADDITIONAL_COMPOSE_QUEUE_ARGS=$(additionalComposeQueueArgs) || exit $?
Expand All @@ -58,18 +56,7 @@ COMPOSE_ARGS_BUILD="\
-f docker-compose.yml ${ADDITIONAL_CACHE_ARGS} ${ADDITIONAL_COMPOSE_ARGS} ${ADDITIONAL_COMPOSE_QUEUE_ARGS} ${ADDITIONAL_COMPOSE_EDQS_ARGS} \
up -d --no-deps --build"

case $COMPOSE_VERSION in
V2)
docker compose $COMPOSE_ARGS_PULL $@
docker compose $COMPOSE_ARGS_BUILD $@
;;
V1)
docker-compose $COMPOSE_ARGS_PULL $@
docker-compose $COMPOSE_ARGS_BUILD $@
;;
*)
# unknown option
;;
esac
docker compose $COMPOSE_ARGS_PULL $@
docker compose $COMPOSE_ARGS_BUILD $@

cd ~-
20 changes: 3 additions & 17 deletions docker-upgrade-tb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ set -e

source compose-utils.sh

COMPOSE_VERSION=$(composeVersion) || exit $?

DEPLOYMENT_FOLDER=$(deploymentFolder) || exit $?

MAIN_SERVICE_NAME=$(mainServiceName) || exit $?
Expand Down Expand Up @@ -84,20 +82,8 @@ COMPOSE_ARGS_RUN="\
run --no-deps --rm -e UPGRADE_TB=true -e FROM_VERSION=${fromVersion} \
${MAIN_SERVICE_NAME}"

case $COMPOSE_VERSION in
V2)
docker compose $COMPOSE_ARGS_PULL
docker compose $COMPOSE_ARGS_UP
docker compose $COMPOSE_ARGS_RUN
;;
V1)
docker-compose $COMPOSE_ARGS_PULL
docker-compose $COMPOSE_ARGS_UP
docker-compose $COMPOSE_ARGS_RUN
;;
*)
# unknown option
;;
esac
docker compose $COMPOSE_ARGS_PULL
docker compose $COMPOSE_ARGS_UP
docker compose $COMPOSE_ARGS_RUN

cd ~-