cd /opt/otb_tracker || exit 1 cat > /tmp/otb_tracker_shared_brand_patch.sh <<'EOF' #!/usr/bin/env bash set -euo pipefail APP_ROOT="/opt/otb_tracker" SHARED_ROOT="/opt/otb/otb-shared-brand" STAMP="$(date +%Y%m%d-%H%M%S)" cd "$APP_ROOT" || exit 1 echo "===== detect template/static roots =====" TPL_ROOT="" STATIC_ROOT="" if [ -d "$APP_ROOT/templates" ]; then TPL_ROOT="$APP_ROOT/templates" elif [ -d "$APP_ROOT/backend/templates" ]; then TPL_ROOT="$APP_ROOT/backend/templates" else echo "ERROR: no templates dir found" exit 1 fi if [ -d "$APP_ROOT/static" ]; then STATIC_ROOT="$APP_ROOT/static" elif [ -d "$APP_ROOT/backend/static" ]; then STATIC_ROOT="$APP_ROOT/backend/static" else echo "ERROR: no static dir found" exit 1 fi echo "Templates: $TPL_ROOT" echo "Static: $STATIC_ROOT" echo "===== ensure shared brand exists and is current =====" cd "$SHARED_ROOT" || exit 1 git pull origin main cd "$APP_ROOT" || exit 1 echo "===== backup =====" mkdir -p "$APP_ROOT/backups/shared-brand-$STAMP" cp -a "$TPL_ROOT" "$APP_ROOT/backups/shared-brand-$STAMP/templates" cp -a "$STATIC_ROOT" "$APP_ROOT/backups/shared-brand-$STAMP/static" echo "===== create includes dir =====" mkdir -p "$TPL_ROOT/includes" mkdir -p "$STATIC_ROOT/css" echo "===== sync shared assets =====" cp "$SHARED_ROOT/brand.css" "$STATIC_ROOT/css/brand.css" cp "$SHARED_ROOT/brand.js" "$STATIC_ROOT/brand.js" echo "===== sync shared header include =====" cp "$SHARED_ROOT/fragments/header.html" "$TPL_ROOT/includes/site_nav.html" echo "===== write canonical shared footer includes =====" cat > "$TPL_ROOT/includes/otb_statusbar.html" <<'EOT'
EOT cat > "$TPL_ROOT/includes/otb_footer.html" <<'EOT' {% include "includes/otb_statusbar.html" %} EOT echo "===== patch html templates =====" python3 <