From 5784bee792b34ee7e2c5353fb3ab70f031883386 Mon Sep 17 00:00:00 2001 From: goldsquid Date: Sat, 13 Dec 2025 15:14:28 +0700 Subject: [PATCH] fix --- clone-peers.sh | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/clone-peers.sh b/clone-peers.sh index 57f41a14..9ae68550 100755 --- a/clone-peers.sh +++ b/clone-peers.sh @@ -90,15 +90,36 @@ if [ $? -ne 0 ]; then exit 1 fi +# Construct URLs +SOURCE_URL="https://${DOMAIN}${SOURCE_RPC_PATH}" +TARGET_URL="https://${TARGET_HOST}.stakesquid.eu${TARGET_RPC_PATH}" + +echo "==========================================" +echo "DEBUG: Configuration" +echo "==========================================" echo "Source RPC path: $SOURCE_RPC_PATH" echo "Target RPC path: $TARGET_RPC_PATH" -echo "Source host: $DOMAIN" +echo "Source domain: $DOMAIN" echo "Target host: $TARGET_HOST.stakesquid.eu" echo "" +echo "Source URL: $SOURCE_URL" +echo "Target URL: $TARGET_URL" +echo "" +echo "==========================================" +echo "DEBUG: Manual curl commands" +echo "==========================================" +echo "To fetch peers from source, run:" +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 -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..." -enodes=$(curl -X POST -H "Content-Type: application/json" --silent --data "{\"jsonrpc\":\"2.0\",\"method\":\"admin_peers\",\"params\":[],\"id\":1}" "https://${DOMAIN}${SOURCE_RPC_PATH}" | 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 @@ -120,7 +141,8 @@ while IFS= read -r enode; do fi echo "Adding peer: ${enode:0:50}..." - result=$(curl -X POST -H "Content-Type: application/json" --silent --data "{\"jsonrpc\":\"2.0\",\"method\":\"admin_addPeer\",\"params\":[\"${enode}\"],\"id\":1}" "https://${TARGET_HOST}.stakesquid.eu${TARGET_RPC_PATH}" | 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"