rpg-westreiche/tools/deploy_web.sh
torsten 2dd6295caf Westreiche: Vault, Werkzeuge und Website
Neuinitialisierung ohne den PDF-Ballast (Regelwerke/Abenteuer/Magazine liegen
auf dem Server, siehe tools/pdf_sync.py und tools/pdf_manifest.json).
Vorherige Historie bewusst verworfen.
2026-11-20 17:20:36 +01:00

44 lines
1.3 KiB
Bash
Executable file
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# Lädt den gebauten Webauftritt (web/) per explizitem FTPS nach public_html/.
# Voraussetzung: `python3 tools/build_site.py` wurde ausgeführt.
#
# Aufruf: ./tools/deploy_web.sh [--dry-run]
set -euo pipefail
cd "$(dirname "$0")/.."
[ -f credentials.txt ] || { echo "credentials.txt fehlt" >&2; exit 1; }
[ -d web ] || { echo "web/ fehlt – erst tools/build_site.py ausführen" >&2; exit 1; }
set -a; . ./credentials.txt; set +a
DRY=0
[ "${1:-}" = "--dry-run" ] && DRY=1
TARGET="public_html"
upload() {
local src="$1" dst="$2"
if [ "$DRY" = 1 ]; then
echo "would upload $src -> ftp://$FTP_URL/$dst"
return
fi
curl -s -S --ssl-reqd --ftp-create-dirs --max-time 120 --user "$FTP_USER:$FTP_PASSWORD" \
-T "$src" "ftp://$FTP_URL/$dst" || { echo "FEHLER: $src" >&2; return 1; }
echo "ok $dst"
}
# Einzeldateien (nur was gebaut wurde – weltenauge.php fehlt, solange das
# Projekt ruht; siehe SHOW_WELTENAUGE in tools/build_site.py)
for f in index.php weltenauge.php; do
[ -f "web/$f" ] || continue
upload "web/$f" "$TARGET/$f"
done
# assets/ und westreiche/ rekursiv
while IFS= read -r -d '' file; do
rel="${file#web/}"
upload "$file" "$TARGET/$rel"
done < <(find web/assets web/westreiche -type f -print0 | sort -z)
echo "Deploy abgeschlossen ($([ "$DRY" = 1 ] && echo "dry-run" || echo "live"))."