Files
crm.clientright.ru/crm_extensions/file_storage/n8n_migration_clean.sh

35 lines
1.1 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
ROOT="/var/www/fastuser/data/www/crm.clientright.ru"
SCRIPT="$ROOT/crm_extensions/file_storage/n8n_s3_migration_clean.php"
LOG_DIR="$ROOT/logs"
RUN_LOG="$LOG_DIR/n8n_migration_clean.log"
# Создаем директорию логов если не существует
mkdir -p "$LOG_DIR"
# Параметры по умолчанию
LIMIT="${LIMIT:-20}"
DRY_RUN="${DRY_RUN:-0}"
# Логирование запуска
echo "[n8n] Starting S3 migration (clean): $(date '+%Y-%m-%d %H:%M:%S')" >> "$RUN_LOG"
echo "[n8n] Parameters: LIMIT=$LIMIT DRY_RUN=$DRY_RUN" >> "$RUN_LOG"
# Запуск PHP скрипта
CMD="php $SCRIPT $LIMIT $DRY_RUN"
echo "[n8n] Executing: $CMD" >> "$RUN_LOG"
# Выполнение с перехватом вывода
OUTPUT=$($CMD 2>&1)
EXIT_CODE=$?
# Логирование вывода и завершения
echo "[n8n] PHP Output:" >> "$RUN_LOG"
echo "$OUTPUT" >> "$RUN_LOG"
echo "[n8n] Done at $(date '+%Y-%m-%d %H:%M:%S') with exit code $EXIT_CODE" >> "$RUN_LOG"
# Выводим ТОЛЬКО чистый JSON в stdout
echo "$OUTPUT"
exit $EXIT_CODE