From b15ab16adc003cd7c30bce31be930b7d648eb3de Mon Sep 17 00:00:00 2001 From: David Boreham Date: Fri, 12 Jul 2024 09:44:43 -0600 Subject: [PATCH 1/2] Use ssh user from config --- scripts/02-init-network-dirs.sh | 4 ++-- scripts/03-merge-genesis-txns.sh | 15 ++++++--------- scripts/delete-deployments.sh | 2 +- scripts/delete-network-dirs.sh | 2 +- scripts/lib.sh | 1 + scripts/network.cfg | 1 + 6 files changed, 12 insertions(+), 13 deletions(-) diff --git a/scripts/02-init-network-dirs.sh b/scripts/02-init-network-dirs.sh index acce500..c0e5613 100755 --- a/scripts/02-init-network-dirs.sh +++ b/scripts/02-init-network-dirs.sh @@ -20,7 +20,7 @@ do node_name=${machine_name_prefix}-${i} node_host_name=${node_name}.${machine_domain} 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}" - 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 diff --git a/scripts/03-merge-genesis-txns.sh b/scripts/03-merge-genesis-txns.sh index b285993..18c3be8 100755 --- a/scripts/03-merge-genesis-txns.sh +++ b/scripts/03-merge-genesis-txns.sh @@ -14,9 +14,6 @@ else exit 1 fi -p2p_port="26656" -so_command=/home/laconic/bin/laconic-so - gentx_dir=${node_network_dir}/config/gentx local_gentx_dir=gentx-${machine_name_prefix} @@ -25,7 +22,7 @@ for (( i=1 ; i<=$node_count ; i++ )); do node_name=${machine_name_prefix}-${i} 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_ip=$(dig +short ${node_host_name}) peer=${node_id}@${node_ip}:${p2p_port} @@ -49,8 +46,8 @@ done echo "Copying gentx files to node 1" node_1_host_name=${machine_name_prefix}-1.${machine_domain} -ssh laconic@${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} rm -rf ${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} 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') 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" 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" # 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_host_name=${node_name}.${machine_domain} 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 echo "Use this for persistent_peers:" diff --git a/scripts/delete-deployments.sh b/scripts/delete-deployments.sh index 4203bb2..dc2ffe6 100755 --- a/scripts/delete-deployments.sh +++ b/scripts/delete-deployments.sh @@ -26,6 +26,6 @@ do node_name=${machine_name_prefix}-${i} node_host_name=${node_name}.${machine_domain} 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 diff --git a/scripts/delete-network-dirs.sh b/scripts/delete-network-dirs.sh index 88d6311..4caedb7 100755 --- a/scripts/delete-network-dirs.sh +++ b/scripts/delete-network-dirs.sh @@ -21,6 +21,6 @@ for (( i=1 ; i<=$node_count ; i++ )); do node_name=${machine_name_prefix}-${i}.${machine_domain} 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 diff --git a/scripts/lib.sh b/scripts/lib.sh index 1c5baa3..f29e677 100644 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -23,6 +23,7 @@ assert_defined "node_count" assert_defined "ssh_user" assert_defined "node_network_dir" assert_defined "chain_id" +assert_defined "p2p_port" # Hack until we fix PATH for remote sessions so_command=/home/laconic/bin/laconic-so diff --git a/scripts/network.cfg b/scripts/network.cfg index 6d5ab5d..2f498b2 100644 --- a/scripts/network.cfg +++ b/scripts/network.cfg @@ -3,3 +3,4 @@ node_count=4 ssh_user=laconic node_network_dir=testnet-dir chain_id=laconic_81337-6 +p2p_port="26656" -- 2.45.2 From 3d38092917ac6a78eb65e542b3d8cc0785765a75 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Fri, 12 Jul 2024 13:22:48 -0600 Subject: [PATCH 2/2] Remove extra line --- scripts/delete-deployments.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/scripts/delete-deployments.sh b/scripts/delete-deployments.sh index dc2ffe6..aaac074 100755 --- a/scripts/delete-deployments.sh +++ b/scripts/delete-deployments.sh @@ -14,8 +14,6 @@ else exit 1 fi -so_command=/home/laconic/bin/laconic-so - echo "Delete deployment dirs on all nodes" spec_file_name=${machine_name_prefix}-spec.yml -- 2.45.2