diff --git a/clone-backup.sh b/clone-backup.sh index 1bb3cb53..a4eb568e 100755 --- a/clone-backup.sh +++ b/clone-backup.sh @@ -31,7 +31,7 @@ if [ ! -d "$LOCAL_DIR" ]; then for file in "${files[@]}"; do echo "Processing: $file" - curl -# "${base_url}${file}" | zstd -d | tar -xvf - -C / + curl --ipv4 -# "${base_url}${file}" | zstd -d | tar -xvf - -C / if [ $? -ne 0 ]; then echo "Error processing $file" diff --git a/clone-peers.sh b/clone-peers.sh index b2ff8767..9ae68550 100755 --- a/clone-peers.sh +++ b/clone-peers.sh @@ -109,17 +109,17 @@ echo "==========================================" echo "DEBUG: Manual curl commands" echo "==========================================" echo "To fetch peers from source, run:" -echo "curl --ipv4 -X POST -H \"Content-Type: application/json\" --data '{\"jsonrpc\":\"2.0\",\"method\":\"admin_peers\",\"params\":[],\"id\":1}' \"$SOURCE_URL\"" +echo "curl -X POST -H \"Content-Type: application/json\" --data '{\"jsonrpc\":\"2.0\",\"method\":\"admin_peers\",\"params\":[],\"id\":1}' \"$SOURCE_URL\"" echo "" echo "To add a peer to target, run:" -echo "curl --ipv4 -X POST -H \"Content-Type: application/json\" --data '{\"jsonrpc\":\"2.0\",\"method\":\"admin_addPeer\",\"params\":[\"\"],\"id\":1}' \"$TARGET_URL\"" +echo "curl -X POST -H \"Content-Type: application/json\" --data '{\"jsonrpc\":\"2.0\",\"method\":\"admin_addPeer\",\"params\":[\"\"],\"id\":1}' \"$TARGET_URL\"" echo "==========================================" echo "" # Run the command to get the list of enode strings from source echo "Fetching peers from source node..." -echo "DEBUG: Executing: curl --ipv4 -X POST -H \"Content-Type: application/json\" --data '{\"jsonrpc\":\"2.0\",\"method\":\"admin_peers\",\"params\":[],\"id\":1}' \"$SOURCE_URL\"" -enodes=$(curl --ipv4 -X POST -H "Content-Type: application/json" --silent --data "{\"jsonrpc\":\"2.0\",\"method\":\"admin_peers\",\"params\":[],\"id\":1}" "$SOURCE_URL" | jq -r '.result[].enode' 2>/dev/null) +echo "DEBUG: Executing: curl -X POST -H \"Content-Type: application/json\" --data '{\"jsonrpc\":\"2.0\",\"method\":\"admin_peers\",\"params\":[],\"id\":1}' \"$SOURCE_URL\"" +enodes=$(curl -X POST -H "Content-Type: application/json" --silent --data "{\"jsonrpc\":\"2.0\",\"method\":\"admin_peers\",\"params\":[],\"id\":1}" "$SOURCE_URL" | jq -r '.result[].enode' 2>/dev/null) # Check if the command was successful if [ $? -ne 0 ] || [ -z "$enodes" ]; then @@ -141,8 +141,8 @@ while IFS= read -r enode; do fi echo "Adding peer: ${enode:0:50}..." - echo "DEBUG: Executing: curl --ipv4 -X POST -H \"Content-Type: application/json\" --data '{\"jsonrpc\":\"2.0\",\"method\":\"admin_addPeer\",\"params\":[\"${enode}\"],\"id\":1}' \"$TARGET_URL\"" - result=$(curl --ipv4 -X POST -H "Content-Type: application/json" --silent --data "{\"jsonrpc\":\"2.0\",\"method\":\"admin_addPeer\",\"params\":[\"${enode}\"],\"id\":1}" "$TARGET_URL" | jq -r '.result' 2>/dev/null) + echo "DEBUG: Executing: curl -X POST -H \"Content-Type: application/json\" --data '{\"jsonrpc\":\"2.0\",\"method\":\"admin_addPeer\",\"params\":[\"${enode}\"],\"id\":1}' \"$TARGET_URL\"" + result=$(curl -X POST -H "Content-Type: application/json" --silent --data "{\"jsonrpc\":\"2.0\",\"method\":\"admin_addPeer\",\"params\":[\"${enode}\"],\"id\":1}" "$TARGET_URL" | jq -r '.result' 2>/dev/null) if [ "$result" = "true" ] || [ "$result" = "null" ]; then echo " ✓ Success" diff --git a/get-block.sh b/get-block.sh index e05d6d9d..e22a8946 100755 --- a/get-block.sh +++ b/get-block.sh @@ -15,4 +15,4 @@ request="{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByNumber\",\"params\":[\" echo "${request}" -curl -s -X POST "${1}" -H "Content-Type: application/json" --data "${request}" | jq -r '.result.number, .result.hash' | gawk '{if (NR==1) print "Block Number:", strtonum($0); else print "Block Hash:", $0}' +curl --ipv4 -s -X POST "${1}" -H "Content-Type: application/json" --data "${request}" | jq -r '.result.number, .result.hash' | gawk '{if (NR==1) print "Block Number:", strtonum($0); else print "Block Hash:", $0}' diff --git a/latest.sh b/latest.sh index 98c4e42b..72a0926c 100755 --- a/latest.sh +++ b/latest.sh @@ -31,13 +31,13 @@ for path in $pathlist; do if $include; then RPC_URL="${PROTO:-https}://$DOMAIN/$path" - if curl -L -s -X POST $RPC_URL -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByNumber\",\"params\":[\"${blocktag}\",false],\"id\":1}" | jq -r '.result.number, .result.hash' | gawk '{if (NR==1) print "Block Number:", strtonum($0); else print "Block Hash:", $0}'; then + if curl --ipv4 -L -s -X POST $RPC_URL -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByNumber\",\"params\":[\"${blocktag}\",false],\"id\":1}" | jq -r '.result.number, .result.hash' | gawk '{if (NR==1) print "Block Number:", strtonum($0); else print "Block Hash:", $0}'; then exit 0 else - if curl -L -s -X POST $RPC_URL -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByNumber\",\"params\":[\"${blocktag}\",false],\"id\":1}" | jq; then + if curl --ipv4 -L -s -X POST $RPC_URL -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByNumber\",\"params\":[\"${blocktag}\",false],\"id\":1}" | jq; then exit 1 else - curl -L -vv -X POST $RPC_URL -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByNumber\",\"params\":[\"${blocktag}\",false],\"id\":1}" + curl --ipv4 -L -vv -X POST $RPC_URL -H "Content-Type: application/json" --data "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getBlockByNumber\",\"params\":[\"${blocktag}\",false],\"id\":1}" fi fi fi diff --git a/list-backups.sh b/list-backups.sh index 82ac0ef2..6bc41bba 100755 --- a/list-backups.sh +++ b/list-backups.sh @@ -1,3 +1,3 @@ #!/bin/bash -curl -s $1 | grep -oP 'rpc_[^"]*\.tar\.zst' | sort -u +curl --ipv4 -s $1 | grep -oP 'rpc_[^"]*\.tar\.zst' | sort -u diff --git a/restore-volumes.sh b/restore-volumes.sh index ad62f4ce..f47bb669 100755 --- a/restore-volumes.sh +++ b/restore-volumes.sh @@ -59,7 +59,7 @@ for file in "${restore_files[@]}"; do echo "Error: /backup directory does not exist. download from http and extract directly to /var/lib/docker" - curl -# "${2}${file}" | zstd -d | tar -xvf - --dereference -C / + curl --ipv4 -# "${2}${file}" | zstd -d | tar -xvf - --dereference -C / if [ $? -ne 0 ]; then echo "Error processing $file" diff --git a/update-ip.sh b/update-ip.sh index af654812..a530fa9a 100755 --- a/update-ip.sh +++ b/update-ip.sh @@ -1,5 +1,5 @@ #!/bin/bash cd /root/rpc -sed -i.bak "s/IP=.*/IP=$(curl ipinfo.io/ip)/g" .env +sed -i.bak "s/IP=.*/IP=$(curl --ipv4 ipinfo.io/ip)/g" .env docker compose up -d