34 lines
1.1 KiB
Bash
Executable File
34 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# bootstrap launcher — curl <shortener> | bash
|
|
#
|
|
# This file is intentionally tiny and stable: its only job is to clone the
|
|
# bootstrap repo (or update an existing clone) and hand off to setup.sh.
|
|
# All real logic lives in the repo so you can update it with `git pull`.
|
|
#
|
|
# Usage:
|
|
# curl -fsSL <shortener> | bash
|
|
# curl -fsSL <shortener> | bash -s -- --yes
|
|
# curl -fsSL <shortener> | bash -s -- --only packages
|
|
|
|
set -euo pipefail
|
|
|
|
REPO_URL="${BOOTSTRAP_REPO:-https://g.mk.fo/bootstrap/main.git}"
|
|
CLONE_DIR="${BOOTSTRAP_HOME:-$HOME/.bootstrap}"
|
|
|
|
need() { command -v "$1" >/dev/null 2>&1 || { echo "bootstrap: missing required command: $1" >&2; exit 1; }; }
|
|
need git
|
|
|
|
if [[ -d "$CLONE_DIR/.git" ]]; then
|
|
echo ">> existing bootstrap at $CLONE_DIR — pulling updates"
|
|
git -C "$CLONE_DIR" pull --ff-only
|
|
else
|
|
if [[ -d "$CLONE_DIR" ]]; then
|
|
mv "$CLONE_DIR" "${CLONE_DIR}.bak.$(date +%Y%m%d-%H%M%S)"
|
|
echo ">> backed up old $CLONE_DIR"
|
|
fi
|
|
echo ">> cloning $REPO_URL -> $CLONE_DIR"
|
|
git clone --depth 1 "$REPO_URL" "$CLONE_DIR"
|
|
fi
|
|
|
|
exec bash "$CLONE_DIR/setup.sh" "$@" |