feat(admin): implement pregnancy and birth management features
Some checks failed
Deploy to production / deploy (push) Failing after 2m6s
Some checks failed
Deploy to production / deploy (push) Failing after 2m6s
- Added new admin functionalities to force pregnancy, clear pregnancy, and trigger birth for characters. - Introduced corresponding routes and controller methods in adminRouter and adminController. - Enhanced the FalukantCharacter model to include pregnancy-related fields. - Created database migration for adding pregnancy columns to the character table. - Updated frontend views and internationalization files to support new pregnancy and birth management features. - Improved user feedback and error handling for these new actions.
This commit is contained in:
@@ -1,113 +1,69 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
TARGET_DIR="${1:?Zielverzeichnis fehlt: ./update-backend.sh <z. B. /opt/yourpart-green> [STAGE]}"
|
||||
# Zweiter Parameter: STAGE für DB-Sync (früher erster Parameter)
|
||||
TARGET_DIR="${1:?target dir required}"
|
||||
STAGE="${2:-production}"
|
||||
BACKEND_TARGET="$TARGET_DIR/backend"
|
||||
|
||||
BACKEND_DIR="$TARGET_DIR/backend"
|
||||
CURRENT_LINK="/opt/yourpart"
|
||||
CURRENT_BACKEND="$CURRENT_LINK/backend"
|
||||
DATA_DIR="/opt/yourpart-data"
|
||||
|
||||
echo "Updating YourPart Backend..."
|
||||
echo "Ziel: $BACKEND_TARGET"
|
||||
echo "Ziel: $BACKEND_DIR"
|
||||
echo "Using STAGE: $STAGE"
|
||||
echo "NOTE: .env files will NOT be overwritten"
|
||||
|
||||
# Zum Backend-Verzeichnis wechseln
|
||||
cd backend
|
||||
cd "$BACKEND_DIR"
|
||||
|
||||
# Alle generierten Verzeichnisse löschen
|
||||
echo "Lösche alle generierten Verzeichnisse..."
|
||||
rm -rf node_modules/.cache/
|
||||
rm -rf logs/
|
||||
rm -rf tmp/
|
||||
|
||||
# Dependencies installieren
|
||||
echo "Installing dependencies..."
|
||||
npm ci --production
|
||||
|
||||
# Sichere .env-Dateien aus dem Ziel-Backend temporär
|
||||
TEMP_ENV_DIR="/tmp/yourpart-env-backup-$$"
|
||||
echo "Sichere .env-Dateien aus $BACKEND_TARGET..."
|
||||
sudo mkdir -p "$TEMP_ENV_DIR"
|
||||
if [ -d "$BACKEND_TARGET" ]; then
|
||||
sudo find "$BACKEND_TARGET" -maxdepth 1 -name '.env*' -type f -exec cp {} "$TEMP_ENV_DIR/" \; 2>/dev/null || true
|
||||
if [ "$(ls -A $TEMP_ENV_DIR 2>/dev/null)" ]; then
|
||||
echo "✓ .env-Dateien gesichert: $(ls $TEMP_ENV_DIR)"
|
||||
mkdir -p "$TEMP_ENV_DIR"
|
||||
|
||||
echo "Sichere .env-Dateien aus $CURRENT_BACKEND..."
|
||||
if [ -d "$CURRENT_BACKEND" ]; then
|
||||
find "$CURRENT_BACKEND" -maxdepth 1 -name '.env*' -type f -exec cp {} "$TEMP_ENV_DIR/" \; 2>/dev/null || true
|
||||
if [ "$(ls -A "$TEMP_ENV_DIR" 2>/dev/null)" ]; then
|
||||
echo "✓ .env-Dateien gesichert: $(ls "$TEMP_ENV_DIR")"
|
||||
cp "$TEMP_ENV_DIR"/.env* "$BACKEND_DIR"/ 2>/dev/null || true
|
||||
else
|
||||
echo "⚠ Keine .env-Dateien in $BACKEND_TARGET gefunden"
|
||||
echo "⚠ Keine .env-Dateien in $CURRENT_BACKEND gefunden"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Altes Backend löschen
|
||||
echo "Lösche altes Backend..."
|
||||
sudo rm -rf "$BACKEND_TARGET"
|
||||
sudo -n mkdir -p "$DATA_DIR/adult-verification"
|
||||
|
||||
# Erstelle Backend-Verzeichnis
|
||||
echo "Erstelle Backend-Verzeichnis..."
|
||||
sudo mkdir -p "$BACKEND_TARGET"
|
||||
sudo mkdir -p /opt/yourpart-data/adult-verification
|
||||
|
||||
# Kopiere neues Backend (ohne .env-Dateien aus dem Quellverzeichnis)
|
||||
echo "Kopiere neues Backend..."
|
||||
if command -v rsync &> /dev/null; then
|
||||
sudo rsync -av --exclude='.env*' --exclude='node_modules' . "$BACKEND_TARGET/" 2>/dev/null
|
||||
if [ -d node_modules ]; then
|
||||
sudo rsync -av --exclude='.env*' node_modules/ "$BACKEND_TARGET/node_modules/" 2>/dev/null || \
|
||||
sudo cp -r node_modules "$BACKEND_TARGET/" 2>/dev/null
|
||||
fi
|
||||
else
|
||||
# Fallback: Kopiere alles außer .env
|
||||
sudo cp -r * "$BACKEND_TARGET/" 2>/dev/null
|
||||
fi
|
||||
|
||||
# Stelle .env-Dateien wieder her
|
||||
echo "Stelle .env-Dateien wieder her..."
|
||||
if [ -d "$TEMP_ENV_DIR" ] && [ "$(ls -A $TEMP_ENV_DIR 2>/dev/null)" ]; then
|
||||
sudo cp "$TEMP_ENV_DIR"/.env* "$BACKEND_TARGET/" 2>/dev/null || true
|
||||
echo "✓ .env-Dateien wiederhergestellt"
|
||||
else
|
||||
echo "⚠ Keine .env-Dateien zum Wiederherstellen vorhanden"
|
||||
fi
|
||||
sudo rm -rf "$TEMP_ENV_DIR"
|
||||
|
||||
# Prüfe ob .env vorhanden ist
|
||||
if [ -f "$BACKEND_TARGET/.env" ]; then
|
||||
if [ -f "$BACKEND_DIR/.env" ]; then
|
||||
echo "✓ .env-Datei ist vorhanden"
|
||||
else
|
||||
echo "⚠ WARNUNG: Keine .env-Datei in $BACKEND_TARGET gefunden!"
|
||||
echo " Bitte manuell erstellen: sudo nano $BACKEND_TARGET/.env"
|
||||
echo "⚠ WARNUNG: Keine .env-Datei in $BACKEND_DIR gefunden!"
|
||||
fi
|
||||
|
||||
# Berechtigungen setzen
|
||||
echo "Setting permissions..."
|
||||
sudo chown -R yourpart:yourpart "$BACKEND_TARGET"
|
||||
sudo chmod -R 755 "$BACKEND_TARGET"
|
||||
sudo chown -R yourpart:yourpart /opt/yourpart-data
|
||||
sudo chmod -R 755 /opt/yourpart-data
|
||||
# Stelle sicher, dass .env-Dateien die richtigen Berechtigungen haben
|
||||
if [ -f "$BACKEND_TARGET/.env" ]; then
|
||||
sudo chmod 600 "$BACKEND_TARGET/.env"
|
||||
sudo -n chown -R yourpart:yourpart "$BACKEND_DIR"
|
||||
sudo -n chmod -R 755 "$BACKEND_DIR"
|
||||
sudo -n chown -R yourpart:yourpart "$DATA_DIR"
|
||||
sudo -n chmod -R 755 "$DATA_DIR"
|
||||
|
||||
if [ -f "$BACKEND_DIR/.env" ]; then
|
||||
sudo -n chmod 600 "$BACKEND_DIR/.env"
|
||||
fi
|
||||
|
||||
# Systemd-Service aktualisieren und neu laden
|
||||
echo "Updating systemd service..."
|
||||
sudo cp yourpart.service /etc/systemd/system/
|
||||
sudo systemctl daemon-reload
|
||||
sudo -n cp "$TARGET_DIR/yourpart.service" /etc/systemd/system/
|
||||
sudo -n systemctl daemon-reload
|
||||
|
||||
# Datenbank-Synchronisation durchführen
|
||||
echo "Running database synchronization..."
|
||||
cd "$BACKEND_TARGET"
|
||||
|
||||
# STAGE für Schema-Updates verwenden
|
||||
echo "Running database sync with STAGE=$STAGE..."
|
||||
export STAGE=$STAGE && npm run sync-db
|
||||
|
||||
# Service neu starten
|
||||
echo "Restarting yourpart service..."
|
||||
sudo systemctl restart yourpart
|
||||
|
||||
# Kurz warten und Status prüfen
|
||||
sleep 2
|
||||
echo "Checking service status..."
|
||||
sudo systemctl status yourpart --no-pager
|
||||
cd "$BACKEND_DIR"
|
||||
export STAGE="$STAGE"
|
||||
npm run sync-db
|
||||
|
||||
echo "Backend update completed!"
|
||||
rm -rf "$TEMP_ENV_DIR"
|
||||
Reference in New Issue
Block a user