setup.sh: fix Docker install — try Docker Inc repo first, fall back to docker.io on Debian; improve TTY detection
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user