Optimized if-else arguments and outputs

This commit is contained in:
DerLinkman 2022-06-07 14:45:19 +02:00
parent 958112af6b
commit 74baf20feb
4 changed files with 27 additions and 24 deletions

View File

@ -30,12 +30,12 @@ for bin in openssl curl docker git awk sha1sum; do
done
echo "checking docker compose version...";
if docker --help | grep compose; then
echo ''
if docker compose >/dev/null 2>&1; then
echo -e "\e[32mFound Compose v2!\e[0m"
elif docker-compose version --short | grep -m1 "^1" > /dev/null 2>&1; then
echo -e "\e[31mWARN: Your machine is using Docker-Compose v1!\e[0m"
echo -e "\e[31mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m"
echo -e "\e[31mPlease consider a upgrade to Docker-Compose v2.\e[0m"
echo -e "\e[33mWARN: Your machine is using Docker-Compose v1!\e[0m"
echo -e "\e[33mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m"
echo -e "\e[33mPlease consider a upgrade to Docker-Compose v2.\e[0m"
echo
echo
echo -e "\e[33mContinuing...\e[0m"

View File

@ -86,12 +86,12 @@ function preflight_local_checks() {
echo "checking docker compose version...";
if docker --help | grep compose; then
echo ''
if docker compose >/dev/null 2>&1; then
echo -e "\e[32mFound Compose v2 on local machine!\e[0m"
elif docker-compose version --short | grep -m1 "^1" > /dev/null 2>&1; then
echo -e "\e[31mWARN: Your machine is using Docker-Compose v1!\e[0m"
echo -e "\e[31mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m"
echo -e "\e[31mPlease consider a upgrade to Docker-Compose v2.\e[0m"
echo -e "\e[33mWARN: Your machine is using Docker-Compose v1!\e[0m"
echo -e "\e[33mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m"
echo -e "\e[33mPlease consider a upgrade to Docker-Compose v2.\e[0m"
echo
echo
echo -e "\e[33mContinuing...\e[0m"
@ -144,16 +144,17 @@ function preflight_remote_checks() {
-i "${REMOTE_SSH_KEY}" \
${REMOTE_SSH_HOST} \
-p ${REMOTE_SSH_PORT} \
-t docker --help | grep compose; then
-t 'docker compose' >/dev/null 2>&1; then
echo -e "\e[32mFound Compose v2 on remote!\e[0m"
COMPOSE_COMMAND="docker compose"
elif ssh -q -o StrictHostKeyChecking=no \
-i "${REMOTE_SSH_KEY}" \
${REMOTE_SSH_HOST} \
-p ${REMOTE_SSH_PORT} \
'docker-compose version --short' | grep -m1 "^1" > /dev/null 2>&1; then
echo -e "\e[31mWARN: The remote is using Docker-Compose v1!\e[0m"
echo -e "\e[31mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m"
echo -e "\e[31mPlease consider a upgrade to Docker-Compose v2 on remote.\e[0m"
-t 'docker-compose version --short' | grep -m1 "^1" > /dev/null 2>&1; then
echo -e "\e[33mWARN: The remote is using Docker-Compose v1!\e[0m"
echo -e "\e[33mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m"
echo -e "\e[33mPlease consider a upgrade to Docker-Compose v2 on remote.\e[0m"
echo
echo
echo -e "\e[33mContinuing...\e[0m"

View File

@ -77,12 +77,13 @@ else
fi
echo "checking docker compose version...";
if docker --help | grep compose; then
if docker compose >/dev/null 2>&1; then
echo -e "\e[32mFound Compose v2!\e[0m"
COMPOSE_COMMAND="docker compose"
elif docker-compose version --short | grep -m1 "^1" > /dev/null 2>&1; then
echo -e "\e[31mWARN: Your machine is using Docker-Compose v1!\e[0m"
echo -e "\e[31mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m"
echo -e "\e[31mPlease consider a upgrade to Docker-Compose v2.\e[0m"
echo -e "\e[33mWARN: Your machine is using Docker-Compose v1!\e[0m"
echo -e "\e[33mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m"
echo -e "\e[33mPlease consider a upgrade to Docker-Compose v2.\e[0m"
echo
echo
echo -e "\e[33mContinuing...\e[0m"

View File

@ -46,12 +46,13 @@ done
echo "checking docker compose version...";
if docker --help | grep compose; then
if docker compose >/dev/null 2>&1; then
echo -e "\e[32mFound Compose v2!\e[0m"
COMPOSE_COMMAND="docker compose"
elif docker-compose version --short | grep -m1 "^1" > /dev/null 2>&1; then
echo -e "\e[31mWARN: Your machine is using Docker-Compose v1!\e[0m"
echo -e "\e[31mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m"
echo -e "\e[31mPlease consider a upgrade to Docker-Compose v2.\e[0m"
echo -e "\e[33mWARN: Your machine is using Docker-Compose v1!\e[0m"
echo -e "\e[33mmailcow will drop the Docker-Compose v1 Support in December 2022\e[0m"
echo -e "\e[33mPlease consider a upgrade to Docker-Compose v2.\e[0m"
echo
echo
echo -e "\e[33mContinuing...\e[0m"
@ -738,4 +739,4 @@ fi
#echo
#git reflog --color=always | grep "Before update on "
#echo
#echo "Use \"git reset --hard hash-on-the-left\" and run ${COMPOSE_COMMAND} up -d afterwards."
#echo "Use \"git reset --hard hash-on-the-left\" and run ${COMPOSE_COMMAND} up -d afterwards."