Skip to content

Instantly share code, notes, and snippets.

@thetanil
Created May 9, 2026 15:13
Show Gist options
  • Select an option

  • Save thetanil/aacb9f7a80d3b2dcf921b6a1bd00f8a5 to your computer and use it in GitHub Desktop.

Select an option

Save thetanil/aacb9f7a80d3b2dcf921b6a1bd00f8a5 to your computer and use it in GitHub Desktop.
Machine bootstrap: installs git+uv, clones thetanil/resto, writes ~/.vaultpass, runs ansible
#!/usr/bin/env bash
# bootstrap.sh — full machine bootstrap for thetanil/resto
#
# Usage (store this in your password manager with real values):
# GH_TOKEN=ghp_xxxx VAULT_PASS=hunter2 bash <(curl -LsSf https://gist.githubusercontent.com/thetanil/REPLACE_WITH_GIST_ID/raw/bootstrap.sh)
#
# GH_TOKEN — fine-grained GitHub token with read-only access to thetanil/resto
# VAULT_PASS — ansible-vault password; written to ~/.vaultpass (chmod 600)
set -euo pipefail
REPO_URL="https://${GH_TOKEN}@github.com/thetanil/resto"
DOTFILES="$HOME/dotfiles"
# --- validate ---
if [[ -z "${GH_TOKEN:-}" ]]; then
echo "ERROR: GH_TOKEN is not set" >&2
exit 1
fi
if [[ -z "${VAULT_PASS:-}" ]]; then
echo "ERROR: VAULT_PASS is not set" >&2
exit 1
fi
# --- install git ---
install_git() {
if command -v git &>/dev/null; then return; fi
echo "==> Installing git..."
if command -v apt-get &>/dev/null; then
sudo apt-get update -qq && sudo apt-get install -y -qq git
elif command -v pacman &>/dev/null; then
sudo pacman -Sy --noconfirm git
elif command -v dnf &>/dev/null; then
sudo dnf install -y git
elif command -v brew &>/dev/null; then
brew install git
else
echo "ERROR: cannot install git — unsupported package manager" >&2
exit 1
fi
}
# --- install uv ---
install_uv() {
if command -v uv &>/dev/null; then return; fi
echo "==> Installing uv..."
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
}
# --- clone repo ---
clone_repo() {
if [[ -d "$DOTFILES/.git" ]]; then
echo "==> $DOTFILES already exists, pulling latest..."
git -C "$DOTFILES" pull --ff-only
else
echo "==> Cloning thetanil/resto..."
git clone "$REPO_URL" "$DOTFILES"
fi
}
# --- write vault password ---
write_vaultpass() {
echo "==> Writing ~/.vaultpass..."
printf '%s\n' "$VAULT_PASS" > "$HOME/.vaultpass"
chmod 600 "$HOME/.vaultpass"
}
# --- run playbook ---
run_bootstrap() {
echo "==> Running bootstrap.py..."
cd "$DOTFILES"
uv run bootstrap.py
}
install_git
install_uv
clone_repo
write_vaultpass
run_bootstrap
echo ""
echo "Bootstrap complete."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment