Files
dotfiles/bootstrap.sh
T
noconnorandClaude Opus 4.8 35befbe1e3 bootstrap: stop one failed tool from killing the whole run
On a minimal Debian/RHEL image neither python3 nor unzip is present.
lib/fetch.sh's install_zip_bin needs one of them, so the 1Password CLI
install failed -- and under `set -eu` that killed bin/install.sh outright.
install_1p sits immediately before install_opencode and install_zarf, so
neither installed; bin/install.sh's non-zero exit then aborted bootstrap.sh,
so node/ (npx) and ansible/ (python3) never ran either.

Net effect on a fresh box: no opencode, no npx for the MCP servers, and no
python3 for model discovery. It presented as "opencode has no models or
skills". Reproduced in a clean debian:13 container.

Two fixes:

  - bin/install.sh: each tool now installs via try(), which warns and
    continues instead of aborting, and reports a summary of what failed. One
    optional CLI is not worth the rest of the bootstrap. The subshell
    re-enables set -e so a failed download can't fall through to mark_version
    and stamp a version that was never installed.

  - bootstrap.sh: ensure python3 before bin/ runs. It is a hard dependency,
    not an extra -- lib/fetch.sh needs it (or unzip) for .zip assets, and
    mcp-config/sync.sh needs it to inject discovered models.

Verified end to end on fresh debian:13: bootstrap completes, opencode/zarf/
op/npx/node/python3 all present, and opencode resolves all 3 covert-gpt
models.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-13 13:44:11 -04:00

58 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env sh
# bootstrap.sh — entrypoint for configuring a fresh VM (RHEL-family or
# Debian-family) with this repo's dotfiles. Safe to re-run.
#
# curl -fsSL https://git.nic-oconnor.com/public/dotfiles/raw/branch/main/bootstrap.sh | sh
# (or, from a checked-out clone: ./bootstrap.sh)
set -eu
REPO_URL="${DOTFILES_REPO:-https://git.nic-oconnor.com/public/dotfiles.git}"
DOTFILES_DIR="${DOTFILES_DIR:-$HOME/.dotfiles}"
SCRIPT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
# When curl-piped into `sh`, there is no checkout on disk: $0 is not a real
# path, so the module scripts alongside this file are missing. Clone (or
# update) the repo, then re-exec bootstrap.sh from the checkout.
if [ ! -f "$SCRIPT_DIR/zsh/install.sh" ]; then
if ! command -v git >/dev/null 2>&1; then
echo "bootstrap: git is required to self-clone; install git first" >&2
exit 1
fi
if [ -d "$DOTFILES_DIR/.git" ]; then
echo "bootstrap: updating existing checkout at $DOTFILES_DIR"
git -C "$DOTFILES_DIR" pull --ff-only
else
echo "bootstrap: cloning $REPO_URL into $DOTFILES_DIR"
git clone "$REPO_URL" "$DOTFILES_DIR"
fi
exec "$DOTFILES_DIR/bootstrap.sh"
fi
# python3 is a hard dependency of this setup, not an optional extra:
# - lib/fetch.sh needs python3 (or unzip) to extract .zip release assets;
# without either, the 1Password CLI install fails.
# - mcp-config/sync.sh needs it to inject the gateway's discovered models;
# without it opencode comes up with an EMPTY model list.
# Minimal Debian/RHEL images ship neither python3 nor unzip, so install it
# before bin/ runs. Non-fatal: an unsupported OS should degrade, not abort.
if ! command -v python3 >/dev/null 2>&1 && ! command -v unzip >/dev/null 2>&1; then
# shellcheck source=lib/os-detect.sh
. "$SCRIPT_DIR/lib/os-detect.sh"
echo "bootstrap: installing python3 (needed for zip assets and model discovery)"
pkg_install python3 || echo "bootstrap: warning: could not install python3" >&2
fi
"$SCRIPT_DIR/zsh/install.sh"
"$SCRIPT_DIR/git/install.sh"
# Runs before bin/ so the kind install gate can see the rootful daemon.
"$SCRIPT_DIR/docker/install.sh"
"$SCRIPT_DIR/bin/install.sh"
# Provides npx, which opencode needs to spawn the npm-based MCP servers in
# mcp-config/. Without it every MCP server silently fails to start.
"$SCRIPT_DIR/node/install.sh"
"$SCRIPT_DIR/ansible/install.sh"
# Runs last: needs rootless Docker already up (started at boot) so it can
# delegate cgroups to it. No-ops where that does not apply.
"$SCRIPT_DIR/docker-rootless-cgroup/install.sh"