forked from Interanet/server-bootstrap
initial commit
This commit is contained in:
119
scripts/docker/install.sh
Normal file
119
scripts/docker/install.sh
Normal file
@@ -0,0 +1,119 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
echo "================================="
|
||||
echo " Docker Installation"
|
||||
echo "================================="
|
||||
|
||||
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# Detect OS
|
||||
if [[ -f /etc/os-release ]]; then
|
||||
. /etc/os-release
|
||||
else
|
||||
echo "Cannot detect operating system."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Detected OS: $ID"
|
||||
|
||||
echo "Running Docker installer for this distro..."
|
||||
|
||||
case "$ID" in
|
||||
|
||||
ubuntu)
|
||||
bash "$BASE_DIR/os/ubuntu.sh"
|
||||
;;
|
||||
|
||||
debian)
|
||||
bash "$BASE_DIR/os/debian.sh"
|
||||
;;
|
||||
|
||||
fedora|centos|rocky|almalinux|rhel)
|
||||
bash "$BASE_DIR/os/rhel.sh"
|
||||
;;
|
||||
|
||||
arch|manjaro)
|
||||
bash "$BASE_DIR/os/arch.sh"
|
||||
;;
|
||||
|
||||
alpine)
|
||||
bash "$BASE_DIR/os/alpine.sh"
|
||||
;;
|
||||
|
||||
opensuse*|suse|opensuse-leap|opensuse-tumbleweed)
|
||||
bash "$BASE_DIR/os/opensuse.sh"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unsupported distribution: $ID"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
echo "Docker installation completed successfully."
|
||||
|
||||
echo "================================="
|
||||
echo " Mirror Configuration"
|
||||
echo "================================="
|
||||
|
||||
read -rp "Configure Docker mirror? (y/n): " DOCKER_MIRROR
|
||||
|
||||
if [[ "$DOCKER_MIRROR" == "y" ]]; then
|
||||
|
||||
echo "Select Docker mirror provider:"
|
||||
echo "1) Liara"
|
||||
echo "2) ArvanCloud"
|
||||
echo "3) Runflare"
|
||||
|
||||
read -rp "Choice [1-3]: " DM
|
||||
|
||||
case "$DM" in
|
||||
1)
|
||||
echo "Applying Liara Docker mirror..."
|
||||
bash "$BASE_DIR/mirrors/liara.sh"
|
||||
;;
|
||||
2)
|
||||
echo "Applying ArvanCloud Docker mirror..."
|
||||
bash "$BASE_DIR/mirrors/arvancloud.sh"
|
||||
;;
|
||||
3)
|
||||
echo "Applying Runflare Docker mirror..."
|
||||
bash "$BASE_DIR/mirrors/runflare.sh"
|
||||
;;
|
||||
*)
|
||||
echo "Invalid choice. Skipping mirror configuration."
|
||||
;;
|
||||
esac
|
||||
|
||||
else
|
||||
echo "Skipping Docker mirror configuration."
|
||||
fi
|
||||
|
||||
echo "================================="
|
||||
echo "Starting Docker service..."
|
||||
|
||||
systemctl enable docker
|
||||
systemctl restart docker
|
||||
|
||||
if [[ -n "$SUDO_USER" ]]; then
|
||||
echo "Adding $SUDO_USER to docker group..."
|
||||
usermod -aG docker "$SUDO_USER" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
echo "================================="
|
||||
echo "Verifying Docker installation..."
|
||||
|
||||
docker --version
|
||||
|
||||
if systemctl is-active --quiet docker; then
|
||||
echo "Docker service is running."
|
||||
else
|
||||
echo "Docker service is NOT running."
|
||||
fi
|
||||
|
||||
echo "================================="
|
||||
echo "Docker setup finished successfully"
|
||||
echo "================================="
|
||||
Reference in New Issue
Block a user