#!/bin/bash set -e APP_DIR="/opt/aufmassweb/_aufmass_web" LOG_FILE="/var/log/aufmassweb-deploy.log" log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" | tee -a "$LOG_FILE" } log "=== Deployment gestartet ===" cd "$APP_DIR" log "Pull von Gitea..." cd /opt/aufmassweb && git pull origin main 2>&1 | tee -a "$LOG_FILE" log "Pip install..." cd "$APP_DIR" && source venv/bin/activate && pip install --no-cache-dir -r requirements.txt 2>&1 | tee -a "$LOG_FILE" log "DB-Migration..." cd "$APP_DIR" && source venv/bin/activate && flask db upgrade 2>&1 | tee -a "$LOG_FILE" || echo "No migration needed" log "Restart..." systemctl restart aufmassweb 2>&1 | tee -a "$LOG_FILE" log "=== Deployment erfolgreich abgeschlossen ==="