#!/usr/bin/env bash # Generischer Deploy für GeoGraSim — robust gegen Server-Doppelstruktur. # # Problem: Apache-DocumentRoot auf Prod ist /var/www/html/geograsim/ # (NICHT /var/www/html/geograsim/App/). Daher MÜSSEN alle Inhalte aus # App/ sowohl im App/-Subdir als auch im Top-Level liegen — sonst sieht # Apache sie nicht. Dieses Skript syncht beides. # # Voraussetzung: ssh-agent läuft mit ~/.ssh/openclaw geladen. # # Aufruf (aus Repo-Root /c/xampp/htdocs/geograsim/): # bash App/Don_t_Deploy/deploy.sh # bash App/Don_t_Deploy/deploy.sh App/Don_t_Deploy/migrate-XYZ.sql # mit DB-Migration # # Optionaler erster Parameter: SQL-Migration-File. set -e SSH_OPTS="-i ~/.ssh/openclaw -o StrictHostKeyChecking=accept-new" HOST="root@85.215.155.82" DEST="/root/webstack/projects/geograsim" SQL_FILE="${1:-}" if ! ssh-add -l >/dev/null 2>&1; then echo "ERROR: ssh-agent ist nicht aktiv oder Key nicht geladen." echo "Starte zuerst:" echo " eval \$(ssh-agent)" echo " ssh-add ~/.ssh/openclaw" exit 1 fi echo "=== 1) Code-Tar bauen (alle Files in App/ ohne node_modules/Don_t_Deploy/...) ===" TAR=/tmp/geograsim-deploy-$(date +%Y%m%d-%H%M%S).tar.gz tar -czf "$TAR" \ --exclude='App/node_modules' \ --exclude='App/src' \ --exclude='App/tests' \ --exclude='App/Don_t_Deploy' \ --exclude='App/.env.local' \ --exclude='App/package*' \ --exclude='App/vite*' \ --exclude='App/tsconfig*' \ --exclude='*.log' \ --exclude='_original' \ --exclude='*.bak-*' \ --exclude='*.bak-pre-*' \ --exclude='App/.LocalDeveloperTools' \ --exclude='App/bulk-reset-lernapps.php' \ App/ ls -lh "$TAR" | awk '{print "Tar:", $5, $NF}' echo "=== 2) Hochladen ===" scp $SSH_OPTS "$TAR" "$HOST:/tmp/deploy.tar.gz" echo "=== 3) Auf Prod entpacken + Top-Level spiegeln ===" ssh $SSH_OPTS "$HOST" " cd $DEST && tar -xzf /tmp/deploy.tar.gz && rm /tmp/deploy.tar.gz && cp -R App/sims/. sims/ && cp -R App/pages/. pages/ && cp -R App/assets/. assets/ && cp -R App/php/. php/ && for d in forschung data docs scripts; do if [ -d \"App/\$d\" ]; then mkdir -p \"\$d\" && cp -R \"App/\$d/.\" \"\$d/\"; fi done && find App/ -maxdepth 1 -type f \( -name '*.html' -o -name '*.php' -o -name '*.svg' -o -name '*.png' -o -name '*.txt' -o -name '*.ico' -o -name '.htaccess' \) -exec cp {} ./ \; && docker exec webstack-php php -r 'opcache_reset();' && echo 'CODE_OK' " if [ -n "$SQL_FILE" ] && [ -f "$SQL_FILE" ]; then echo "=== 4) SQL-Migration: $SQL_FILE ===" scp $SSH_OPTS "$SQL_FILE" "$HOST:/tmp/migrate.sql" ssh $SSH_OPTS "$HOST" " docker cp /tmp/migrate.sql webstack-mysql:/tmp/migrate.sql && docker exec webstack-mysql sh -c 'mysql --default-character-set=utf8mb4 -uroot -pServerMySQL2026! geograsim < /tmp/migrate.sql' && rm /tmp/migrate.sql && echo 'DB_OK' " fi echo "=== 5) Smoke-Test ===" echo -n " / "; curl -sI "https://geograsim.at/" | head -1 echo -n " /heli-game "; curl -sI "https://geograsim.at/heli-game" | head -1 echo -n " /staustufen "; curl -sI "https://geograsim.at/staustufen" | head -1 echo -n " /schueler "; curl -sI "https://geograsim.at/schueler" | head -1 echo "=== Fertig ==="