Skip to content

Commit 9a2887c

Browse files
committed
core: improved docker compose version check
1 parent 45666d2 commit 9a2887c

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

_modules/scripts/core.sh

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -38,45 +38,45 @@ get_docker_version(){
3838
}
3939

4040
get_compose_type(){
41-
if docker compose > /dev/null 2>&1; then
42-
if docker compose version --short | grep -e "^2." -e "^v2." > /dev/null 2>&1; then
43-
COMPOSE_VERSION=native
44-
COMPOSE_COMMAND="docker compose"
45-
if [[ "$caller" == "update.sh" ]]; then
46-
sed -i 's/^DOCKER_COMPOSE_VERSION=.*/DOCKER_COMPOSE_VERSION=native/' "$SCRIPT_DIR/mailcow.conf"
47-
fi
48-
echo -e "\e[33mFound Docker Compose Plugin (native).\e[0m"
49-
echo -e "\e[33mSetting the DOCKER_COMPOSE_VERSION Variable to native\e[0m"
50-
sleep 2
51-
echo -e "\e[33mNotice: You'll have to update this Compose Version via your Package Manager manually!\e[0m"
52-
else
53-
echo -e "\e[31mCannot find Docker Compose with a Version Higher than 2.X.X.\e[0m"
54-
echo -e "\e[31mPlease update/install it manually regarding to this doc site: https://docs.mailcow.email/install/\e[0m"
55-
exit 1
56-
fi
57-
elif docker-compose > /dev/null 2>&1; then
58-
if ! [[ $(alias docker-compose 2> /dev/null) ]] ; then
59-
if docker-compose version --short | grep "^2." > /dev/null 2>&1; then
60-
COMPOSE_VERSION=standalone
61-
COMPOSE_COMMAND="docker-compose"
62-
if [[ "$caller" == "update.sh" ]]; then
63-
sed -i 's/^DOCKER_COMPOSE_VERSION=.*/DOCKER_COMPOSE_VERSION=standalone/' "$SCRIPT_DIR/mailcow.conf"
64-
fi
65-
echo -e "\e[33mFound Docker Compose Standalone.\e[0m"
66-
echo -e "\e[33mSetting the DOCKER_COMPOSE_VERSION Variable to standalone\e[0m"
67-
sleep 2
68-
echo -e "\e[33mNotice: For an automatic update of docker-compose please use the update_compose.sh scripts located at the helper-scripts folder.\e[0m"
69-
else
70-
echo -e "\e[31mCannot find Docker Compose with a Version Higher than 2.X.X.\e[0m"
71-
echo -e "\e[31mPlease update/install manually regarding to this doc site: https://docs.mailcow.email/install/\e[0m"
72-
exit 1
73-
fi
41+
if docker compose > /dev/null 2>&1; then
42+
if docker compose version --short | grep -e "^[2-9]\." -e "^v[2-9]\." -e "^[1-9][0-9]\." -e "^v[1-9][0-9]\." > /dev/null 2>&1; then
43+
COMPOSE_VERSION=native
44+
COMPOSE_COMMAND="docker compose"
45+
if [[ "$caller" == "update.sh" ]]; then
46+
sed -i 's/^DOCKER_COMPOSE_VERSION=.*/DOCKER_COMPOSE_VERSION=native/' "$SCRIPT_DIR/mailcow.conf"
47+
fi
48+
echo -e "\e[33mFound Docker Compose Plugin (native).\e[0m"
49+
echo -e "\e[33mSetting the DOCKER_COMPOSE_VERSION Variable to native\e[0m"
50+
sleep 2
51+
echo -e "\e[33mNotice: You'll have to update this Compose Version via your Package Manager manually!\e[0m"
52+
else
53+
echo -e "\e[31mCannot find Docker Compose with a Version Higher than 2.X.X.\e[0m"
54+
echo -e "\e[31mPlease update/install it manually regarding to this doc site: https://docs.mailcow.email/install/\e[0m"
55+
exit 1
7456
fi
57+
elif docker-compose > /dev/null 2>&1; then
58+
if ! [[ $(alias docker-compose 2> /dev/null) ]] ; then
59+
if docker-compose version --short | grep -e "^[2-9]\." -e "^[1-9][0-9]\." > /dev/null 2>&1; then
60+
COMPOSE_VERSION=standalone
61+
COMPOSE_COMMAND="docker-compose"
62+
if [[ "$caller" == "update.sh" ]]; then
63+
sed -i 's/^DOCKER_COMPOSE_VERSION=.*/DOCKER_COMPOSE_VERSION=standalone/' "$SCRIPT_DIR/mailcow.conf"
64+
fi
65+
echo -e "\e[33mFound Docker Compose Standalone.\e[0m"
66+
echo -e "\e[33mSetting the DOCKER_COMPOSE_VERSION Variable to standalone\e[0m"
67+
sleep 2
68+
echo -e "\e[33mNotice: For an automatic update of docker-compose please use the update_compose.sh scripts located at the helper-scripts folder.\e[0m"
7569
else
76-
echo -e "\e[31mCannot find Docker Compose.\e[0m"
77-
echo -e "\e[31mPlease install it regarding to this doc site: https://docs.mailcow.email/install/\e[0m"
78-
exit 1
70+
echo -e "\e[31mCannot find Docker Compose with a Version Higher than 2.X.X.\e[0m"
71+
echo -e "\e[31mPlease update/install manually regarding to this doc site: https://docs.mailcow.email/install/\e[0m"
72+
exit 1
7973
fi
74+
fi
75+
else
76+
echo -e "\e[31mCannot find Docker Compose.\e[0m"
77+
echo -e "\e[31mPlease install it regarding to this doc site: https://docs.mailcow.email/install/\e[0m"
78+
exit 1
79+
fi
8080
}
8181

8282
detect_bad_asn() {

0 commit comments

Comments
 (0)