#!/usr/bin/env bash # publish-maps.sh — publish a project's docs/ (Archify maps, Mermaid sources, # diagrams) to the central maps site behind Caddy on .35. # # URL: https://maps.lab.audasmedia.com.au//docs/ (file_server browse) # Host: sam@192.168.20.35:/Docker/Containers/caddy/maps/ # # Usage: # publish-maps.sh [] # default: current directory # publish-maps.sh --list # list what's already published # # Incremental + atomic (rsync -az): only changed blocks transfer; files are # renamed into place so a failure mid-run can't leave a half-written map. set -euo pipefail REMOTE="sam@192.168.20.35" DEST_ROOT="/Docker/Containers/caddy/maps" SSH_E="-e ssh -o BatchMode=yes -o ConnectTimeout=8" if [[ "${1:-}" == "--list" ]]; then ssh -o BatchMode=yes -o ConnectTimeout=8 "$REMOTE" "ls -1 $DEST_ROOT" \ || { echo "cannot reach $REMOTE" >&2; exit 1; } exit 0 fi PROJ="${1:-$(pwd)}" PROJ="$(cd "$PROJ" && pwd)" NAME="$(basename "$PROJ")" DOCS="$PROJ/docs" if [[ ! -d "$DOCS" ]]; then echo "no docs/ found in $PROJ — nothing to publish" >&2 exit 1 fi DEST="$DEST_ROOT/$NAME/docs" echo "→ publishing $PROJ/docs → $REMOTE:$DEST" # Create the project's parent dir on the remote (rsync won't make nested parents) ssh -o BatchMode=yes -o ConnectTimeout=8 "$REMOTE" "mkdir -p $DEST" \ || { echo "cannot create $DEST on $REMOTE" >&2; exit 1; } # -a archive, -z compress, --exclude Archify visual-check sidecars (screenshots # + receipts live next to the map; keeps the browse index clean) rsync -az \ --exclude '*.visual-check.*' \ "$SSH_E" \ "$DOCS/" "$REMOTE:$DEST/" echo "✓ published: https://maps.lab.audasmedia.com.au/$NAME/docs/" echo " (site index: https://maps.lab.audasmedia.com.au/)"