refactor(update-backend): streamline .env file handling process
Some checks failed
Deploy to production / deploy (push) Failing after 1m58s

- Replaced the previous method of copying .env files with a direct installation from a specified source path.
- Improved permissions and ownership settings for the .env file to enhance security.
- Added user feedback for successful file transfer and verification steps.
This commit is contained in:
Torsten Schulz (local)
2026-03-30 16:19:00 +02:00
parent 4ebff4dc17
commit ca33a29317
5 changed files with 18 additions and 23 deletions

View File

@@ -1933,6 +1933,8 @@ export default class VocabService {
if (correctIndices.length === 0) return false;
const options = Array.isArray(parsedQuestionData?.options) ? parsedQuestionData.options : [];
const correctTexts = correctIndices
.map((i) => options[i])
.filter((opt) => opt !== undefined && opt !== null);

View File

@@ -30,6 +30,7 @@
"loading": "Lädt...",
"back": "Zurück",
"cancel": "Abbrechen",
"ok": "OK",
"yes": "Ja",
"no": "Nein"
},

View File

@@ -30,6 +30,7 @@
"loading": "Loading...",
"back": "Back",
"cancel": "Cancel",
"ok": "OK",
"yes": "Yes",
"no": "No"
},

View File

@@ -30,6 +30,7 @@
"loading": "Cargando...",
"back": "Atrás",
"cancel": "Cancelar",
"ok": "Aceptar",
"yes": "Sí",
"no": "No"
},

View File

@@ -25,27 +25,21 @@ echo "Installing dependencies..."
npm ci --production
echo "Übernehme .env-Dateien vom Live-System..."
if sudo -n test -f "$CURRENT_BACKEND/.env"; then
sudo -n cp "$CURRENT_BACKEND/.env" "$BACKEND_DIR/.env"
sudo -n chown tsschulz:tsschulz "$BACKEND_DIR/.env"
echo "✓ .env-Datei übernommen"
else
echo "⚠ Keine lesbare .env-Datei in $CURRENT_BACKEND gefunden"
fi
TEMP_ENV_DIR="/tmp/yourpart-env-backup-$$"
mkdir -p "$TEMP_ENV_DIR"
SOURCE_ENV="/opt/yourpart/backend/.env"
TARGET_ENV="$BACKEND_DIR/.env"
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 $CURRENT_BACKEND gefunden"
fi
fi
echo "Quelle: $SOURCE_ENV"
echo "Ziel: $TARGET_ENV"
sudo -n ls -l "$SOURCE_ENV"
sudo -n install -m 600 -o yourpart -g yourpart "$SOURCE_ENV" "$TARGET_ENV"
echo "Prüfe kopierte Datei..."
ls -l "$TARGET_ENV"
sudo -n head -n 1 "$TARGET_ENV" >/dev/null
echo "✓ .env-Datei wurde übernommen"
sudo -n mkdir -p "$DATA_DIR/adult-verification"
@@ -61,10 +55,6 @@ 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
echo "Updating systemd service..."
sudo -n cp "$TARGET_DIR/yourpart.service" /etc/systemd/system/
sudo -n systemctl daemon-reload