From 1c3aca9beac5f23845a2aaecb2c6554b2d82b91f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20M=C3=B6lle?= Date: Mon, 17 Apr 2023 20:45:33 +0200 Subject: [PATCH] =?UTF-8?q?=E2=80=9Einstall.sh=E2=80=9C=20=C3=A4ndern?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/install.sh b/install.sh index 15900e2..174dbcc 100644 --- a/install.sh +++ b/install.sh @@ -1,5 +1,4 @@ #!/bin/bash - # This script installs Docker and Docker Compose on a Linux system. # It detects the Linux distribution (Ubuntu, Debian, CentOS, Alpine, or openSUSE) and installs the packages accordingly. # The script also asks the user if they want to install Docker Compose. @@ -7,9 +6,9 @@ # Function to install Docker on Ubuntu and Debian install_docker_deb() { sudo apt-get update - sudo apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release - curl -fsSL https://download.docker.com/linux/${1}/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/${1} $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common + curl -fsSL https://download.docker.com/linux/${1}/gpg | sudo apt-key add - + sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/${1} $(lsb_release -cs) stable" sudo apt-get update sudo apt-get install -y docker-ce docker-ce-cli containerd.io || { echo "Unable to install 'docker-ce'. Exiting."; exit 1; } } @@ -39,8 +38,7 @@ install_docker_opensuse() { # Function to install Docker Compose install_docker_compose() { - LATEST_COMPOSE_VERSION=$(curl --silent https://api.github.com/repos/docker/compose/releases/latest | grep -Po '"tag_name": "\K.*?(?=")') - sudo curl -L "https://github.com/docker/compose/releases/download/${LATEST_COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose } @@ -74,4 +72,20 @@ case "$DISTRO" in ;; "opensuse" | "opensuse-leap" | "opensuse-tumbleweed") echo "Installing Docker on openSUSE..." - install_docker_opensuse \ No newline at end of file + install_docker_opensuse + ;; + *) + echo "Unsupported Linux distribution." + exit 1 + ;; +esac + +echo "Docker installed successfully." + +# Prompt user for Docker Compose installation +while true; do + read -p "Do you want to install Docker Compose? (y/n): " yn + case $yn in + [Yy]* ) + echo "Installing Docker Compose..." + install_docker_compose