diff --git a/scripts/02-init-network-dirs.sh b/scripts/02-init-network-dirs.sh index c0e5613..c1ed02a 100755 --- a/scripts/02-init-network-dirs.sh +++ b/scripts/02-init-network-dirs.sh @@ -21,6 +21,9 @@ do node_host_name=${node_name}.${machine_domain} echo "Running initialize-network ${node_network_dir} on ${node_host_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} + # Change file ownership in the network dir to work around root-only container issue + change_dir_ownership ${node_host_name} ${node_network_dir} echo "Running join-network ${node_network_dir} on ${node_host_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} + change_dir_ownership ${node_host_name} ${node_network_dir} done diff --git a/scripts/03-merge-genesis-txns.sh b/scripts/03-merge-genesis-txns.sh index 18c3be8..5959c1e 100755 --- a/scripts/03-merge-genesis-txns.sh +++ b/scripts/03-merge-genesis-txns.sh @@ -15,6 +15,7 @@ else fi gentx_dir=${node_network_dir}/config/gentx +genesis_json_file=${node_network_dir}/config/genesis.json local_gentx_dir=gentx-${machine_name_prefix} echo "Fetch node ids and node ips for persistent-peers" @@ -42,27 +43,42 @@ do node_host_name=${node_name}.${machine_domain} echo "Copying ${gentx_dir} on ${node_name} to ${local_gentx_dir}" scp laconic@${node_host_name}:~/${gentx_dir}/* ${local_gentx_dir} + scp laconic@${node_host_name}:~/${genesis_json_file} ${local_gentx_dir}/${node_name}-genesis.json +done + +# Extract the peer node validator addresses from their genesis.json files +gentx_addresses="" +for (( i=2 ; i<=$node_count ; i++ )); +do + node_name=${machine_name_prefix}-${i} + node_genesis_file=${local_gentx_dir}/${node_name}-genesis.json + node_gentx_address=$(grep address ${node_genesis_file} | head -1 | cut -d '"' -f 4) + gentx_addresses+=${delimeter}${node_gentx_address} + delimeter="," done echo "Copying gentx files to node 1" node_1_host_name=${machine_name_prefix}-1.${machine_domain} 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} +scp ${local_gentx_dir}/gentx-* 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}/gentx-*) 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 ${ssh_user}@${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} --gentx-addresses ${gentx_addresses} +# Change file ownership in the network dir to work around root-only container issue +change_dir_ownership ${node_1_host_name} ${node_network_dir} echo "Fetching genesis file from node 1" local_genesis_file=${local_gentx_dir}/genesis.json scp ${ssh_user}@${node_1_host_name}:~/${node_network_dir}/config/genesis.json ${local_gentx_dir} echo "Copying genesis file to other nodes" +# Note: we should be using --create-network --genesis-file ${genesis_file} for this rather than copying directly into the network dir # Note: start at node 2 here because we're going to copy to node 1 for (( i=2 ; i<=$node_count ; i++ )); do diff --git a/scripts/delete-network-dirs.sh b/scripts/delete-network-dirs.sh index 4caedb7..426995e 100755 --- a/scripts/delete-network-dirs.sh +++ b/scripts/delete-network-dirs.sh @@ -20,7 +20,9 @@ echo "Deleting network dirs on all nodes" for (( i=1 ; i<=$node_count ; i++ )); do node_name=${machine_name_prefix}-${i}.${machine_domain} + change_dir_ownership ${node_name} ${node_network_dir} echo "Deleting ${node_network_dir} on ${node_name}" ssh ${ssh_user}@${node_name} rm -rf ${node_network_dir} ${local_gentx_dir} done +rm -rf ${local_gentx_dir} diff --git a/scripts/lib.sh b/scripts/lib.sh index f29e677..277389b 100644 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -40,3 +40,11 @@ function run_on_all_nodes() { ssh ${ssh_user}@${machine_name} ${command_to_run} done } + +function change_dir_ownership() { + local machine_name=$1 + local directory_path=$2 + local command_to_run="sudo chown \$USER: -R ${directory_path}" + echo "Running: ${command_to_run} on ${machine_name}" + ssh ${ssh_user}@${machine_name} ${command_to_run} +}