44 lines
1.1 KiB
Bash
Executable File
44 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# --- Caricamento variabili d'ambiente ---
|
|
if [ -f .env ]; then
|
|
export $(grep -v '^#' .env | xargs)
|
|
else
|
|
echo "❌ Errore: File .env non trovato."
|
|
exit 1
|
|
fi
|
|
|
|
# --- Configurazione FTP ---
|
|
FTP_HOST="ftp.canticristiani.it"
|
|
FTP_USER="canticristiani.it"
|
|
FTP_PASS="$FTP_PASSWORD"
|
|
SOURCE_URL="http://185.193.67.105:3000/cantiletture.json"
|
|
REMOTE_PATH="api/cantiletture.json"
|
|
|
|
if [ -z "$FTP_PASS" ]; then
|
|
echo "❌ Errore: FTP_PASSWORD non definita nel file .env"
|
|
exit 1
|
|
fi
|
|
|
|
# --- Download del file ---
|
|
echo "⬇️ Scaricamento dati da $SOURCE_URL..."
|
|
TEMP_FILE=$(mktemp)
|
|
if ! curl -s -L "$SOURCE_URL" -o "$TEMP_FILE"; then
|
|
echo "❌ Errore nel download dei dati."
|
|
rm "$TEMP_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
# --- Upload via FTP ---
|
|
echo "🚀 Caricamento nuovo file su $FTP_HOST/$REMOTE_PATH..."
|
|
if curl -s -u "$FTP_USER:$FTP_PASS" --ftp-pasv --ftp-create-dirs -T "$TEMP_FILE" "ftp://$FTP_HOST/$REMOTE_PATH"; then
|
|
echo "✅ Allineamento completato con successo!"
|
|
else
|
|
echo "❌ Errore durante il caricamento FTP."
|
|
rm "$TEMP_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
# Cleanup
|
|
rm "$TEMP_FILE"
|