From 848725967d717d8850bbd279683678cb64247a2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20M=C3=B6lle?= Date: Mon, 17 Apr 2023 21:16:56 +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 | 64 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/install.sh b/install.sh index 9687d4a..d99519a 100644 --- a/install.sh +++ b/install.sh @@ -7,15 +7,27 @@ if [ "$(id -u)" -ne 0 ]; then fi # Check which Linux distribution is installed -if [ -f /etc/debian_version ]; then - echo "Detected Debian-based system." - DISTRO="debian" -elif [ -f /etc/redhat-release ]; then - echo "Detected Red Hat-based system." - DISTRO="redhat" -elif [ -f /etc/alpine-release ]; then - echo "Detected Alpine Linux." - DISTRO="alpine" +if [ -f /etc/os-release ]; then + . /etc/os-release + if [[ "$ID" == "ubuntu" ]]; then + echo "Detected Ubuntu." + PACKAGE_MANAGER="apt-get-ubuntu" + elif [[ "$ID" == "opensuse" ]]; then + echo "Detected openSUSE." + PACKAGE_MANAGER="zypper" + elif [[ "$ID" == "debian" ]]; then + echo "Detected Debian." + PACKAGE_MANAGER="apt-get" + elif [[ "$ID" == "alpine" ]]; then + echo "Detected Alpine Linux." + PACKAGE_MANAGER="apk" + elif [[ "$ID" == "centos" ]]; then + echo "Detected CentOS." + PACKAGE_MANAGER="yum" + else + echo "Unsupported Linux distribution." + exit 1 + fi else echo "Unsupported Linux distribution." exit 1 @@ -23,14 +35,32 @@ fi # Install Docker echo "Installing Docker..." -if [ "$DISTRO" = "debian" ] || [ "$DISTRO" = "ubuntu" ]; then - bash -c "$(curl -L https://git.moelle.space/hxcde/docker-auto-installer/raw/branch/main/debian.sh)" - systemctl start docker -elif [ "$DISTRO" = "redhat" ]; then - bash -c "$(curl -L https://git.moelle.space/hxcde/docker-auto-installer/raw/branch/main/centos.sh)" - systemctl start docker -elif [ "$DISTRO" = "alpine" ]; then - sh -c "$(curl -L https://git.moelle.space/hxcde/docker-auto-installer/raw/branch/main/alpine.sh)" +$PACKAGE_MANAGER update +$PACKAGE_MANAGER install -y docker + +# Start Docker +echo "Starting Docker..." +systemctl start docker + +# Enable Docker to start at boot +echo "Enabling Docker at boot..." +systemctl enable docker + +# Install Docker Compose +read -p "Do you want to install Docker Compose? (y/n) " INSTALL_COMPOSE +if [ "$INSTALL_COMPOSE" == "y" ]; then + echo "Installing Docker Compose..." + if [ "$PACKAGE_MANAGER" == "apt-get" ] then + bash -c "$(curl -L https://git.moelle.space/hxcde/docker-auto-installer/raw/branch/main/debian.sh)" + elif [ "$PACKAGE_MANAGER" == "apt-get-ubuntu" ]; then + bash -c "$(curl -L https://git.moelle.space/hxcde/docker-auto-installer/raw/branch/main/ubuntu.sh)" + elif [ "$PACKAGE_MANAGER" == "zypper" ]; then + sh -c "$(curl -L https://git.moelle.space/hxcde/docker-auto-installer/raw/branch/main/opensuse.sh)" + elif [ "$PACKAGE_MANAGER" == "apk" ]; then + sh -c "$(curl -L https://git.moelle.space/hxcde/docker-auto-installer/raw/branch/main/alpine.sh)" + elif [ "$PACKAGE_MANAGER" == "yum" ]; then + bash -c "$(curl -L https://git.moelle.space/hxcde/docker-auto-installer/raw/branch/main/centos.sh)" + fi fi echo "Docker and Docker Compose installation completed." \ No newline at end of file