#!/usr/bin/env bash # # install.sh - tiny entrypoint for the curl|bash oneliner. # Ensures git, clones the repo, hands off to bootstrap.sh. # # Configurable via env: # REPO_URL git url (default: this public repo) # REF branch/tag/commit to check out (default: main) # DEST clone destination (default: /opt/linux-bootstrap) # Any extra args are forwarded to bootstrap.sh, e.g.: # curl -fsSL .../install.sh | bash -s -- --skip hardening # set -Eeuo pipefail export DEBIAN_FRONTEND=noninteractive REPO_URL="${REPO_URL:-https://github.com/CHANGE_ME/linux-bootstrap.git}" REF="${REF:-main}" DEST="${DEST:-/opt/linux-bootstrap}" say() { printf '\e[34m[install]\e[0m %s\n' "$*"; } if [[ $EUID -ne 0 ]]; then command -v sudo >/dev/null 2>&1 || { echo "need root or sudo"; exit 1; } SUDO="sudo" else SUDO="" fi # 1. ensure git if ! command -v git >/dev/null 2>&1; then say "installing git" if command -v apt-get >/dev/null 2>&1; then $SUDO apt-get update -qq $SUDO apt-get install -y -qq git elif command -v dnf >/dev/null 2>&1; then $SUDO dnf install -y git elif command -v pacman >/dev/null 2>&1; then $SUDO pacman -Sy --noconfirm git else echo "no supported package manager to install git"; exit 1 fi fi # 2. clone or update if [[ -d "$DEST/.git" ]]; then say "updating existing clone at $DEST" $SUDO git -C "$DEST" fetch --depth=1 origin "$REF" $SUDO git -C "$DEST" checkout -f "$REF" $SUDO git -C "$DEST" reset --hard "origin/$REF" 2>/dev/null || true else say "cloning $REPO_URL -> $DEST" $SUDO git clone --depth=1 --branch "$REF" "$REPO_URL" "$DEST" 2>/dev/null \ || $SUDO git clone --depth=1 "$REPO_URL" "$DEST" fi # 3. run bootstrap, forwarding any extra args say "running bootstrap.sh $*" $SUDO chmod +x "$DEST/bootstrap.sh" "$DEST/config/motd/01-banner.sh" exec "$DEST/bootstrap.sh" "$@"