31 lines
1.5 KiB
Bash
Executable File
31 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
# bootstrap.sh -- the whole "first command" of a fresh machine, so nobody has
|
|
# to remember chezmoi's incantation. Everything after this is dotup's job.
|
|
#
|
|
# sh bootstrap.sh <public-repo-url> # or run it bare and answer the prompt
|
|
#
|
|
# 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
|
|
|
|
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; }
|
|
|
|
# Not fatal -- the public tier applies fine as root -- but brew-only packages
|
|
# (lazygit, omp, herdr) will refuse later, so say it now rather than then.
|
|
[ "$(id -u)" -ne 0 ] || echo "bootstrap.sh: running as root — Homebrew will refuse later; a normal user with sudo is the happy path" >&2
|
|
|
|
sh -c "$(curl -fsLS get.chezmoi.io)" -- init --apply "$URL" || exit 1
|
|
|
|
echo
|
|
echo "next: ~/.local/bin/dotup (full path — this shell's PATH predates the install)"
|