refactor(update-backend): streamline .env file handling process
Some checks failed
Deploy to production / deploy (push) Failing after 1m58s
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user