#!/usr/bin/env bash # Deploy the current main commit to every federation host listed in # scripts/hosts (one node per line: LABEL SSH_TARGET REMOTE_PATH PUBLIC_URL). # Loops scripts/deploy.sh against each. Bails on first failure unless --keep-going. set -euo pipefail HOSTS_FILE="${PSYC_HOSTS_FILE:-$(dirname "$0")/hosts}" KEEP_GOING=0 for arg in "$@"; do case "$arg" in --keep-going) KEEP_GOING=1 ;; -h|--help) echo "usage: $0 [--keep-going]" echo " reads $HOSTS_FILE (override with PSYC_HOSTS_FILE=...)" exit 0 ;; esac done if [[ ! -f "$HOSTS_FILE" ]]; then echo "no hosts file at $HOSTS_FILE — copy scripts/hosts.example to scripts/hosts and edit" >&2 exit 2 fi declare -a OK=() FAIL=() while IFS= read -r line; do # skip blanks + comments [[ -z "${line// /}" || "${line# }" == \#* ]] && continue # shellcheck disable=SC2206 parts=($line) if [[ ${#parts[@]} -lt 4 ]]; then echo "[deploy-all] skipping malformed line: $line" >&2 continue fi LABEL="${parts[0]}" SSH_TARGET="${parts[1]}" REMOTE_PATH="${parts[2]}" PUBLIC_URL="${parts[3]}" echo echo "════════════════════════════════════════════════════════════════" echo " deploying → $LABEL ($SSH_TARGET:$REMOTE_PATH → $PUBLIC_URL)" echo "════════════════════════════════════════════════════════════════" if PSYC_PROD_HOST="$SSH_TARGET" \ PSYC_PROD_PATH="$REMOTE_PATH" \ PSYC_PROD_URL="$PUBLIC_URL" \ bash "$(dirname "$0")/deploy.sh" < /dev/null; then OK+=("$LABEL") else FAIL+=("$LABEL") if [[ $KEEP_GOING -ne 1 ]]; then echo "[deploy-all] $LABEL failed — stopping. pass --keep-going to continue past failures." >&2 break fi fi done < "$HOSTS_FILE" echo echo "════════════════════════════════════════════════════════════════" echo " summary" echo "════════════════════════════════════════════════════════════════" echo " ok: ${OK[*]:-(none)}" echo " failed: ${FAIL[*]:-(none)}" [[ ${#FAIL[@]} -eq 0 ]]