run-outer-client.sh
1 #!/bin/bash 2 3 # USAGE examples: 4 # CLI with env vars: PEERS=core_client_ip_1:4130,core_client_ip_2:4130,core_client_ip_3:4130,outer_client_ip_1:4130,... ./run-outer-client.sh 5 # CLI with prompts for vars: ./run-outer-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., 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 [ -z "${PEERS}" ]; then 15 COMMAND="cargo run --release -- start --nodisplay --client --node 0.0.0.0:4130 --verbosity 1 --rest 0.0.0.0:3030" 16 else 17 COMMAND="cargo run --release -- start --nodisplay --client --node 0.0.0.0:4130 --peers ${PEERS} --verbosity 1 --rest 0.0.0.0:3030" 18 fi 19 20 for word in $*; 21 do 22 COMMAND="${COMMAND} ${word}" 23 done 24 25 function exit_node() 26 { 27 echo "Exiting..." 28 kill $! 29 exit 30 } 31 32 trap exit_node SIGINT 33 34 echo "Checking for updates..." 35 git stash 36 rm Cargo.lock 37 STATUS=$(git pull) 38 39 if [ "$STATUS" != "Already up to date." ]; then 40 echo "Updated code found, cleaning the project" 41 cargo clean 42 fi 43 44 echo "Running an Aleo Outer Client node..." 45 $COMMAND & 46 wait