chore-2193: add Rocky Linux setup script#2490
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a Rocky Linux / RHEL-compatible setup script to install prerequisites, install Docker CE via the RHEL repo, and bootstrap ContextForge similarly to the existing Ubuntu setup script.
Changes:
- Introduces
scripts/rocky-contextforge-setup-script.shwith OS detection for Rocky/RHEL/CentOS/AlmaLinux anddnf-based package installs - Installs Docker CE via
https://download.docker.com/linux/rhel/docker-ce.repo, enables the Docker service, and configures the user for docker group usage - Clones the ContextForge repo, creates
.envfrom.env.example, and optionally starts/verifies services
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| echo | ||
| echo "Examples:" | ||
| echo " $0 # Install to ~/mcp-context-forge and start" | ||
| echo " $0 /opt/contextforge # Install to /opt/contextforge and start" |
There was a problem hiding this comment.
The help text suggests installing to /opt/contextforge, but the script is explicitly intended to run as a non-root user and will fail to git clone into /opt on most systems. Consider changing the example to a user-writable path or noting that the directory must be pre-created and owned by the running user.
| echo " $0 /opt/contextforge # Install to /opt/contextforge and start" | |
| echo " $0 ~/contextforge # Install to ~/contextforge and start" |
| # Get architecture string for Docker repo | ||
| get_docker_arch() { | ||
| local arch | ||
| arch=$(uname -m) | ||
| case "$arch" in | ||
| x86_64) | ||
| echo "x86_64" | ||
| ;; | ||
| aarch64) | ||
| echo "aarch64" | ||
| ;; | ||
| *) | ||
| log_error "Unsupported architecture: $arch" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| } | ||
|
|
There was a problem hiding this comment.
get_docker_arch() is defined but never used, which adds dead code and may confuse readers about architecture handling. Either remove this function or wire it into Docker repo/package selection so the architecture check is actually enforced.
| # Get architecture string for Docker repo | |
| get_docker_arch() { | |
| local arch | |
| arch=$(uname -m) | |
| case "$arch" in | |
| x86_64) | |
| echo "x86_64" | |
| ;; | |
| aarch64) | |
| echo "aarch64" | |
| ;; | |
| *) | |
| log_error "Unsupported architecture: $arch" | |
| exit 1 | |
| ;; | |
| esac | |
| } |
| # Remove old Docker packages if present | ||
| sudo dnf remove -y docker \ | ||
| docker-client \ | ||
| docker-client-latest \ | ||
| docker-common \ | ||
| docker-latest \ | ||
| docker-latest-logrotate \ | ||
| docker-logrotate \ | ||
| docker-engine \ | ||
| podman \ | ||
| runc 2>/dev/null || true |
There was a problem hiding this comment.
The Docker install step unconditionally removes podman (and runc) via dnf remove. On many RHEL-compatible hosts, podman is used by other tooling and removing it can uninstall dependent packages or break existing workflows. Consider making podman removal opt-in (prompt/flag), or restrict removals to packages that actually conflict with Docker CE (e.g., podman-docker) and avoid removing runc unless required.
| log_info "Installing uv..." | ||
| curl -LsSf https://astral.sh/uv/install.sh | sh >&2 | ||
|
|
There was a problem hiding this comment.
The command curl -LsSf https://astral.sh/uv/install.sh | sh downloads and executes a remote installer script without any integrity or authenticity verification, so a compromise of astral.sh or its TLS path would lead to arbitrary code execution under the current user. An attacker who can influence DNS, the network path, or that host could serve a malicious script and gain full control of the environment where this setup script is run. Use a distribution-verified package/source or at minimum verify a pinned checksum/signature of the installer before executing it, rather than piping curl output directly into sh.
Add setup script for Rocky Linux and RHEL-compatible distributions. Adapts the Ubuntu setup script with the following changes: - Use dnf package manager instead of apt - Docker CE installation via RHEL repository - OS detection for Rocky, RHEL, CentOS, and AlmaLinux - Support for x86_64 and aarch64 architectures Closes #2193 Signed-off-by: Jonathan Springer <jps@s390x.com>
Check if Docker is logged in before running docker-compose to avoid image pull failures. If not logged in, prompt user with options: - Interactive login (username/password prompts) - Username with password from stdin (for automation) - Skip login (continue without authentication) Supports custom registry URLs for non-Docker Hub registries. Signed-off-by: Jonathan Springer <jps@s390x.com>
887a2fd to
5255f78
Compare
Changes Made During ReviewBug Fixes
Security & Hardening
New Features
Consistency Improvements
Commits
Usage Examples# Fully non-interactive Rocky install
./rocky-contextforge-setup-script.sh -y --remove-podman --skip-start
# Fully non-interactive Ubuntu install
./ubuntu-contextforge-setup-script.sh -y --skip-start |
Apply to both Rocky and Ubuntu setup scripts: - Add -y/--yes flag for fully non-interactive operation - Check for .git directory before running git pull - Fail fast with clear error if directory exists but isn't a git repo - Auto-confirm prompts in non-interactive mode - Exit with error on unsupported OS in non-interactive mode Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
5255f78 to
a4425f4
Compare
Testing in Docker ContainerAdditional FixAdded Test Results (Rocky Linux 9.7 container)Test Commanddocker run --privileged --rm rockylinux/rockylinux:9 bash -c '
dnf install -y sudo
useradd -m contextforge
echo "contextforge ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/contextforge
curl -fsSL https://raw.githubusercontent.com/IBM/mcp-context-forge/2193-rocky/scripts/rocky-contextforge-setup-script.sh \
-o /home/contextforge/setup.sh
chmod +x /home/contextforge/setup.sh
chown contextforge:contextforge /home/contextforge/setup.sh
su - contextforge -c "./setup.sh -y --remove-podman --skip-start"
'Full systemd testing requires a VM or init-enabled container. |
Full E2E Test with Init Container (systemd)Test Environment
Test Commanddocker run --privileged --rm -d \
--name rocky-init-test \
-v /sys/fs/cgroup:/sys/fs/cgroup:rw \
--cgroupns=host \
rockylinux/rockylinux:9-ubi-init /sbin/init
docker exec rocky-init-test bash -c '
dnf install -y sudo
useradd -m contextforge
echo "contextforge ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/contextforge
'
docker cp scripts/rocky-contextforge-setup-script.sh rocky-init-test:/home/contextforge/setup.sh
docker exec rocky-init-test chown contextforge:contextforge /home/contextforge/setup.sh
docker exec rocky-init-test chmod +x /home/contextforge/setup.sh
docker exec rocky-init-test su - contextforge -c "./setup.sh -y --remove-podman --skip-start"Results ✅
Docker Service VerificationRelatedCreated issue #2501 for comprehensive E2E setup script testing infrastructure across multiple distributions. |
* chore-2193: add Rocky Linux setup script Add setup script for Rocky Linux and RHEL-compatible distributions. Adapts the Ubuntu setup script with the following changes: - Use dnf package manager instead of apt - Docker CE installation via RHEL repository - OS detection for Rocky, RHEL, CentOS, and AlmaLinux - Support for x86_64 and aarch64 architectures Closes IBM#2193 Signed-off-by: Jonathan Springer <jps@s390x.com> * chore-2193: add Docker login check before compose-up Check if Docker is logged in before running docker-compose to avoid image pull failures. If not logged in, prompt user with options: - Interactive login (username/password prompts) - Username with password from stdin (for automation) - Skip login (continue without authentication) Supports custom registry URLs for non-Docker Hub registries. Signed-off-by: Jonathan Springer <jps@s390x.com> * fix: add non-interactive mode and git repo check to setup scripts Apply to both Rocky and Ubuntu setup scripts: - Add -y/--yes flag for fully non-interactive operation - Check for .git directory before running git pull - Fail fast with clear error if directory exists but isn't a git repo - Auto-confirm prompts in non-interactive mode - Exit with error on unsupported OS in non-interactive mode Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> * Linting Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> --------- Signed-off-by: Jonathan Springer <jps@s390x.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> Co-authored-by: Mihai Criveti <crivetimihai@gmail.com>
Summary
scripts/ubuntu-contextforge-setup-script.sh) for RHEL-based systemsChanges
dnfpackage manager instead ofapthttps://download.docker.com/linux/rhel/docker-ce.repo)Closes #2193