feat: bootstrap.sh defaults to its own clone URL — one URL to type

This commit is contained in:
bcherb2
2026-08-22 21:58:59 -04:00
parent ea10ba9d4a
commit 926a71266e
3 changed files with 23 additions and 23 deletions
+9 -8
View File
@@ -1098,15 +1098,16 @@ fi
printf '\n\033[1mbootstrap.sh — the first command, wrapped\033[0m\n' printf '\n\033[1mbootstrap.sh — the first command, wrapped\033[0m\n'
B=$ROOT/bootstrap.sh B=$ROOT/bootstrap.sh
if sh -n "$B" 2>/dev/null; then ok "bootstrap.sh parses"; else no "bootstrap.sh has a syntax error"; fi if sh -n "$B" 2>/dev/null; then ok "bootstrap.sh parses"; else no "bootstrap.sh has a syntax error"; fi
# The same property the phase 3 negative test asserts for the tier as a whole: # The tier names no real host, with one carved-out exception: this file may
# this file ships in the public repo, so it names no real host, ever. # name ITS OWN clone URL (fetching it proves you know the host already). It
if grep -qEi 'djdadi|15\.204|xeta' "$B"; then no "bootstrap.sh names a real host"; else ok "bootstrap.sh names no real host"; fi # must never name the endpoint, the VPS, or the private repo.
# No URL from argv, env, or a tty -> usage and exit 2, before curl runs. if grep -qEi 'xeta|15\.204|dotfiles-private' "$B"; then no "bootstrap.sh names a host beyond its own repo"; else ok "bootstrap.sh names nothing beyond its own repo"; fi
rc=0; out=$(DOTFILES_URL= sh "$B" </dev/null 2>&1) || rc=$? if grep -q 'DEFAULT_URL="https://[^"]*/dotfiles-public.git"' "$B"; then ok "…and defaults to its own clone URL"; else no "…and defaults to its own clone URL — default missing or malformed"; fi
is "no URL anywhere is refused, not guessed" 2 "$rc" # An explicit empty URL is an error, not a fall-through to the default: the
# caller said "this one" and named nothing.
rc=0; out=$(DOTFILES_URL= sh "$B" "" </dev/null 2>&1) || rc=$?
is "an explicit empty URL is refused, not defaulted" 2 "$rc"
has "…and says how to call it" "usage:" "$out" has "…and says how to call it" "usage:" "$out"
rc=0; out=$(sh "$B" "" </dev/null 2>&1) || rc=$?
is "an empty argument is an error too, not a prompt hang" 2 "$rc"
printf '\n\033[1minteractive loop (needs a pty)\033[0m\n' printf '\n\033[1minteractive loop (needs a pty)\033[0m\n'
if command -v fzf >/dev/null && command -v curl >/dev/null && command -v script >/dev/null; then if command -v fzf >/dev/null && command -v curl >/dev/null && command -v script >/dev/null; then
+4 -3
View File
@@ -22,11 +22,12 @@ sh -c "$(curl -fsLS get.chezmoi.io)" -- init --apply <this repo url>
~/.local/bin/dotup ~/.local/bin/dotup
``` ```
The first line is also wrapped as `bootstrap.sh` in this repo, for anyone who The first line is also wrapped as `bootstrap.sh`, which defaults to this
can fetch it raw but cannot remember chezmoi's incantation: repo's own clone URL — the one place in the tier a real host appears, because
fetching the file proves you already know it:
```sh ```sh
curl -fsSL <this repo raw url>/bootstrap.sh | sh -s -- <this repo url> curl -fsSL <this repo raw url>/bootstrap.sh | sh
``` ```
Two commands. The first lays down the files and clones the six externals; the Two commands. The first lays down the files and clones the six externals; the
+10 -12
View File
@@ -4,20 +4,18 @@
# #
# sh bootstrap.sh <public-repo-url> # or run it bare and answer the prompt # sh bootstrap.sh <public-repo-url> # or run it bare and answer the prompt
# #
# The repo URL is an argument rather than a constant for the same reason the # This tier names no real host -- with exactly one exception, and it is this
# tests prompt for it: this tier is public and names no real host. Your own # file naming ITS OWN clone URL. The exception discloses nothing: the only way
# paste-ready line lives in the private repo's runbook. # to fetch this script is to already know the host it names. The endpoint host
# and everything else stay out, same as everywhere else in the tier.
set -u set -u
URL=${1:-${DOTFILES_URL:-}} DEFAULT_URL="https://git.djdadi.com/ben/dotfiles-public.git"
# Prompt only when someone is there to answer: `curl | sh` and the test # An explicit argument wins outright -- including an explicit EMPTY one, which
# harness both arrive with stdin not a terminal, and must fail fast instead # is an error rather than a silent fall-through to the default: the caller
# of hanging on a prompt nobody sees. # said "this one" and then named nothing.
if [ -z "$URL" ] && [ -t 0 ]; then if [ "$#" -ge 1 ]; then URL=$1; else URL=${DOTFILES_URL:-$DEFAULT_URL}; fi
printf 'Public repo clone URL: ' >&2 [ -n "$URL" ] || { echo "usage: bootstrap.sh [public-repo-url]" >&2; exit 2; }
IFS= read -r URL || :
fi
[ -n "$URL" ] || { echo "usage: bootstrap.sh <public-repo-url>" >&2; exit 2; }
command -v curl >/dev/null 2>&1 \ command -v curl >/dev/null 2>&1 \
|| { echo "bootstrap.sh: curl is required and not installed" >&2; exit 1; } || { echo "bootstrap.sh: curl is required and not installed" >&2; exit 1; }