laconic-network-bootstrap/scripts/04-create-deployments.sh

44 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
set -x
fi
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source ${SCRIPT_DIR}/lib.sh
usage="Usage: $0 <machine-name-prefix> <peers>"
if [[ -n "$1" ]]; then
machine_name_prefix=$1
else
echo ${usage}
exit 1
fi
if [[ -n "$2" ]]; then
peers=$2
else
echo ${usage}
exit 1
fi
so_command=/home/laconic/bin/laconic-so
echo "Run deploy init on all nodes"
spec_file_name=${machine_name_prefix}-spec.yml
deployment_dir=${machine_name_prefix}-deployment
echo "Creating deployments on all nodes"
for (( i=1 ; i<=$node_count ; i++ ));
do
node_name=${machine_name_prefix}-${i}
node_host_name=${node_name}.${machine_domain}
laconic_console_config="LACONIC_HOSTED_ENDPOINT=http://${node_host_name}:9473"
echo "Creating deployment dir on ${node_name}"
ssh laconic@${node_host_name} ${so_command} --stack mainnet-laconic deploy init --map-ports-to-host any-same --output ${spec_file_name} --config ${laconic_console_config}
ssh laconic@${node_host_name} ${so_command} --stack mainnet-laconic deploy create --deployment-dir ${deployment_dir} --spec-file ${spec_file_name} --network-dir ${node_network_dir} --initial-peers ${peers}
done