Refactor multinode-demo/ scripts to avoid shipping fullnode-x.sh (#3835)
This commit is contained in:
@ -1,12 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Creates a fullnode configuration
|
||||
#
|
||||
|
||||
here=$(dirname "$0")
|
||||
# shellcheck source=multinode-demo/common.sh
|
||||
source "$here"/common.sh
|
||||
|
||||
lamports=1000000000
|
||||
bootstrap_leader_lamports=
|
||||
|
||||
usage () {
|
||||
exitcode=0
|
||||
if [[ -n "$1" ]]; then
|
||||
@ -14,25 +14,18 @@ usage () {
|
||||
echo "Error: $*"
|
||||
fi
|
||||
cat <<EOF
|
||||
usage: $0 [-n lamports] [-l] [-p] [-t node_type]
|
||||
usage: $0 [-n lamports] [-b lamports]
|
||||
|
||||
Creates a fullnode configuration
|
||||
Create a cluster 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
|
||||
-n lamports - Number of lamports to create [default: $lamports]
|
||||
-b lamports - Override the number of lamports for the bootstrap leader's stake
|
||||
|
||||
EOF
|
||||
exit $exitcode
|
||||
}
|
||||
|
||||
lamports=1000000000
|
||||
bootstrap_leader=true
|
||||
bootstrap_leader_lamports=
|
||||
|
||||
fullnode=true
|
||||
while getopts "h?n:b:lpt:" opt; do
|
||||
while getopts "h?n:b:" opt; do
|
||||
case $opt in
|
||||
h|\?)
|
||||
usage
|
||||
@ -44,22 +37,6 @@ while getopts "h?n:b:lpt:" opt; do
|
||||
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"
|
||||
;;
|
||||
@ -68,42 +45,24 @@ done
|
||||
|
||||
|
||||
set -e
|
||||
"$here"/clear-fullnode-config.sh
|
||||
|
||||
for i in "$SOLANA_RSYNC_CONFIG_DIR" "$SOLANA_CONFIG_DIR"; do
|
||||
echo "Cleaning $i"
|
||||
rm -rvf "$i"
|
||||
mkdir -p "$i"
|
||||
done
|
||||
# Create genesis ledger
|
||||
$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
|
||||
|
||||
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"
|
||||
)
|
||||
|
||||
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[@]}"
|
||||
cp -a "$SOLANA_RSYNC_CONFIG_DIR"/ledger "$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger
|
||||
)
|
||||
if [[ -n $bootstrap_leader_lamports ]]; then
|
||||
args+=(--bootstrap-leader-lamports "$bootstrap_leader_lamports")
|
||||
fi
|
||||
|
||||
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
|
||||
$solana_genesis "${args[@]}"
|
||||
cp -a "$SOLANA_RSYNC_CONFIG_DIR"/ledger "$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger
|
||||
|
Reference in New Issue
Block a user