2024-07-08 12:22:16 +00:00
|
|
|
|
|
|
|
function error_exit() {
|
|
|
|
echo "Error: $1"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
function assert_defined() {
|
|
|
|
local variable_name=$1
|
|
|
|
if [[ ! ${!variable_name} ]]; then
|
|
|
|
error_exit "$variable_name is not defined"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
network_config_file=./network.cfg
|
|
|
|
|
|
|
|
if [[ ! -f ${network_config_file} ]]; then
|
|
|
|
error_exit "$network_config_file does not exist"
|
|
|
|
fi
|
|
|
|
source ${network_config_file}
|
|
|
|
|
|
|
|
assert_defined "machine_domain"
|
|
|
|
assert_defined "node_count"
|
|
|
|
assert_defined "ssh_user"
|
2024-07-12 15:38:36 +00:00
|
|
|
assert_defined "node_network_dir"
|
|
|
|
assert_defined "chain_id"
|
2024-07-13 18:51:40 +00:00
|
|
|
assert_defined "p2p_port"
|
2024-07-08 12:22:16 +00:00
|
|
|
|
|
|
|
# Hack until we fix PATH for remote sessions
|
|
|
|
so_command=/home/laconic/bin/laconic-so
|
|
|
|
|
|
|
|
# run_on_all_nodes(machine_name_prefix, command_to_run)
|
|
|
|
function run_on_all_nodes() {
|
|
|
|
local machine_name_prefix=$1
|
|
|
|
local command_to_run=$2
|
|
|
|
for (( i=1 ; i<=$node_count ; i++ ));
|
|
|
|
do
|
|
|
|
local machine_name=${machine_name_prefix}-${i}.${machine_domain}
|
|
|
|
echo "${machine_name}:"
|
|
|
|
echo "Running: ${command_to_run}"
|
|
|
|
ssh ${ssh_user}@${machine_name} ${command_to_run}
|
|
|
|
done
|
|
|
|
}
|
2024-07-31 17:34:16 +00:00
|
|
|
|
|
|
|
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}
|
|
|
|
}
|