This commit is contained in:
goldsquid
2025-12-13 15:14:28 +07:00
parent 870b658616
commit 5784bee792

View File

@@ -90,15 +90,36 @@ if [ $? -ne 0 ]; then
exit 1 exit 1
fi 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 "Source RPC path: $SOURCE_RPC_PATH"
echo "Target RPC path: $TARGET_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 "Target host: $TARGET_HOST.stakesquid.eu"
echo "" 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\":[\"<enode>\"],\"id\":1}' \"$TARGET_URL\""
echo "=========================================="
echo ""
# Run the command to get the list of enode strings from source # Run the command to get the list of enode strings from source
echo "Fetching peers from source node..." 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 # Check if the command was successful
if [ $? -ne 0 ] || [ -z "$enodes" ]; then if [ $? -ne 0 ] || [ -z "$enodes" ]; then
@@ -120,7 +141,8 @@ while IFS= read -r enode; do
fi fi
echo "Adding peer: ${enode:0:50}..." 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 if [ "$result" = "true" ] || [ "$result" = "null" ]; then
echo " ✓ Success" echo " ✓ Success"