From d807ec7dc81e4b5721addf0b6ef87d41b767b7e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20M=C3=B6lle?= Date: Mon, 17 Apr 2023 20:42:36 +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 | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/install.sh b/install.sh index f043500..45d0664 100644 --- a/install.sh +++ b/install.sh @@ -1,4 +1,5 @@ #!/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. @@ -6,9 +7,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 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 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 update sudo apt-get install -y docker-ce docker-ce-cli containerd.io || { echo "Unable to install 'docker-ce'. Exiting."; exit 1; } } @@ -38,7 +39,8 @@ install_docker_opensuse() { # Function to install Docker Compose install_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 + 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 chmod +x /usr/local/bin/docker-compose } @@ -70,18 +72,4 @@ case "$DISTRO" in echo "Installing Docker on Alpine..." install_docker_alpine ;; - "opensuse" | "opensuse-leap" | "opensuse-tumbleweed") - echo "Installing Docker on openSUSE..." - 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): " + "opensuse