diff --git a/scripts/manageSnapshots.sh b/scripts/manageSnapshots.sh index ca5e12b..ee1e171 100755 --- a/scripts/manageSnapshots.sh +++ b/scripts/manageSnapshots.sh @@ -3,7 +3,14 @@ set -xe #Variables -filename="networks" +if [ -f .env ]; then + source .env +else + echo "Error: .env file not found. Please create a .env file with the required environment variables." >&2 + exit 1 +fi + +rpc_urls="${SNAPSHOT_RPC_URLS}" ipfs_api="${IPFS_API}" generate_snapshot() { @@ -14,13 +21,17 @@ generate_snapshot() { mkdir snapshots fi - while IFS=, read -r _ rpc; do - echo "${rpc} - ${rpc:-no rpc found}" - [ -n "$rpc" ] && node ./scripts/buildSnapshot.js "$rpc" - done < "$filename" + # Get list of RPC URLs from environment variable + IFS=',' read -r -a rpc_array <<< "$rpc_urls" + for rpc in "${rpc_array[@]}"; do + echo "${rpc}" + [ -n "$rpc" ] && node ./scripts/buildSnapshot.js "https://$rpc" + done + echo "Generating done" } + upload_snapshot() { echo "Uploading snapshots..." ipfs_logfile="logs/ipfs_$(date '+%Y-%m-%d').txt"