Address review comments
* Only public IP address in the list * formatting and other comments
This commit is contained in:
parent
27c1410fdc
commit
f8352bac2f
|
@ -1,60 +1,48 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Format for the nodes file
|
|
||||||
# node1 public-ip|node1 privte-ip
|
|
||||||
# node2 public-ip|node2 privte-ip
|
|
||||||
# ....
|
|
||||||
# e.g.
|
|
||||||
# 35.197.92.75|10.138.0.6
|
|
||||||
# 35.185.232.222|10.138.0.3
|
|
||||||
# 35.233.137.53|10.138.0.5
|
|
||||||
|
|
||||||
nodes_file=$1
|
nodes_file=$1
|
||||||
remote_user=$2
|
remote_user=$2
|
||||||
ssh_keys=$3
|
ssh_keys=$3
|
||||||
|
|
||||||
declare -A ip_addr_array
|
oldIFS="$IFS"
|
||||||
while IFS=\| read public private
|
IFS=$'\n' ip_addr_array=($(<$nodes_file))
|
||||||
do
|
IFS="$oldIFS"
|
||||||
ip_addr_array[$public]=$private
|
|
||||||
done < $nodes_file
|
ssh_command_prefix='export PATH="$HOME/.cargo/bin:$PATH"; cd solana; USE_INSTALL=1 ./multinode-demo/'
|
||||||
|
|
||||||
count=0
|
count=0
|
||||||
leader=
|
leader=
|
||||||
for public_ip in ${!ip_addr_array[*]}
|
for ip_addr in "${ip_addr_array[@]}"; do
|
||||||
do
|
echo "$ip_addr"
|
||||||
rsync -r -av ~/.cargo/bin $remote_user@$public_ip:~/.cargo
|
|
||||||
rsync -r -av ./multinode-demo $remote_user@$public_ip:~/solana/
|
|
||||||
|
|
||||||
if [ -z $ssh_keys ]
|
rsync -r -av ~/.cargo/bin "$remote_user"@"$ip_addr":~/.cargo
|
||||||
then
|
rsync -r -av ./multinode-demo "$remote_user"@"$ip_addr":~/solana/
|
||||||
echo "skip copying the ssk keys"
|
|
||||||
|
if [[ -z $ssh_keys ]]; then
|
||||||
|
echo "skip copying the ssh keys"
|
||||||
else
|
else
|
||||||
echo "rsync -r -av $ssh_keys/* $remote_user@$public_ip:~/.ssh/"
|
echo "rsync -r -av $ssh_keys/* $remote_user@$ip_addr:~/.ssh/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ssh $remote_user@$public_ip 'source .cargo/env; cd solana; USE_INSTALL=1 ./multinode-demo/setup.sh'
|
ssh "$remote_user"@"$ip_addr" $ssh_command_prefix'setup.sh'
|
||||||
|
|
||||||
if [ $count -eq 0 ]
|
if [[ "$count" -eq 0 ]]; then
|
||||||
then
|
|
||||||
# Start the leader on the first node
|
# Start the leader on the first node
|
||||||
echo "Starting leader node $public_ip"
|
echo "Starting leader node $ip_addr"
|
||||||
ssh -n -f $remote_user@$public_ip 'source .cargo/env; cd solana; USE_INSTALL=1 ./multinode-demo/leader.sh > leader.log 2>&1'
|
ssh -n -f "$remote_user"@"$ip_addr" $ssh_command_prefix'leader.sh > leader.log 2>&1'
|
||||||
leader=${ip_addr_array[$public_ip]}
|
leader=${ip_addr_array[0]}
|
||||||
else
|
else
|
||||||
# Start validator on all other nodes
|
# Start validator on all other nodes
|
||||||
echo "Starting validator node $public_ip"
|
echo "Starting validator node $ip_addr"
|
||||||
ssh -n -f $remote_user@$public_ip "source .cargo/env; cd solana; USE_INSTALL=1 ./multinode-demo/validator.sh $remote_user@$leader:~/solana $leader > validator.log 2>&1"
|
ssh -n -f "$remote_user"@"$ip_addr" $ssh_command_prefix"validator.sh $remote_user@$leader:~/solana $leader > validator.log 2>&1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
(( count++ ))
|
(( count++ ))
|
||||||
|
|
||||||
if [ $count -eq ${#ip_addr_array[@]} ]
|
if [[ "$count" -eq ${#ip_addr_array[@]} ]]; then
|
||||||
then
|
|
||||||
# Launch client demo on the last node
|
# Launch client demo on the last node
|
||||||
echo "Starting client demo on $public_ip"
|
echo "Starting client demo on $ip_addr"
|
||||||
ssh -n -f $remote_user@$public_ip "source .cargo/env; cd solana; USE_INSTALL=1 ./multinode-demo/client.sh $remote_user@$leader:~/solana $count > client.log 2>&1"
|
ssh -n -f "$remote_user"@"$ip_addr" $ssh_command_prefix"client.sh $remote_user@$leader:~/solana $count > client.log 2>&1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue