1227e2716d
- rapport-lxc.sh: LOCAL_STACK / LOCAL_MIGRATIONS Tarballs werden per pct push in den Container geschoben statt git clone / sync-migrations - deploy-local.sh: läuft auf dem Mac, tart die lokalen Working-Copies (SERVER-CONTAINER + APP/supabase/migrations), scp auf den Proxmox-Host, ruft rapport-lxc.sh im Local-Modus mit durchgereichten Parametern - README: Local-Deploy als empfohlener Test-Pfad dokumentiert Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
73 lines
3.9 KiB
Bash
Executable File
73 lines
3.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# ─────────────────────────────────────────────────────────────────────────────
|
|
# RAPPORT Server — Local-Deploy auf einen Proxmox-Host (OHNE Gitea)
|
|
#
|
|
# Läuft auf deinem MAC. Packt die lokalen Working-Copies von SERVER-CONTAINER
|
|
# und den APP-Migrations, kopiert sie + rapport-lxc.sh per scp auf den
|
|
# Proxmox-Host und ruft dort rapport-lxc.sh im Local-Modus auf.
|
|
#
|
|
# PVE_HOST=root@192.168.1.10 bash deploy-local.sh
|
|
#
|
|
# Alle rapport-lxc.sh-Parameter (RAM_MB, NET_IP, …) werden durchgereicht:
|
|
# PVE_HOST=root@192.168.1.10 RAM_MB=8192 NET_IP=192.168.1.50/24 \
|
|
# NET_GW=192.168.1.1 bash deploy-local.sh
|
|
# ─────────────────────────────────────────────────────────────────────────────
|
|
set -euo pipefail
|
|
|
|
# ═══ Konfiguration ══════════════════════════════════════════════════════════
|
|
PVE_HOST="${PVE_HOST:-}" # root@<proxmox-ip> (Pflicht)
|
|
PVE_SSH_PORT="${PVE_SSH_PORT:-22}"
|
|
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
RAPPORT_ROOT="${RAPPORT_ROOT:-$(cd "$HERE/.." && pwd)}" # ~/RAPPORT
|
|
STACK_DIR="${STACK_DIR:-$RAPPORT_ROOT/SERVER-CONTAINER}"
|
|
APP_DIR="${APP_DIR:-$RAPPORT_ROOT/APP}"
|
|
MIGRATIONS_DIR="${MIGRATIONS_DIR:-$APP_DIR/supabase/migrations}"
|
|
|
|
GN='\033[0;32m'; YW='\033[0;33m'; RD='\033[0;31m'; BL='\033[1;34m'; CL='\033[0m'
|
|
msg() { echo -e "${GN}✔${CL} $*"; }
|
|
info() { echo -e "${YW}→${CL} $*"; }
|
|
die() { echo -e "${RD}✗${CL} $*" >&2; exit 1; }
|
|
|
|
echo -e "${BL}RAPPORT Server — Local-Deploy auf Proxmox${CL}"
|
|
[[ -n "$PVE_HOST" ]] || die "PVE_HOST nicht gesetzt. Beispiel: PVE_HOST=root@192.168.1.10 bash deploy-local.sh"
|
|
[[ -d "$STACK_DIR" ]] || die "STACK_DIR nicht gefunden: $STACK_DIR"
|
|
[[ -d "$MIGRATIONS_DIR" ]] || die "MIGRATIONS_DIR nicht gefunden: $MIGRATIONS_DIR"
|
|
ls "$MIGRATIONS_DIR"/*.sql >/dev/null 2>&1 || die "Keine *.sql in $MIGRATIONS_DIR"
|
|
|
|
SSH="ssh -p $PVE_SSH_PORT $PVE_HOST"
|
|
SCP="scp -P $PVE_SSH_PORT"
|
|
|
|
# ═══ 1 · Tarballs bauen ═════════════════════════════════════════════════════
|
|
TMP="$(mktemp -d)"
|
|
trap 'rm -rf "$TMP"' EXIT
|
|
STACK_TAR="$TMP/rapport-stack.tar.gz"
|
|
MIGR_TAR="$TMP/rapport-migrations.tar.gz"
|
|
|
|
info "Packe Stack aus $STACK_DIR …"
|
|
tar --exclude='.git' --exclude='node_modules' --exclude='.env' \
|
|
--exclude='volumes/db/data' --exclude='.DS_Store' \
|
|
-czf "$STACK_TAR" -C "$STACK_DIR" .
|
|
|
|
info "Packe Migrations aus $MIGRATIONS_DIR …"
|
|
tar -czf "$MIGR_TAR" -C "$MIGRATIONS_DIR" $(cd "$MIGRATIONS_DIR" && ls *.sql)
|
|
msg "Tarballs gebaut ($(du -h "$STACK_TAR" | cut -f1) Stack, $(du -h "$MIGR_TAR" | cut -f1) Migrations)."
|
|
|
|
# ═══ 2 · Auf Proxmox-Host kopieren ══════════════════════════════════════════
|
|
info "Kopiere Dateien nach $PVE_HOST:/tmp/ …"
|
|
$SCP "$STACK_TAR" "$MIGR_TAR" "$HERE/rapport-lxc.sh" "$PVE_HOST:/tmp/"
|
|
msg "Dateien übertragen."
|
|
|
|
# ═══ 3 · rapport-lxc.sh im Local-Modus auf dem Host starten ═════════════════
|
|
# Alle relevanten Parameter aus DIESER Shell an den Remote-Aufruf durchreichen.
|
|
ENV_PASS=""
|
|
for v in CTID CT_HOSTNAME CORES RAM_MB SWAP_MB DISK_GB BRIDGE STORAGE \
|
|
TMPL_STORAGE NET_IP NET_GW PASSWORD TEMPLATE; do
|
|
if [[ -n "${!v:-}" ]]; then
|
|
ENV_PASS+="$v=$(printf '%q' "${!v}") "
|
|
fi
|
|
done
|
|
|
|
info "Starte rapport-lxc.sh auf $PVE_HOST …"
|
|
echo
|
|
$SSH "LOCAL_STACK=/tmp/rapport-stack.tar.gz LOCAL_MIGRATIONS=/tmp/rapport-migrations.tar.gz ${ENV_PASS}bash /tmp/rapport-lxc.sh"
|