diff --git a/install.sh b/install.sh index 8c245d6..50f49fe 100755 --- a/install.sh +++ b/install.sh @@ -29,8 +29,10 @@ ensure_docker(){ case "$(uname -s)" in Linux) if [ "$(ask 'Install Docker automatically? (y/n)' y)" = y ]; then - curl -fsSL https://get.docker.com | sh + install_docker_linux sudo usermod -aG docker "$USER" || true + docker compose version >/dev/null 2>&1 || sudo docker compose version >/dev/null 2>&1 \ + || die "docker installed but 'docker compose' is unavailable; install the compose v2 plugin and retry" ok "Docker installed (re-login required for the group change to take effect)" else die "please install docker yourself and retry" @@ -40,6 +42,47 @@ ensure_docker(){ esac } +# install_docker_linux uses get.docker.com only on the distros it supports. That +# script keys its repo URL off /etc/os-release ID + codename, so on derivatives +# such as Kali it writes a repo for a nonexistent release (debian kali-rolling) +# and leaves apt broken. Other apt-based distros get the distro's own packages. +install_docker_linux(){ + local id="" id_like="" + if [ -r /etc/os-release ]; then + id="$(. /etc/os-release && echo "${ID:-}")" + id_like="$(. /etc/os-release && echo "${ID_LIKE:-}")" + fi + case "$id" in + ubuntu|debian|raspbian|centos|fedora|rhel|sles) + curl -fsSL https://get.docker.com | sh + return ;; + esac + command -v apt-get >/dev/null 2>&1 \ + || die "automatic Docker install is not supported on '${id:-unknown}'; please install docker + the compose plugin yourself and retry" + info "'${id:-unknown}' (like: ${id_like:-n/a}) is not supported by get.docker.com; installing from the distro's apt repos" + # Drop a broken repo left by an earlier get.docker.com run (it fails every apt update). + local f + for f in /etc/apt/sources.list.d/docker.list /etc/apt/sources.list.d/docker.sources; do + if [ -f "$f" ] && grep -q "download.docker.com/linux/debian.*${id}" "$f" 2>/dev/null; then + warn "removing broken Docker repo $f" + sudo rm -f "$f" + fi + done + sudo apt-get update + sudo apt-get install -y docker.io + # The compose v2 package name varies across Debian derivatives; take the first that exists. + local p + for p in docker-compose-plugin docker-compose-v2 docker-compose; do + if apt-cache madison "$p" 2>/dev/null | grep -q .; then + sudo apt-get install -y "$p" && break + fi + done + # Kali (and some others) don't start services on package install. + if command -v systemctl >/dev/null 2>&1; then + sudo systemctl enable --now docker || true + fi +} + # ── 1) All-Docker ─────────────────────────────── install_docker(){ ensure_docker