# CDN Update Script This document describes a reference implementation of the `cdn-update.sh` automation script for the Community CDN architecture. The script is designed to: * Download the signed control file * Verify its signature * Validate JSON syntax * Generate fail2ban configuration * Generate nginx configuration * Select an available origin * Synchronize content using rsync * Export Prometheus metrics * Fail safely when configuration validation fails --- # Reference Script ```bash #!/usr/bin/env bash set -euo pipefail ############################################################################### # Configuration ############################################################################### BASE="/var/lib/cdn" CONFIG_DIR="${BASE}/config" CONTENT_DIR="${BASE}/content" METRICS_DIR="${BASE}/metrics" CONTROL_URL="https://control.example.org/hpr.ccdn.settings.json" SIG_URL="https://control.example.org/hpr.ccdn.settings.json.minisig" PUBKEY="RWQxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" CONTROL_FILE="${CONFIG_DIR}/hpr.ccdn.settings.json" SIG_FILE="${CONFIG_DIR}/hpr.ccdn.settings.json.minisig" NGINX_GEN="/etc/nginx/conf.d/cdn-generated.conf" FAIL2BAN_JAIL="/etc/fail2ban/jail.d/cdn-generated.local" METRICS_FILE="${METRICS_DIR}/cdn.prom" TMPDIR="$(mktemp -d)" ############################################################################### # Metrics helper ############################################################################### metric_write() { cat > "${METRICS_FILE}" < "${FAIL2BAN_JAIL}" < "${NGINX_GEN}" <