feat: bootstrap.sh defaults to its own clone URL — one URL to type
This commit is contained in:
+9
-8
@@ -1098,15 +1098,16 @@ fi
|
||||
printf '\n\033[1mbootstrap.sh — the first command, wrapped\033[0m\n'
|
||||
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
|
||||
# The same property the phase 3 negative test asserts for the tier as a whole:
|
||||
# this file ships in the public repo, so it names no real host, ever.
|
||||
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
|
||||
# No URL from argv, env, or a tty -> usage and exit 2, before curl runs.
|
||||
rc=0; out=$(DOTFILES_URL= sh "$B" </dev/null 2>&1) || rc=$?
|
||||
is "no URL anywhere is refused, not guessed" 2 "$rc"
|
||||
# The tier names no real host, with one carved-out exception: this file may
|
||||
# name ITS OWN clone URL (fetching it proves you know the host already). It
|
||||
# must never name the endpoint, the VPS, or the private repo.
|
||||
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
|
||||
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
|
||||
# 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"
|
||||
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'
|
||||
if command -v fzf >/dev/null && command -v curl >/dev/null && command -v script >/dev/null; then
|
||||
|
||||
@@ -22,11 +22,12 @@ sh -c "$(curl -fsLS get.chezmoi.io)" -- init --apply <this repo url>
|
||||
~/.local/bin/dotup
|
||||
```
|
||||
|
||||
The first line is also wrapped as `bootstrap.sh` in this repo, for anyone who
|
||||
can fetch it raw but cannot remember chezmoi's incantation:
|
||||
The first line is also wrapped as `bootstrap.sh`, which defaults to this
|
||||
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
|
||||
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
|
||||
|
||||
+10
-12
@@ -4,20 +4,18 @@
|
||||
#
|
||||
# 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
|
||||
# tests prompt for it: this tier is public and names no real host. Your own
|
||||
# paste-ready line lives in the private repo's runbook.
|
||||
# This tier names no real host -- with exactly one exception, and it is this
|
||||
# file naming ITS OWN clone URL. The exception discloses nothing: the only way
|
||||
# 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
|
||||
|
||||
URL=${1:-${DOTFILES_URL:-}}
|
||||
# Prompt only when someone is there to answer: `curl | sh` and the test
|
||||
# harness both arrive with stdin not a terminal, and must fail fast instead
|
||||
# of hanging on a prompt nobody sees.
|
||||
if [ -z "$URL" ] && [ -t 0 ]; then
|
||||
printf 'Public repo clone URL: ' >&2
|
||||
IFS= read -r URL || :
|
||||
fi
|
||||
[ -n "$URL" ] || { echo "usage: bootstrap.sh <public-repo-url>" >&2; exit 2; }
|
||||
DEFAULT_URL="https://git.djdadi.com/ben/dotfiles-public.git"
|
||||
# An explicit argument wins outright -- including an explicit EMPTY one, which
|
||||
# is an error rather than a silent fall-through to the default: the caller
|
||||
# said "this one" and then named nothing.
|
||||
if [ "$#" -ge 1 ]; then URL=$1; else URL=${DOTFILES_URL:-$DEFAULT_URL}; fi
|
||||
[ -n "$URL" ] || { echo "usage: bootstrap.sh [public-repo-url]" >&2; exit 2; }
|
||||
|
||||
command -v curl >/dev/null 2>&1 \
|
||||
|| { echo "bootstrap.sh: curl is required and not installed" >&2; exit 1; }
|
||||
|
||||
Reference in New Issue
Block a user