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
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Require curl as a prerequisite (needed to download the script itself)
|
# Require curl as a prerequisite
|
||||||
if ! command -v curl &> /dev/null; then
|
if ! command -v curl &> /dev/null; then
|
||||||
echo "ERROR: curl is required but not installed."
|
echo "ERROR: curl is required but not installed."
|
||||||
echo ""
|
echo ""
|
||||||
@@ -34,12 +34,6 @@ if ! command -v curl &> /dev/null; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Detect interactive vs piped mode
|
|
||||||
INTERACTIVE=true
|
|
||||||
if [ ! -t 0 ]; then
|
|
||||||
INTERACTIVE=false
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check for Docker
|
# Check for Docker
|
||||||
DOCKER_INSTALLED=false
|
DOCKER_INSTALLED=false
|
||||||
if command -v docker &> /dev/null; then
|
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 " Use 'docker compose down -v' to DELETE the database."
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# Confirm (skip in non-interactive/piped mode)
|
# Confirm (skip if already ran the script or piped)
|
||||||
if [ "$INTERACTIVE" = "true" ]; then
|
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]: "
|
echo -n "Continue? [Y/n]: "
|
||||||
read -r CONFIRM
|
read -r CONFIRM
|
||||||
CONFIRM=${CONFIRM:-Y}
|
CONFIRM=${CONFIRM:-Y}
|
||||||
@@ -84,8 +81,8 @@ if [ "$INTERACTIVE" = "true" ]; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "(Running in non-interactive mode — proceeding automatically)"
|
echo "(No TTY detected — proceeding automatically)"
|
||||||
echo "To interactively confirm, run: curl -sL ... | bash"
|
echo "To interactively confirm, run this script in a terminal."
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -103,15 +100,39 @@ echo "[2/4] Installing Docker..."
|
|||||||
if [ "$DOCKER_INSTALLED" = "true" ]; then
|
if [ "$DOCKER_INSTALLED" = "true" ]; then
|
||||||
echo " Docker already installed ($DOCKER_VERSION) — skipping."
|
echo " Docker already installed ($DOCKER_VERSION) — skipping."
|
||||||
else
|
else
|
||||||
echo " Installing Docker from Docker Inc. repository..."
|
# Try Docker Inc. repo first (Ubuntu/Debian)
|
||||||
install -m 0755 -d /etc/apt/keyrings
|
INSTALLED_DOCKER=false
|
||||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
OS_ID=$(lsb_release -is 2>/dev/null || echo "")
|
||||||
chmod a+r /etc/apt/keyrings/docker.gpg
|
OS_CODENAME=$(lsb_release -cs 2>/dev/null || cat /etc/os-release | grep VERSION_CODENAME | cut -d= -f2)
|
||||||
. /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
|
echo " OS: $OS_ID ($OS_CODENAME)"
|
||||||
apt-get update -qq
|
|
||||||
apt-get install -y -qq docker-ce docker-ce-cli containerd.io docker-compose-plugin > /dev/null 2>&1
|
# Try Docker Inc. repo for Ubuntu
|
||||||
echo " Docker installed."
|
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
|
fi
|
||||||
|
|
||||||
systemctl enable docker --now > /dev/null 2>&1 || true
|
systemctl enable docker --now > /dev/null 2>&1 || true
|
||||||
|
|||||||
Reference in New Issue
Block a user