fix: check-deps installs all required system packages via apt

scripts/check_deps.sh now checks and installs all prerequisites:
git, curl, openssl, python3, python3-cryptography, docker, docker-compose.
Runs apt-get update only once if anything needs installing.
Also adds current user to docker group if missing.
Makefile calls it with sudo so it has the rights to install packages.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-22 09:27:45 -04:00
parent 368457ecce
commit 30878fe539
2 changed files with 51 additions and 43 deletions
+50 -42
View File
@@ -1,48 +1,56 @@
#!/bin/sh
# Install Python dependencies needed by setup_cell.py
# Install all host dependencies required by Personal Internet Cell.
# Uses apt-get (Debian/Ubuntu). Must be run with sudo or as root.
set -e
echo "Checking system dependencies..."
APT_UPDATED=0
# Ensure python3 is available
if ! command -v python3 >/dev/null 2>&1; then
echo "Installing python3..."
sudo apt-get install -y python3 || { echo "ERROR: python3 not found and could not install it."; exit 1; }
apt_install() {
PKG="$1"
if ! dpkg -s "$PKG" >/dev/null 2>&1; then
echo " Installing $PKG..."
if [ "$APT_UPDATED" = "0" ]; then
apt-get update -qq
APT_UPDATED=1
fi
apt-get install -y -qq "$PKG"
else
echo " [ok] $PKG"
fi
}
echo "=== Checking system dependencies ==="
# Core tools
apt_install git
apt_install curl
apt_install openssl
apt_install python3
apt_install python3-cryptography
# Docker
if ! command -v docker >/dev/null 2>&1; then
echo " Installing docker..."
if [ "$APT_UPDATED" = "0" ]; then
apt-get update -qq
APT_UPDATED=1
fi
apt-get install -y -qq docker.io
fi
echo " [ok] docker"
# Docker Compose (v2 plugin preferred, v1 fallback)
if ! docker compose version >/dev/null 2>&1 && ! command -v docker-compose >/dev/null 2>&1; then
echo " Installing docker-compose..."
apt-get install -y -qq docker-compose
fi
echo " [ok] docker-compose"
# Ensure current user is in docker group
if ! id | grep -q '(docker)'; then
echo " Adding $(id -un) to docker group..."
usermod -aG docker "$(id -un)"
echo " NOTE: Log out and back in (or run 'newgrp docker') for docker group to take effect."
fi
# Check if cryptography is already importable
if python3 -c "import cryptography" 2>/dev/null; then
echo "Dependencies OK."
exit 0
fi
echo "Installing python3-cryptography..."
# 1. Try apt (works if sudo is passwordless or interactive TTY is available)
if sudo -n apt-get install -y python3-cryptography 2>/dev/null; then
echo "Dependencies OK."
exit 0
fi
# 2. Try pip (module form, covers both pip3 and python3 -m pip)
if python3 -m pip install --user cryptography 2>/dev/null; then
echo "Dependencies OK."
exit 0
fi
# 3. Bootstrap pip via get-pip.py, then install
if command -v curl >/dev/null 2>&1; then
curl -sSL https://bootstrap.pypa.io/get-pip.py -o /tmp/get-pip.py 2>/dev/null \
&& python3 /tmp/get-pip.py --user -q 2>/dev/null \
&& python3 -m pip install --user cryptography 2>/dev/null \
&& { echo "Dependencies OK."; exit 0; }
fi
# 4. No automated path worked — ask the user to install manually
echo ""
echo "ERROR: Could not install python3-cryptography automatically."
echo "Please run the following command and then retry:"
echo ""
echo " sudo apt-get install -y python3-cryptography"
echo ""
exit 1
echo "=== All dependencies OK ==="