Files
timemaster/push-frontend.sh
T
patrickandClaude Opus 4.8 8ae792fd90 chore(deploy): entkoppelte Self-Update-Skripte pro Server
Jeder Server aktualisiert sich eigenstaendig aus dem Repo – kein
Cross-Server-SSH, kein "both". 137 und 164 komplett getrennt.

- server-update.sh: laeuft AUF dem Server (git pull --ff-only → alembic
  upgrade head → restart → health). Guard: bricht ab wenn venv fehlt.
- push-frontend.sh: lokal, baut Frontend + rsync dist/ an EINEN Server
  (Node laeuft nicht auf den Servern, dist ist gitignored). Guard gegen
  Ausfuehrung auf einem Zielserver.
- deploy.sh + update.sh stillgelegt (Abbruch-Stubs): deploy.sh rsyncte den
  Arbeitsbaum in den Server-git-Baum und verschmutzte ihn (git pull brach);
  update.sh koppelte beide Server ("both").

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 16:29:43 +02:00

50 lines
1.9 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
# =============================================================================
# push-frontend.sh LOKAL auf dem Dev-Rechner ausführen
#
# Baut das Frontend und liefert die dist/ an GENAU EINEN Server.
# Nötig, weil auf den Servern kein Node läuft und frontend/dist gitignored ist
# (server-update.sh kann das Frontend also nicht selbst bauen).
#
# Usage:
# ./push-frontend.sh 137 # → root@192.168.1.137
# ./push-frontend.sh 164 # → root@192.168.1.164
# ./push-frontend.sh 137 --no-build # bestehendes dist/ nur syncen
# =============================================================================
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
FRONTEND_DIR="$SCRIPT_DIR/frontend"
REMOTE_PATH="/opt/timemaster"
GREEN='\033[0;32m'; RED='\033[0;31m'; NC='\033[0m'
log() { echo -e "${GREEN}==>${NC} $*"; }
die() { echo -e "${RED}[FEHLER]${NC} $*" >&2; exit 1; }
TARGET="${1:-}"
case "$TARGET" in
137) SERVER="root@192.168.1.137" ;;
164) SERVER="root@192.168.1.164" ;;
*) die "Server angeben: 137 oder 164 (z.B. ./push-frontend.sh 137)" ;;
esac
# Schutz: nicht versehentlich auf dem Zielserver ausführen
for ip in 192.168.1.137 192.168.1.164; do
[[ " $(hostname -I 2>/dev/null) " == *" $ip "* ]] && die "Läuft auf einem Zielserver nur lokal auf dem Dev-Rechner ausführen."
done
DO_BUILD=true
[[ "${2:-}" == "--no-build" ]] && DO_BUILD=false
if $DO_BUILD; then
log "npm run build"
( cd "$FRONTEND_DIR" && npm run build ) || die "Frontend-Build fehlgeschlagen."
fi
[[ -f "$FRONTEND_DIR/dist/index.html" ]] || die "dist/index.html fehlt erst bauen."
log "rsync dist/ → $SERVER:$REMOTE_PATH/frontend/dist/"
rsync -az --delete "$FRONTEND_DIR/dist/" "$SERVER:$REMOTE_PATH/frontend/dist/" \
|| die "rsync fehlgeschlagen (SSH-Key/Host-Key prüfen)."
log "✓ Frontend auf $TARGET aktualisiert"