2018-11-11 08:02:50 -08:00
|
|
|
#!/usr/bin/env bash
|
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
|
|
|
|
2019-04-17 18:03:58 -07:00
|
|
|
lamports=1000000000
|
|
|
|
bootstrap_leader_lamports=
|
|
|
|
|
2018-06-28 16:08:59 -07:00
|
|
|
usage () {
|
2018-07-02 08:08:14 -07:00
|
|
|
exitcode=0
|
|
|
|
if [[ -n "$1" ]]; then
|
|
|
|
exitcode=1
|
|
|
|
echo "Error: $*"
|
|
|
|
fi
|
2018-06-28 16:08:59 -07:00
|
|
|
cat <<EOF
|
2019-04-17 18:03:58 -07:00
|
|
|
usage: $0 [-n lamports] [-b lamports]
|
2018-06-28 16:08:59 -07:00
|
|
|
|
2019-04-17 18:03:58 -07:00
|
|
|
Create a cluster configuration
|
2018-06-28 16:08:59 -07:00
|
|
|
|
2019-04-17 18:03:58 -07:00
|
|
|
-n lamports - Number of lamports to create [default: $lamports]
|
|
|
|
-b lamports - Override the number of lamports for the bootstrap leader's stake
|
2018-07-02 08:08:14 -07:00
|
|
|
|
2018-06-28 16:08:59 -07:00
|
|
|
EOF
|
2018-07-02 08:08:14 -07:00
|
|
|
exit $exitcode
|
2018-06-28 16:08:59 -07:00
|
|
|
}
|
|
|
|
|
2019-04-17 18:03:58 -07:00
|
|
|
while getopts "h?n:b:" opt; do
|
2018-06-28 16:08:59 -07:00
|
|
|
case $opt in
|
|
|
|
h|\?)
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
n)
|
2019-03-05 17:01:57 -08:00
|
|
|
lamports="$OPTARG"
|
2018-06-28 16:08:59 -07:00
|
|
|
;;
|
2019-04-16 13:03:01 -07:00
|
|
|
b)
|
|
|
|
bootstrap_leader_lamports="$OPTARG"
|
|
|
|
;;
|
2018-07-02 08:08:14 -07:00
|
|
|
*)
|
|
|
|
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
|
2019-04-17 18:03:58 -07:00
|
|
|
"$here"/clear-fullnode-config.sh
|
2018-06-18 15:23:56 -07:00
|
|
|
|
2019-04-17 18:03:58 -07:00
|
|
|
# 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
|
2019-04-16 13:03:01 -07:00
|
|
|
|
2019-04-17 18:03:58 -07:00
|
|
|
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"
|
|
|
|
)
|
2019-04-16 13:03:01 -07:00
|
|
|
|
2019-04-17 18:03:58 -07:00
|
|
|
if [[ -n $bootstrap_leader_lamports ]]; then
|
|
|
|
args+=(--bootstrap-leader-lamports "$bootstrap_leader_lamports")
|
2018-07-02 08:08:14 -07:00
|
|
|
fi
|
2018-06-24 10:10:55 -07:00
|
|
|
|
2019-04-17 18:03:58 -07:00
|
|
|
$solana_genesis "${args[@]}"
|
|
|
|
cp -a "$SOLANA_RSYNC_CONFIG_DIR"/ledger "$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger
|