#!/usr/bin/env bash # # automations.sh -- one command to run or deploy anything in this repo. # # Run it two ways: # # 1. One-liner on a fresh target host (clones the repo, then launches): # curl -fsSL https://git.anomalous.dev/57_Wolve/automations/raw/branch/main/automations.sh \ # | REPO_URL=https://git.anomalous.dev/57_Wolve/automations.git bash # # 2. From a clone: # ./automations.sh # # It opens a Gum wizard (auto-installed) that lets you: # • Mode: deploy on THIS host, or build deploy.sh artifacts locally. # • Pick any deployment (pocket-id, beszel, headscale, webfinger, squid, # copyparty, simplex, openbao) or any generic script (setup-host, harden-ssh, # harden-jumphost, sshuser, auto-update). # Shared defaults come from globals/ (see globals/README.md). # # Non-interactive: set SKIP_PROMPTS=1 plus the needed vars and pipe the menu # choices in, or just call the underlying deployments//deploy.sh # directly -- they all honor SKIP_PROMPTS=1. set -euo pipefail # ---------------------------------------------------------------------------- # Self-locate, or bootstrap by cloning the repo (one-liner / piped form). # ---------------------------------------------------------------------------- _self="${BASH_SOURCE[0]:-}" if [[ -n "$_self" && -f "$(cd "$(dirname "$_self")" 2>/dev/null && pwd)/scripts/lib.sh" ]]; then ROOT="$(cd "$(dirname "$_self")" && pwd)" else # Piped via curl: we don't have the repo on disk. Clone it, then re-exec. : "${REPO_URL:=}" : "${REPO_BRANCH:=main}" [[ -n "$REPO_URL" ]] || { echo "[x] Running standalone (piped). Set REPO_URL=... so I can clone the repo." >&2 exit 1 } # We need git to clone, but oslib.sh's pkg_install isn't on disk yet (that's # what we're cloning). Install git inline across the supported package # managers -- apk (Alpine), apt-get (Debian/Ubuntu), dnf/yum (Alma/RHEL). if ! command -v git >/dev/null 2>&1; then echo "[+] git not found; installing it..." >&2 if command -v apk >/dev/null 2>&1; then apk add -q git || true elif command -v apt-get >/dev/null 2>&1; then { apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq git; } || true elif command -v dnf >/dev/null 2>&1; then dnf install -y -q git || true elif command -v yum >/dev/null 2>&1; then yum install -y -q git || true fi fi command -v git >/dev/null 2>&1 || { echo "[x] git is required to clone the repo, but it isn't installed and I couldn't install it automatically (need root + a supported package manager). Install git, then re-run." >&2 exit 1 } _tmp="$(mktemp -d -t automations.XXXXXX)" echo "[+] Cloning $REPO_URL ($REPO_BRANCH)..." git clone --depth 1 --branch "$REPO_BRANCH" "$REPO_URL" "$_tmp" exec bash "$_tmp/automations.sh" "$@" fi # shellcheck source=scripts/lib.sh . "$ROOT/scripts/lib.sh" load_globals DEPLOYMENTS=(pocket-id beszel headscale webfinger squid copyparty simplex openbao) SCRIPTS=(setup-host harden-ssh harden-jumphost sshuser auto-update) # ---------------------------------------------------------------------------- # Prompt helpers (gum). `ask` records each answer in ENVS for passing onward. # ---------------------------------------------------------------------------- ENVS=() ask() { #