#!/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, simplex) # or any generic script (harden-ssh, harden-jumphost, sshuser). # 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 } command -v git >/dev/null 2>&1 || { command -v apk >/dev/null 2>&1 && apk add -q git; } _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 simplex) SCRIPTS=(setup-host harden-ssh harden-jumphost sshuser auto-update) # ---------------------------------------------------------------------------- # Prompt helpers (gum). `ask` records each answer in ENVS for passing onward. # ---------------------------------------------------------------------------- ENVS=() ask() { #