Files
eeg-reader/docker_setup.sh
2026-08-25 12:38:56 -06:00

34 lines
1.8 KiB
Bash

#!/bin/bash
# Fixed Docker install script.
# Notes on fixes are in the chat response.
HOSTS="alberto1 alberto2 alberto3 alberto4 alberto5 alberto6"
for host in $HOSTS; do
echo "=== $host ==="
# Step 1: remove old / conflicting packages (only if present)
ssh "$host" "PKGS=\$(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc docker-buildx podman-docker containerd runc 2>/dev/null | cut -f1); if [ -n \"\$PKGS\" ]; then echo 'usit' | sudo -S apt-get remove -y \$PKGS; fi"
# Step 2: install prerequisites and add Docker's GPG key
ssh "$host" "echo 'usit' | sudo -S apt-get update && \
echo 'usit' | sudo -S apt-get install -y ca-certificates curl && \
echo 'usit' | sudo -S install -m 0755 -d /etc/apt/keyrings && \
echo 'usit' | sudo -S curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc && \
echo 'usit' | sudo -S chmod a+r /etc/apt/keyrings/docker.asc"
# Step 3: add the Docker apt source (built remotely, no leading spaces)
# We write to a temp file first (no sudo needed), then move it into
# place with sudo. This keeps the password stream and the file
# content in two separate steps.
ssh "$host" "CODENAME=\$(. /etc/os-release && echo \"\${UBUNTU_CODENAME:-\$VERSION_CODENAME}\"); \
ARCH=\$(dpkg --print-architecture); \
printf 'Types: deb\nURIs: https://download.docker.com/linux/ubuntu\nSuites: %s\nComponents: stable\nArchitectures: %s\nSigned-By: /etc/apt/keyrings/docker.asc\n' \"\$CODENAME\" \"\$ARCH\" > /tmp/docker.sources; \
echo 'usit' | sudo -S mv /tmp/docker.sources /etc/apt/sources.list.d/docker.sources; \
echo 'usit' | sudo -S apt-get update"
# Step 4: install Docker
ssh "$host" "echo 'usit' | sudo -S apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin"
done