43 lines
1.6 KiB
Bash
Executable File
43 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# First-time setup on a fresh machine:
|
|
#
|
|
# export GITEA_TOKEN=... # read access to ziadarafat/dotfiles
|
|
# curl -fsSL -H "Authorization: token $GITEA_TOKEN" \
|
|
# https://gitea.godemperordoge.org/ziadarafat/dotfiles/raw/branch/main/bootstrap.sh | bash
|
|
#
|
|
# Options (env): DOTFILES_PROFILE=full|full-work|headless, DOTFILES_SKIP_SYSTEM=1 (no sudo), DOTFILES_REF=main
|
|
export USER=${USER:-$(id -un)}
|
|
set -euo pipefail
|
|
|
|
REPO="https://gitea.godemperordoge.org/ziadarafat/dotfiles.git"
|
|
DIR="${DOTFILES_DIR:-$HOME/.dotfiles}"
|
|
REF="${DOTFILES_REF:-main}"
|
|
|
|
need() { command -v "$1" >/dev/null 2>&1; }
|
|
as_root() { if [ "$(id -u)" = 0 ]; then "$@"; else sudo "$@"; fi; }
|
|
|
|
if ! need git || ! need curl || ! need xz; then
|
|
echo "==> installing git/curl/xz"
|
|
. /etc/os-release
|
|
case "$ID" in
|
|
fedora|almalinux|rhel|rocky) as_root dnf install -y git curl xz ;;
|
|
arch|cachyos|endeavouros|manjaro) as_root pacman -Sy --needed --noconfirm git curl xz ;;
|
|
debian|ubuntu) as_root apt-get update && as_root apt-get install -y git curl xz-utils ;;
|
|
steamos) ;; # ships all three
|
|
*) echo "install git, curl and xz, then re-run" >&2; exit 1 ;;
|
|
esac
|
|
fi
|
|
|
|
if [ ! -d "$DIR/.git" ]; then
|
|
echo "==> cloning dotfiles into $DIR"
|
|
auth=()
|
|
[ -n "${GITEA_TOKEN:-}" ] && auth=(-c "http.extraHeader=Authorization: token $GITEA_TOKEN")
|
|
git "${auth[@]}" clone --branch "$REF" "$REPO" "$DIR"
|
|
fi
|
|
|
|
mkdir -p "$HOME/.config/dotfiles"
|
|
[ -n "${DOTFILES_PROFILE:-}" ] && echo "$DOTFILES_PROFILE" >"$HOME/.config/dotfiles/profile"
|
|
|
|
export DOTFILES_DIR="$DIR"
|
|
exec "$DIR/bin/dot" bootstrap
|