diff --git a/deploy_blockchain_genesis_onprem.sh b/deploy_blockchain_genesis_onprem.sh index 856e3dfc4..10ba48735 100644 --- a/deploy_blockchain_genesis_onprem.sh +++ b/deploy_blockchain_genesis_onprem.sh @@ -29,8 +29,16 @@ if [[ ! $2 =~ $number_re ]] ; then printf "Invalid <# of Shards> argument: $2\n" exit fi +if [[ $3 -lt 0 ]] || [[ $3 -gt 4 ]]; then + printf "Invalid argument: $3\n" + exit +fi PARENT_NODE_INDEX_BEGIN=$3 printf "PARENT_NODE_INDEX_BEGIN=$PARENT_NODE_INDEX_BEGIN\n" +if [[ $4 -lt 0 ]] || [[ $4 -gt 4 ]]; then + printf "Invalid argument: $4\n" + exit +fi PARENT_NODE_INDEX_END=$4 printf "PARENT_NODE_INDEX_END=$PARENT_NODE_INDEX_END\n" printf "\n" diff --git a/deploy_blockchain_incremental_gcp.sh b/deploy_blockchain_incremental_gcp.sh index 9eeb88ddf..4fa960546 100644 --- a/deploy_blockchain_incremental_gcp.sh +++ b/deploy_blockchain_incremental_gcp.sh @@ -352,7 +352,7 @@ function deploy_node() { # 5. Wait until node is synced printf "\n\n<<< Waiting until node $node_index is synced >>>\n\n" - WAIT_CMD="gcloud compute ssh $node_target_addr --command 'cd \$(find /home/ain-blockchain* -maxdepth 0 -type d); . wait_until_node_sync.sh' --project $PROJECT_ID --zone $node_zone" + WAIT_CMD="gcloud compute ssh $node_target_addr --command 'cd \$(find /home/ain-blockchain* -maxdepth 0 -type d); . wait_until_node_sync.sh $node_url' --project $PROJECT_ID --zone $node_zone" printf "WAIT_CMD=$WAIT_CMD\n\n" eval $WAIT_CMD } diff --git a/deploy_blockchain_incremental_onprem.sh b/deploy_blockchain_incremental_onprem.sh index 9b6d7234f..fa335cb40 100644 --- a/deploy_blockchain_incremental_onprem.sh +++ b/deploy_blockchain_incremental_onprem.sh @@ -29,8 +29,16 @@ if [[ ! $2 =~ $number_re ]] ; then printf "Invalid <# of Shards> argument: $2\n" exit fi +if [[ $3 -lt 0 ]] || [[ $3 -gt 4 ]]; then + printf "Invalid argument: $3\n" + exit +fi PARENT_NODE_INDEX_BEGIN=$3 printf "PARENT_NODE_INDEX_BEGIN=$PARENT_NODE_INDEX_BEGIN\n" +if [[ $4 -lt 0 ]] || [[ $4 -gt 4 ]]; then + printf "Invalid argument: $4\n" + exit +fi PARENT_NODE_INDEX_END=$4 printf "PARENT_NODE_INDEX_END=$PARENT_NODE_INDEX_END\n" printf "\n" @@ -339,7 +347,7 @@ function deploy_node() { # 5. Wait until node is synced printf "\n\n<<< Waiting until node $node_index ($node_target_addr) is synced >>>\n\n" - WAIT_CMD="ssh $node_target_addr 'cd \$(find /home/${SEASON}/ain-blockchain* -maxdepth 0 -type d); . wait_until_node_sync.sh'" + WAIT_CMD="ssh $node_target_addr 'cd \$(find /home/${SEASON}/ain-blockchain* -maxdepth 0 -type d); . wait_until_node_sync.sh $node_url'" printf "\n\nWAIT_CMD=$WAIT_CMD\n\n" eval "echo ${node_login_pw} | sshpass -f <(printf '%s\n' ${node_login_pw}) ${WAIT_CMD}" } diff --git a/wait_until_node_sync.sh b/wait_until_node_sync.sh index c66c90fe1..582ccd4f8 100644 --- a/wait_until_node_sync.sh +++ b/wait_until_node_sync.sh @@ -1,7 +1,18 @@ #!/bin/bash +if [[ $# -lt 1 ]] || [[ $# -gt 1 ]]; then + printf "Usage: bash wait_until_node_sync.sh \n" + printf "Example: bash wait_until_node_sync.sh http://123.456.789.1:8079\n" + printf "\n" + return 1 +fi + printf "\n[[[[[ wait_until_node_sync.sh ]]]]]\n\n" +# Parse options. +NODE_URL="$1" +printf "NODE_URL=$NODE_URL\n" + printf "\n#### Wait until the new node server catches up ####\n\n" SECONDS=0 @@ -16,11 +27,11 @@ EOF while : do - healthCheck=$(curl -m 20 -X GET -H "Content-Type: application/json" "http://localhost:8080/health_check") + healthCheck=$(curl -m 20 -X GET -H "Content-Type: application/json" "${NODE_URL}/health_check") printf "\nhealthCheck = ${healthCheck}\n" if [[ "$healthCheck" = "true" ]]; then printf "\nBlockchain Node server is synced & running!\n" - lastBlockNumber=$(curl -m 20 -X GET -H "Content-Type: application/json" "http://localhost:8080/last_block_number" | jq -r '.result') + lastBlockNumber=$(curl -m 20 -X GET -H "Content-Type: application/json" "${NODE_URL}/last_block_number" | jq -r '.result') printf "\nlastBlockNumber = ${lastBlockNumber}\n" printf "\nTime it took to sync in seconds: $SECONDS\n" break