solana/multinode-demo/common.sh

93 lines
2.6 KiB
Bash
Raw Normal View History

2018-06-24 10:10:55 -07:00
# |source| this file
#
2018-08-27 09:13:53 -07:00
# Common utilities shared by other scripts in this directory
#
# The following directive disable complaints about unused variables in this
# file:
2018-06-24 10:10:55 -07:00
# shellcheck disable=2034
2018-08-27 09:13:53 -07:00
#
2018-06-24 10:10:55 -07:00
SOLANA_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. || exit 1; pwd)"
rsync=rsync
if [[ $(uname) != Linux ]]; then
# Protect against unsupported configurations to prevent non-obvious errors
# later. Arguably these should be fatal errors but for now prefer tolerance.
if [[ -n $SOLANA_CUDA ]]; then
echo "Warning: CUDA is not supported on $(uname)"
SOLANA_CUDA=
fi
fi
if [[ -n $USE_INSTALL || ! -f "$SOLANA_ROOT"/Cargo.toml ]]; then
2018-06-24 10:10:55 -07:00
solana_program() {
2018-06-26 18:30:17 -07:00
declare program="$1"
2018-06-24 10:10:55 -07:00
printf "solana-%s" "$program"
}
else
solana_program() {
2018-06-26 18:30:17 -07:00
declare program="$1"
2019-04-12 08:38:14 -07:00
declare features="--features="
2018-06-24 10:10:55 -07:00
if [[ "$program" =~ ^(.*)-cuda$ ]]; then
program=${BASH_REMATCH[1]}
2019-04-12 08:38:14 -07:00
features+="cuda,"
2018-06-24 10:10:55 -07:00
fi
if [[ $program = replicator ]]; then
features+="chacha,"
fi
2018-12-12 13:30:00 -08:00
if [[ -r "$SOLANA_ROOT/$program"/Cargo.toml ]]; then
2018-12-12 13:30:00 -08:00
maybe_package="--package solana-$program"
2018-11-16 08:04:46 -08:00
fi
if [[ -n $NDEBUG ]]; then
maybe_release=--release
fi
declare manifest_path="--manifest-path=$SOLANA_ROOT/$program/Cargo.toml"
printf "cargo run $manifest_path $maybe_release $maybe_package --bin solana-%s %s -- " "$program" "$features"
2018-06-24 10:10:55 -07:00
}
2019-04-12 08:38:14 -07:00
# shellcheck disable=2154 # 'here' is referenced but not assigned
LD_LIBRARY_PATH=$(cd "$SOLANA_ROOT/target/perf-libs" && pwd):$LD_LIBRARY_PATH
2019-04-12 08:38:14 -07:00
export LD_LIBRARY_PATH
2018-06-24 10:10:55 -07:00
fi
2018-07-19 12:59:31 -07:00
solana_bench_tps=$(solana_program bench-tps)
2018-06-24 10:10:55 -07:00
solana_drone=$(solana_program drone)
solana_fullnode=$(solana_program fullnode)
solana_fullnode_cuda=$(solana_program fullnode-cuda)
solana_genesis=$(solana_program genesis)
2019-04-01 16:43:07 -07:00
solana_gossip=$(solana_program gossip)
2018-07-12 14:42:01 -07:00
solana_keygen=$(solana_program keygen)
solana_ledger_tool=$(solana_program ledger-tool)
2019-04-01 16:43:07 -07:00
solana_wallet=$(solana_program wallet)
solana_replicator=$(solana_program replicator)
2018-06-24 10:10:55 -07:00
export RUST_LOG=${RUST_LOG:-solana=info} # if RUST_LOG is unset, default to info
export RUST_BACKTRACE=1
# shellcheck source=scripts/configure-metrics.sh
source "$SOLANA_ROOT"/scripts/configure-metrics.sh
# The directory on the cluster entrypoint that is rsynced by other full nodes
SOLANA_RSYNC_CONFIG_DIR=$SOLANA_ROOT/config
# Configuration that remains local
SOLANA_CONFIG_DIR=$SOLANA_ROOT/config-local
default_arg() {
declare name=$1
declare value=$2
for arg in "${args[@]}"; do
if [[ $arg = "$name" ]]; then
return
fi
done
if [[ -n $value ]]; then
args+=("$name" "$value")
else
args+=("$name")
fi
}