From 4cb17bca320b52263befd931ed656ef8b5ecd690 Mon Sep 17 00:00:00 2001 From: Ada Date: Mon, 6 Apr 2026 10:27:10 -0400 Subject: [PATCH] =?UTF-8?q?setup.sh:=20fix=20Docker=20install=20=E2=80=94?= =?UTF-8?q?=20try=20Docker=20Inc=20repo=20first,=20fall=20back=20to=20dock?= =?UTF-8?q?er.io=20on=20Debian;=20improve=20TTY=20detection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/setup.sh | 61 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 20 deletions(-) diff --git a/deploy/setup.sh b/deploy/setup.sh index 260cc79..8e9a7e1 100755 --- a/deploy/setup.sh +++ b/deploy/setup.sh @@ -22,7 +22,7 @@ if ! command -v apt-get &> /dev/null; then exit 1 fi -# Require curl as a prerequisite (needed to download the script itself) +# Require curl as a prerequisite if ! command -v curl &> /dev/null; then echo "ERROR: curl is required but not installed." echo "" @@ -34,12 +34,6 @@ if ! command -v curl &> /dev/null; then exit 1 fi -# Detect interactive vs piped mode -INTERACTIVE=true -if [ ! -t 0 ]; then - INTERACTIVE=false -fi - # Check for Docker DOCKER_INSTALLED=false if command -v docker &> /dev/null; then @@ -74,8 +68,11 @@ echo "Data: SQLite database is stored in a Docker named volume." echo " Use 'docker compose down -v' to DELETE the database." echo "" -# Confirm (skip in non-interactive/piped mode) -if [ "$INTERACTIVE" = "true" ]; then +# Confirm (skip if already ran the script or piped) +if [ -n "$INSCRIPT" ]; then + echo "(INSCRIPT set — skipping confirmation)" +elif [ -t 1 ]; then + # stdout is a TTY — assume interactive terminal echo -n "Continue? [Y/n]: " read -r CONFIRM CONFIRM=${CONFIRM:-Y} @@ -84,8 +81,8 @@ if [ "$INTERACTIVE" = "true" ]; then exit 0 fi else - echo "(Running in non-interactive mode — proceeding automatically)" - echo "To interactively confirm, run: curl -sL ... | bash" + echo "(No TTY detected — proceeding automatically)" + echo "To interactively confirm, run this script in a terminal." echo "" fi @@ -103,15 +100,39 @@ echo "[2/4] Installing Docker..." if [ "$DOCKER_INSTALLED" = "true" ]; then echo " Docker already installed ($DOCKER_VERSION) — skipping." else - echo " Installing Docker from Docker Inc. repository..." - install -m 0755 -d /etc/apt/keyrings - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg - chmod a+r /etc/apt/keyrings/docker.gpg - . /etc/os-release - echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $VERSION_CODENAME stable" > /etc/apt/sources.list.d/docker.list - apt-get update -qq - apt-get install -y -qq docker-ce docker-ce-cli containerd.io docker-compose-plugin > /dev/null 2>&1 - echo " Docker installed." + # Try Docker Inc. repo first (Ubuntu/Debian) + INSTALLED_DOCKER=false + OS_ID=$(lsb_release -is 2>/dev/null || echo "") + OS_CODENAME=$(lsb_release -cs 2>/dev/null || cat /etc/os-release | grep VERSION_CODENAME | cut -d= -f2) + + echo " OS: $OS_ID ($OS_CODENAME)" + + # Try Docker Inc. repo for Ubuntu + if [ "$OS_ID" = "Ubuntu" ]; then + echo " Trying Docker Inc. repository..." + install -m 0755 -d /etc/apt/keyrings + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg + chmod a+r /etc/apt/keyrings/docker.gpg + echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $OS_CODENAME stable" > /etc/apt/sources.list.d/docker.list + apt-get update -qq + if apt-get install -y -qq docker-ce docker-ce-cli containerd.io docker-compose-plugin > /dev/null 2>&1; then + echo " Docker installed from Docker Inc. repo." + INSTALLED_DOCKER=true + fi + fi + + # Fall back to docker.io (Debian native) + if [ "$INSTALLED_DOCKER" = "false" ]; then + echo " Falling back to docker.io (Debian package)..." + apt-get update -qq + if apt-get install -y -qq docker.io docker-compose-plugin > /dev/null 2>&1; then + echo " Docker installed from Debian repos." + INSTALLED_DOCKER=true + else + echo " ERROR: Could not install Docker. Please install manually." + exit 1 + fi + fi fi systemctl enable docker --now > /dev/null 2>&1 || true