#!/usr/bin/env sh # Bootstrap: curl -fsSL https://install.visudo.icu | sh # Supports: curl -fsSL | sh -s -- [install.sh flags...] set -e # --- Colors (POSIX-safe, respects NO_COLOR) --- if [ -n "${NO_COLOR:-}" ] || [ ! -t 1 ]; then RED='' GREEN='' DIM='' NC='' else RED='\033[0;31m' GREEN='\033[0;32m' DIM='\033[2m' NC='\033[0m' fi info() { printf " %b●%b %s\n" "$GREEN" "$NC" "$*"; } error() { printf " %b●%b %s\n" "$RED" "$NC" "$*" >&2; } # --- Preflight --- if [ "$(id -u)" = "0" ]; then error "Do not run this as root" exit 1 fi if [ "$(uname)" != "Linux" ]; then error "This installer only supports Linux" exit 1 fi if ! command -v bash >/dev/null 2>&1; then error "bash is required" exit 1 fi if ! command -v curl >/dev/null 2>&1; then error "curl is required — install it first, then re-run" exit 1 fi # --- Parse arguments --- BASE_URL="${DOTFILES_URL:-https://install.visudo.icu}" DOTFILES_DIR="$HOME/.dotfiles" INSTALL_ARGS="" while [ $# -gt 0 ]; do case "$1" in --dir|-d) DOTFILES_DIR="$2"; shift 2 ;; *) INSTALL_ARGS="$INSTALL_ARGS $1"; shift ;; esac done # --- Download and extract --- info "Downloading dotfiles..." if [ -d "$DOTFILES_DIR" ]; then info "Existing install found at $DOTFILES_DIR — updating..." rm -rf "$DOTFILES_DIR" fi mkdir -p "$DOTFILES_DIR" if ! curl -fsSL "$BASE_URL/dotfiles.tar.gz" | tar -xz -C "$DOTFILES_DIR"; then error "Failed to download or extract dotfiles from $BASE_URL/dotfiles.tar.gz" exit 1 fi # --- Verify download integrity --- if [ ! -f "$DOTFILES_DIR/install.sh" ]; then error "Download appears corrupted — install.sh not found in $DOTFILES_DIR" exit 1 fi # --- Launch installer --- info "Launching installer..." printf " %b%s%b\n\n" "$DIM" "$DOTFILES_DIR/install.sh$INSTALL_ARGS" "$NC" # shellcheck disable=SC2086 exec bash "$DOTFILES_DIR/install.sh" $INSTALL_ARGS