/ scripts / run-core-client.sh
run-core-client.sh
 1  #!/bin/bash
 2  
 3  # USAGE examples: 
 4    # CLI with env vars: PEERS=“validator_ip:4130,core_client_ip_1:4130,core_client_ip_2:4130,core_client_ip_3:4130,outer_client_ip_1:4130,... ./run-core-client.sh
 5    # CLI with prompts for vars:  ./run-core-client.sh
 6  
 7  # If the env var PEERS is not set, prompt for it
 8  if [ -z "${PEERS}" ]
 9  then
10    read -r -p "Enter the peers (comma-separated) (e.g., “validator_ip:4130,core_client_ip_1:4130,core_client_ip_2:4130,core_client_ip_3:4130,outer_client_ip_1:4130,...): "
11    PEERS=$REPLY
12  fi
13  
14  if [ "${PEERS}" == "" ]
15  then
16    echo "Missing peers."
17    exit 1
18  fi
19  
20  COMMAND='cargo run --release -- start --nodisplay --client --node 0.0.0.0:4130 --peers ${PEERS} --verbosity 1 --norest'
21  
22  for word in $*;
23  do
24    COMMAND="${COMMAND} ${word}"
25  done
26  
27  function exit_node()
28  {
29      echo "Exiting..."
30      kill $!
31      exit
32  }
33  
34  trap exit_node SIGINT
35  
36  echo "Checking for updates..."
37  git stash
38  rm Cargo.lock
39  STATUS=$(git pull)
40  
41  if [ "$STATUS" != "Already up to date." ]; then
42    echo "Updated code found, cleaning the project"
43    cargo clean
44  fi
45  
46  echo "Running an Aleo Core Client node..."
47  $COMMAND &
48  wait