diff --git a/deploy/setup.sh b/deploy/setup.sh index 8e9a7e1..9d9b346 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 +# Require curl if ! command -v curl &> /dev/null; then echo "ERROR: curl is required but not installed." echo "" @@ -34,13 +34,19 @@ if ! command -v curl &> /dev/null; then exit 1 fi -# Check for Docker +# Check for Docker (docker.io or docker-ce) DOCKER_INSTALLED=false if command -v docker &> /dev/null; then DOCKER_INSTALLED=true DOCKER_VERSION=$(docker --version 2>/dev/null | awk '{print $3}' | tr -d ',') fi +# Check for docker-compose plugin +COMPOSE_INSTALLED=false +if docker compose version &> /dev/null; then + COMPOSE_INSTALLED=true +fi + # Check if repo already exists REPO_DIR="/root/project-tracker" REPO_EXISTS=false @@ -52,6 +58,7 @@ fi echo "Pre-flight check:" echo " OS: $(lsb_release -ds 2>/dev/null || cat /etc/os-release | grep PRETTY_NAME | cut -d'"' -f2)" echo " Docker: ${DOCKER_INSTALLED:+$DOCKER_VERSION (installed)}" +echo " Compose: ${COMPOSE_INSTALLED:+installed}" echo " Repo dir: ${REPO_EXISTS:+WARNING — $REPO_DIR already exists (will git pull)}" echo "" @@ -68,11 +75,8 @@ echo "Data: SQLite database is stored in a Docker named volume." echo " Use 'docker compose down -v' to DELETE the database." echo "" -# 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 +# Confirm +if [ -t 1 ]; then echo -n "Continue? [Y/n]: " read -r CONFIRM CONFIRM=${CONFIRM:-Y} @@ -81,8 +85,7 @@ elif [ -t 1 ]; then exit 0 fi else - echo "(No TTY detected — proceeding automatically)" - echo "To interactively confirm, run this script in a terminal." + echo "(No TTY — proceeding automatically)" echo "" fi @@ -97,45 +100,33 @@ apt-get install -y -qq curl git ca-certificates gnupg > /dev/null 2>&1 # Install Docker echo "[2/4] Installing Docker..." -if [ "$DOCKER_INSTALLED" = "true" ]; then - echo " Docker already installed ($DOCKER_VERSION) — skipping." +if [ "$DOCKER_INSTALLED" = "true" ] && [ "$COMPOSE_INSTALLED" = "true" ]; then + echo " Docker and Docker Compose already installed — skipping." else - # 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." + if [ "$DOCKER_INSTALLED" = "false" ]; then + echo " Installing docker.io from Debian repos..." + apt-get install -y -qq docker.io > /dev/null 2>&1 || { + echo " ERROR: Could not install docker.io. Try: apt-get install docker.io" exit 1 - fi + } + echo " docker.io installed." + else + echo " Docker already installed ($DOCKER_VERSION)." fi -fi -systemctl enable docker --now > /dev/null 2>&1 || true + if [ "$COMPOSE_INSTALLED" = "false" ]; then + echo " Installing docker-compose-plugin..." + apt-get install -y -qq docker-compose-plugin > /dev/null 2>&1 || { + echo " ERROR: Could not install docker-compose-plugin." + exit 1 + } + echo " docker-compose-plugin installed." + else + echo " Docker Compose already installed." + fi + + systemctl enable docker --now > /dev/null 2>&1 || true +fi # Clone or update repo echo "[3/4] Setting up Project Tracker..."