solana-with-rpc-optimizations/multinode-demo/setup.sh

110 lines
2.4 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2018-08-27 09:13:53 -07:00
#
# Creates a fullnode configuration
#
2018-06-24 10:10:55 -07:00
2018-06-23 11:52:12 -07:00
here=$(dirname "$0")
2018-06-24 10:10:55 -07:00
# shellcheck source=multinode-demo/common.sh
source "$here"/common.sh
2018-06-23 11:52:12 -07:00
2018-06-28 16:08:59 -07:00
usage () {
exitcode=0
if [[ -n "$1" ]]; then
exitcode=1
echo "Error: $*"
fi
2018-06-28 16:08:59 -07:00
cat <<EOF
usage: $0 [-n lamports] [-l] [-p] [-t node_type]
2018-06-28 16:08:59 -07:00
Creates a fullnode configuration
-n lamports - Number of lamports to create
-t node_type - Create configuration files only for this kind of node. Valid
options are bootstrap-leader or fullnode. Creates configuration files
for both by default
2018-06-28 16:08:59 -07:00
EOF
exit $exitcode
2018-06-28 16:08:59 -07:00
}
lamports=1000000000
bootstrap_leader=true
bootstrap_leader_lamports=
fullnode=true
while getopts "h?n:b:lpt:" opt; do
2018-06-28 16:08:59 -07:00
case $opt in
h|\?)
usage
exit 0
;;
n)
lamports="$OPTARG"
2018-06-28 16:08:59 -07:00
;;
b)
bootstrap_leader_lamports="$OPTARG"
;;
t)
node_type="$OPTARG"
case $OPTARG in
bootstrap-leader|leader) # TODO: Remove legacy 'leader' option
bootstrap_leader=true
fullnode=false
;;
fullnode|validator) # TODO: Remove legacy 'validator' option
bootstrap_leader=false
fullnode=true
;;
*)
usage "Error: unknown node type: $node_type"
;;
esac
;;
*)
usage "Error: unhandled option: $opt"
;;
2018-06-28 16:08:59 -07:00
esac
done
2018-06-24 10:10:55 -07:00
set -e
for i in "$SOLANA_RSYNC_CONFIG_DIR" "$SOLANA_CONFIG_DIR"; do
echo "Cleaning $i"
rm -rvf "$i"
mkdir -p "$i"
done
if $bootstrap_leader; then
# Create genesis configuration
(
set -x
$solana_keygen -o "$SOLANA_CONFIG_DIR"/mint-id.json
$solana_keygen -o "$SOLANA_CONFIG_DIR"/bootstrap-leader-id.json
$solana_keygen -o "$SOLANA_CONFIG_DIR"/bootstrap-leader-vote-id.json
args=(
--bootstrap-leader-keypair "$SOLANA_CONFIG_DIR"/bootstrap-leader-id.json
--bootstrap-vote-keypair "$SOLANA_CONFIG_DIR"/bootstrap-leader-vote-id.json
--ledger "$SOLANA_RSYNC_CONFIG_DIR"/ledger
--mint "$SOLANA_CONFIG_DIR"/mint-id.json
--lamports "$lamports"
)
if [[ -n $bootstrap_leader_lamports ]]; then
args+=(--bootstrap-leader-lamports "$bootstrap_leader_lamports")
fi
$solana_genesis "${args[@]}"
2018-12-07 10:34:14 -08:00
cp -a "$SOLANA_RSYNC_CONFIG_DIR"/ledger "$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger
)
fi
2018-06-24 10:10:55 -07:00
if $fullnode; then
(
set -x
$solana_keygen -o "$SOLANA_CONFIG_DIR"/fullnode-id.json
$solana_keygen -o "$SOLANA_CONFIG_DIR"/fullnode-vote-id.json
)
fi