2018-06-14 17:11:55 -07:00
|
|
|
#!/bin/bash
|
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-24 10:10:55 -07:00
|
|
|
usage() {
|
2018-06-26 16:46:17 -07:00
|
|
|
if [[ -n "$1" ]]; then
|
|
|
|
echo "$*"
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
echo "usage: $0 [rsync network path to solana repo on leader machine] [network ip address of leader]"
|
2018-05-27 18:19:07 -07:00
|
|
|
exit 1
|
2018-06-22 18:18:09 -07:00
|
|
|
}
|
2018-05-27 18:19:07 -07:00
|
|
|
|
2018-06-24 10:10:55 -07:00
|
|
|
if [[ "$1" = "-h" || -n "$3" ]]; then
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -d "$SNAP" ]]; then
|
|
|
|
# Exit if mode is not yet configured
|
|
|
|
# (typically the case after the Snap is first installed)
|
|
|
|
[[ -n "$(snapctl get mode)" ]] || exit 0
|
|
|
|
|
|
|
|
# Select leader from the Snap configuration
|
|
|
|
leader_address="$(snapctl get leader-address)"
|
|
|
|
if [[ -z "$leader_address" ]]; then
|
2018-06-26 16:46:17 -07:00
|
|
|
# Assume public testnet by default
|
|
|
|
leader_address=35.230.65.68 # testnet.solana.com
|
2018-06-24 10:10:55 -07:00
|
|
|
fi
|
2018-06-26 16:46:17 -07:00
|
|
|
leader="$leader_address"
|
2018-06-24 10:10:55 -07:00
|
|
|
else
|
2018-06-26 16:46:17 -07:00
|
|
|
if [[ -n "$3" ]]; then
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "$1" ]]; then
|
|
|
|
leader=${1:-${here}/..} # Default to local solana repo
|
|
|
|
leader_address=${2:-127.0.0.1} # Default to local leader
|
|
|
|
elif [[ -z "$2" ]]; then
|
|
|
|
leader="$1"
|
|
|
|
leader_address=$(dig +short "$1" | head -n1)
|
|
|
|
if [[ -z "$leader_address" ]]; then
|
|
|
|
usage "Error: unable to resolve IP address for $leader"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
leader="$1"
|
|
|
|
leader_address="$2"
|
|
|
|
fi
|
2018-06-24 10:10:55 -07:00
|
|
|
fi
|
|
|
|
leader_port=8001
|
|
|
|
|
|
|
|
if [[ -n "$SOLANA_CUDA" ]]; then
|
|
|
|
program="$solana_fullnode_cuda"
|
|
|
|
else
|
|
|
|
program="$solana_fullnode"
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
[[ -f "$SOLANA_CONFIG_DIR"/validator.json ]] || {
|
2018-07-02 08:08:14 -07:00
|
|
|
echo "$SOLANA_CONFIG_DIR/validator.json not found, create it by running:"
|
|
|
|
echo
|
|
|
|
echo " ${here}/setup.sh -t validator"
|
2018-06-22 18:18:09 -07:00
|
|
|
exit 1
|
|
|
|
}
|
2018-05-27 18:19:07 -07:00
|
|
|
|
2018-06-26 16:46:17 -07:00
|
|
|
rsync_leader_url=$(rsync_url "$leader")
|
|
|
|
|
2018-07-15 12:25:32 -07:00
|
|
|
tune_networking
|
|
|
|
|
2018-06-24 10:10:55 -07:00
|
|
|
SOLANA_LEADER_CONFIG_DIR="$SOLANA_CONFIG_DIR"/leader-config
|
|
|
|
rm -rf "$SOLANA_LEADER_CONFIG_DIR"
|
2018-07-15 12:25:32 -07:00
|
|
|
set -ex
|
2018-07-27 23:44:52 -07:00
|
|
|
$rsync -vPrz --max-size=100M "$rsync_leader_url"/config/ "$SOLANA_LEADER_CONFIG_DIR"
|
|
|
|
[[ -r "$SOLANA_LEADER_CONFIG_DIR"/ledger.log ]] || {
|
|
|
|
echo "Unable to retrieve ledger.log from $rsync_leader_url"
|
|
|
|
exit 1
|
|
|
|
}
|
2018-07-02 17:35:28 -07:00
|
|
|
|
2018-07-13 09:34:42 -07:00
|
|
|
# Ensure the validator has at least 1 token before connecting to the network
|
|
|
|
# TODO: Remove this workaround
|
|
|
|
while ! $solana_wallet \
|
2018-07-13 11:47:52 -07:00
|
|
|
-l "$SOLANA_LEADER_CONFIG_DIR"/leader.json \
|
2018-07-15 12:25:32 -07:00
|
|
|
-k "$SOLANA_CONFIG_PRIVATE_DIR"/validator-id.json airdrop --tokens 1; do
|
2018-07-13 09:34:42 -07:00
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
|
2018-07-17 13:31:24 -07:00
|
|
|
set -o pipefail
|
|
|
|
$program \
|
2018-07-12 15:45:41 -07:00
|
|
|
--identity "$SOLANA_CONFIG_DIR"/validator.json \
|
|
|
|
--testnet "$leader_address:$leader_port" \
|
2018-07-17 13:31:24 -07:00
|
|
|
--ledger "$SOLANA_LEADER_CONFIG_DIR"/ledger.log \
|
|
|
|
2>&1 | $validator_logger
|