Use ssh user from config (#2)

Reviewed-on: #2
Co-authored-by: David Boreham <david@bozemanpass.com>
Co-committed-by: David Boreham <david@bozemanpass.com>
This commit is contained in:
David Boreham 2024-07-13 18:51:40 +00:00 committed by David Boreham
parent 9bf0e4bbde
commit 37fa49ef15
6 changed files with 12 additions and 15 deletions

View File

@ -20,7 +20,7 @@ do
node_name=${machine_name_prefix}-${i} node_name=${machine_name_prefix}-${i}
node_host_name=${node_name}.${machine_domain} node_host_name=${node_name}.${machine_domain}
echo "Running initialize-network ${node_network_dir} on ${node_host_name}" echo "Running initialize-network ${node_network_dir} on ${node_host_name}"
ssh laconic@${node_host_name} /home/laconic/bin/laconic-so --stack mainnet-laconic deploy setup --network-dir ${node_network_dir} --initialize-network --chain-id ${chain_id} --node-moniker ${node_name} ssh ${ssh_user}@${node_host_name} ${so_command} --stack mainnet-laconic deploy setup --network-dir ${node_network_dir} --initialize-network --chain-id ${chain_id} --node-moniker ${node_name}
echo "Running join-network ${node_network_dir} on ${node_host_name}" echo "Running join-network ${node_network_dir} on ${node_host_name}"
ssh laconic@${node_host_name} /home/laconic/bin/laconic-so --stack mainnet-laconic deploy setup --network-dir ${node_network_dir} --join-network --key-name ${node_name} ssh ${ssh_user}@${node_host_name} ${so_command} --stack mainnet-laconic deploy setup --network-dir ${node_network_dir} --join-network --key-name ${node_name}
done done

View File

@ -14,9 +14,6 @@ else
exit 1 exit 1
fi fi
p2p_port="26656"
so_command=/home/laconic/bin/laconic-so
gentx_dir=${node_network_dir}/config/gentx gentx_dir=${node_network_dir}/config/gentx
local_gentx_dir=gentx-${machine_name_prefix} local_gentx_dir=gentx-${machine_name_prefix}
@ -25,7 +22,7 @@ for (( i=1 ; i<=$node_count ; i++ ));
do do
node_name=${machine_name_prefix}-${i} node_name=${machine_name_prefix}-${i}
node_host_name=${node_name}.${machine_domain} node_host_name=${node_name}.${machine_domain}
gentx_file_name=$(ssh laconic@${node_host_name} ls /home/laconic/${gentx_dir} | head -1) gentx_file_name=$(ssh ${ssh_user}@${node_host_name} ls /home/laconic/${gentx_dir} | head -1)
node_id=$(echo ${gentx_file_name} | sed -e 's/^gentx-//' -e 's/.json$//') node_id=$(echo ${gentx_file_name} | sed -e 's/^gentx-//' -e 's/.json$//')
node_ip=$(dig +short ${node_host_name}) node_ip=$(dig +short ${node_host_name})
peer=${node_id}@${node_ip}:${p2p_port} peer=${node_id}@${node_ip}:${p2p_port}
@ -49,8 +46,8 @@ done
echo "Copying gentx files to node 1" echo "Copying gentx files to node 1"
node_1_host_name=${machine_name_prefix}-1.${machine_domain} node_1_host_name=${machine_name_prefix}-1.${machine_domain}
ssh laconic@${node_1_host_name} rm -rf ${local_gentx_dir} ssh ${ssh_user}@${node_1_host_name} rm -rf ${local_gentx_dir}
ssh laconic@${node_1_host_name} mkdir ${local_gentx_dir} ssh ${ssh_user}@${node_1_host_name} mkdir ${local_gentx_dir}
scp ${local_gentx_dir}/* laconic@${node_1_host_name}:~/${local_gentx_dir} scp ${local_gentx_dir}/* laconic@${node_1_host_name}:~/${local_gentx_dir}
gentx_file_list=$(ssh laconic@${node_1_host_name} ls -m ${local_gentx_dir}/*) gentx_file_list=$(ssh laconic@${node_1_host_name} ls -m ${local_gentx_dir}/*)
@ -59,11 +56,11 @@ echo "Node 1 now has: ${gentx_file_list}"
gentx_files=$(echo ${gentx_file_list} | tr -d ' ' | tr -d '\n') gentx_files=$(echo ${gentx_file_list} | tr -d ' ' | tr -d '\n')
echo "Generate genesis on node 1" echo "Generate genesis on node 1"
ssh laconic@${node_1_host_name} ${so_command} --stack mainnet-laconic deploy setup --network-dir ${node_network_dir} --create-network --gentx-files ${gentx_files} ssh ${ssh_user}@${node_1_host_name} ${so_command} --stack mainnet-laconic deploy setup --network-dir ${node_network_dir} --create-network --gentx-files ${gentx_files}
echo "Fetching genesis file from node 1" echo "Fetching genesis file from node 1"
local_genesis_file=${local_gentx_dir}/genesis.json local_genesis_file=${local_gentx_dir}/genesis.json
scp laconic@${node_1_host_name}:~/${node_network_dir}/config/genesis.json ${local_gentx_dir} scp ${ssh_user}@${node_1_host_name}:~/${node_network_dir}/config/genesis.json ${local_gentx_dir}
echo "Copying genesis file to other nodes" echo "Copying genesis file to other nodes"
# Note: start at node 2 here because we're going to copy to node 1 # Note: start at node 2 here because we're going to copy to node 1
@ -72,7 +69,7 @@ do
node_name=${machine_name_prefix}-${i} node_name=${machine_name_prefix}-${i}
node_host_name=${node_name}.${machine_domain} node_host_name=${node_name}.${machine_domain}
echo "Copying ${local_genesis_file} to ${node_name} to ${node_name}" echo "Copying ${local_genesis_file} to ${node_name} to ${node_name}"
scp ${local_genesis_file} laconic@${node_host_name}:~/${node_network_dir}/config scp ${local_genesis_file} ${ssh_user}@${node_host_name}:~/${node_network_dir}/config
done done
echo "Use this for persistent_peers:" echo "Use this for persistent_peers:"

View File

@ -14,8 +14,6 @@ else
exit 1 exit 1
fi fi
so_command=/home/laconic/bin/laconic-so
echo "Delete deployment dirs on all nodes" echo "Delete deployment dirs on all nodes"
spec_file_name=${machine_name_prefix}-spec.yml spec_file_name=${machine_name_prefix}-spec.yml
@ -26,6 +24,6 @@ do
node_name=${machine_name_prefix}-${i} node_name=${machine_name_prefix}-${i}
node_host_name=${node_name}.${machine_domain} node_host_name=${node_name}.${machine_domain}
echo "Deleting deployment dir on ${node_name}" echo "Deleting deployment dir on ${node_name}"
ssh laconic@${node_host_name} sudo rm -rf ${deployment_dir} ssh ${ssh_user}@${node_host_name} sudo rm -rf ${deployment_dir}
done done

View File

@ -21,6 +21,6 @@ for (( i=1 ; i<=$node_count ; i++ ));
do do
node_name=${machine_name_prefix}-${i}.${machine_domain} node_name=${machine_name_prefix}-${i}.${machine_domain}
echo "Deleting ${node_network_dir} on ${node_name}" echo "Deleting ${node_network_dir} on ${node_name}"
ssh laconic@${node_name} rm -rf ${node_network_dir} ${local_gentx_dir} ssh ${ssh_user}@${node_name} rm -rf ${node_network_dir} ${local_gentx_dir}
done done

View File

@ -23,6 +23,7 @@ assert_defined "node_count"
assert_defined "ssh_user" assert_defined "ssh_user"
assert_defined "node_network_dir" assert_defined "node_network_dir"
assert_defined "chain_id" assert_defined "chain_id"
assert_defined "p2p_port"
# Hack until we fix PATH for remote sessions # Hack until we fix PATH for remote sessions
so_command=/home/laconic/bin/laconic-so so_command=/home/laconic/bin/laconic-so

View File

@ -3,3 +3,4 @@ node_count=4
ssh_user=laconic ssh_user=laconic
node_network_dir=testnet-dir node_network_dir=testnet-dir
chain_id=laconic_81337-6 chain_id=laconic_81337-6
p2p_port="26656"