From 06f1e1f8679555188afc5b4480ad3fe96af90dbe Mon Sep 17 00:00:00 2001 From: scriptos Date: Wed, 12 Jun 2024 14:11:44 +0200 Subject: [PATCH] =?UTF-8?q?Unterst=C3=BCtzung=20f=C3=BCr=20Ubuntu=2024.04?= =?UTF-8?q?=20hinzugef=C3=BCgt,=20OS-Pr=C3=BCfung=20aktualisiert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker-installer-ubuntu.v3.sh | 36 +++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/docker-installer-ubuntu.v3.sh b/docker-installer-ubuntu.v3.sh index 59d800e..83d39af 100644 --- a/docker-installer-ubuntu.v3.sh +++ b/docker-installer-ubuntu.v3.sh @@ -1,21 +1,21 @@ #!/bin/bash # Script Name: docker-installer.v3.sh -# Beschreibung: Docker & Docker-Compose Installer für "Ubuntu 22.04 Jammy" only +# Beschreibung: Docker & Docker-Compose Installer für Ubuntu 22.04 Jammy und Ubuntu 24.04 # Aufruf: bash ./docker-installer.v3.sh # Autor: Patrick Asmus # Web: https://www.techniverse.net # Git-Reposit.: https://git.techniverse.net/scriptos/linux-docker-installer -# Version: 3.3 -# Datum: 08.04.2024 -# Modifikation: Script now checks OS before installation +# Version: 3.4 +# Datum: 12.06.2024 +# Modifikation: Unterstützung für Ubuntu 24.04 hinzugefügt, OS-Prüfung aktualisiert ##################################################### # Betriebssystem und Version prüfen OS=$(lsb_release -is) VERSION=$(lsb_release -rs) -if [ "$OS" != "Ubuntu" ] || [ "$VERSION" != "22.04" ]; then - echo "Dieses Script ist nur für Ubuntu 22.04 geeignet. Installation abgebrochen." +if [ "$OS" != "Ubuntu" ] || { [ "$VERSION" != "22.04" ] && [ "$VERSION" != "24.04" ]; }; then + echo "Dieses Script unterstützt nur Ubuntu 22.04 und Ubuntu 24.04. Installation abgebrochen." exit 1 fi @@ -27,25 +27,33 @@ COMPOSE_DIR="/docker-compose" # Docker installieren sudo apt update sudo apt install -y apt-transport-https ca-certificates curl software-properties-common -curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg -echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + +if [ "$VERSION" == "22.04" ]; then + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg + echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null +elif [ "$VERSION" == "24.04" ]; then + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null +fi + sudo apt update sudo apt install -y docker-ce docker-ce-cli containerd.io + sudo usermod -aG docker $USER # Docker-Root-Verzeichnis ändern & Compose Verzeichnis erstellen sudo systemctl stop docker sudo mkdir -p $DOCKER_ROOT_DIR -echo "{\"data-root\": \"$DOCKER_ROOT_DIR\"}" | sudo tee /etc/docker/daemon.json -cp /var/lib/docker/* $DOCKER_ROOT_DIR +echo "{\"data-root\": \"$DOCKER_ROOT_DIR\"}" | sudo tee /etc/docker/daemon.json > /dev/null +cp /var/lib/docker/* $DOCKER_ROOT_DIR -r rm -R /var/lib/docker sudo systemctl start docker -mkdir $COMPOSE_DIR +mkdir -p $COMPOSE_DIR -# Docker-compose installieren +# Docker-compose installieren (gleicher Prozess für beide Versionen) sudo apt install -y curl -sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose +sudo curl -L "https://github.com/docker/compose/releases/download/v2.12.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose # Optional: Plugin für Oh my ZSH aktivieren @@ -56,4 +64,4 @@ sudo sed -i 's/plugins=(git)/plugins=(git docker)/g' /root/.zshrc docker --version docker-compose --version -exit 0 \ No newline at end of file +exit 0