2018-06-26 22:53:05 -07:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
2018-08-27 09:13:53 -07:00
|
|
|
# Runs solana-wallet against the specified network
|
|
|
|
#
|
2018-06-27 07:40:22 -07:00
|
|
|
# usage: $0 <rsync network path to solana repo on leader machine>"
|
2018-06-26 22:53:05 -07:00
|
|
|
#
|
|
|
|
|
|
|
|
here=$(dirname "$0")
|
2018-06-26 23:15:43 -07:00
|
|
|
# shellcheck source=multinode-demo/common.sh
|
2018-06-26 22:53:05 -07:00
|
|
|
source "$here"/common.sh
|
|
|
|
|
2018-08-27 10:23:22 -07:00
|
|
|
# shellcheck source=scripts/oom-score-adj.sh
|
|
|
|
source "$here"/../scripts/oom-score-adj.sh
|
|
|
|
|
2018-07-02 15:17:12 -07:00
|
|
|
# if $1 isn't host:path, something.com, or a valid local path
|
2018-07-02 17:08:39 -07:00
|
|
|
if [[ ${1%:} != "$1" || "$1" =~ [^.]\.[^.] || -d $1 ]]; then
|
2018-07-02 11:58:01 -07:00
|
|
|
leader=$1 # interpret
|
|
|
|
shift
|
|
|
|
else
|
2018-07-02 16:54:23 -07:00
|
|
|
if [[ -d "$SNAP" ]]; then
|
|
|
|
leader=testnet.solana.com # Default to testnet when running as a Snap
|
|
|
|
else
|
|
|
|
leader=$here/.. # Default to local solana repo
|
|
|
|
fi
|
2018-07-02 11:58:01 -07:00
|
|
|
fi
|
2018-06-26 22:53:05 -07:00
|
|
|
|
2018-07-02 17:08:39 -07:00
|
|
|
if [[ "$1" = "reset" ]]; then
|
|
|
|
echo Wallet resetting
|
|
|
|
rm -rf "$SOLANA_CONFIG_CLIENT_DIR"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2018-06-26 22:53:05 -07:00
|
|
|
rsync_leader_url=$(rsync_url "$leader")
|
|
|
|
|
2018-07-02 10:54:35 -07:00
|
|
|
set -e
|
2018-07-02 17:08:39 -07:00
|
|
|
mkdir -p "$SOLANA_CONFIG_CLIENT_DIR"
|
|
|
|
if [[ ! -r "$SOLANA_CONFIG_CLIENT_DIR"/leader.json ]]; then
|
2018-07-14 20:29:29 -07:00
|
|
|
echo "Fetching leader configuration from $rsync_leader_url"
|
|
|
|
$rsync -Pz "$rsync_leader_url"/config/leader.json "$SOLANA_CONFIG_CLIENT_DIR"/
|
2018-07-02 10:54:35 -07:00
|
|
|
fi
|
2018-06-26 22:53:05 -07:00
|
|
|
|
2018-07-13 09:34:42 -07:00
|
|
|
client_id_path="$SOLANA_CONFIG_CLIENT_DIR"/id.json
|
|
|
|
if [[ ! -r $client_id_path ]]; then
|
2018-07-14 20:29:29 -07:00
|
|
|
echo "Generating client identity: $client_id_path"
|
|
|
|
$solana_keygen -o "$client_id_path"
|
2018-06-29 22:56:23 -07:00
|
|
|
fi
|
|
|
|
|
2018-06-29 09:16:20 -07:00
|
|
|
# shellcheck disable=SC2086 # $solana_wallet should not be quoted
|
2018-06-28 11:56:53 -07:00
|
|
|
exec $solana_wallet \
|
2018-08-28 16:32:40 -07:00
|
|
|
-l "$SOLANA_CONFIG_CLIENT_DIR"/leader.json -k "$client_id_path" --timeout 10 "$@"
|