„install.sh“ ändern

This commit is contained in:
Yann Mölle 2023-04-17 20:42:36 +02:00
parent c98e1a07a4
commit d807ec7dc8

View File

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
# This script installs Docker and Docker Compose on a Linux system. # 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. # 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. # 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 # Function to install Docker on Ubuntu and Debian
install_docker_deb() { install_docker_deb() {
sudo apt-get update sudo apt-get update
sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common sudo apt-get install -y apt-transport-https ca-certificates curl gnupg lsb-release
curl -fsSL https://download.docker.com/linux/${1}/gpg | sudo apt-key add - curl -fsSL https://download.docker.com/linux/${1}/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/${1} $(lsb_release -cs) stable" 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 update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io || { echo "Unable to install 'docker-ce'. Exiting."; exit 1; } 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 # Function to install Docker Compose
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 sudo chmod +x /usr/local/bin/docker-compose
} }
@ -70,18 +72,4 @@ case "$DISTRO" in
echo "Installing Docker on Alpine..." echo "Installing Docker on Alpine..."
install_docker_alpine install_docker_alpine
;; ;;
"opensuse" | "opensuse-leap" | "opensuse-tumbleweed") "opensuse
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): "