2018-06-24 10:10:55 -07:00
|
|
|
# |source| this file
|
|
|
|
#
|
|
|
|
# Disable complaints about unused variables in this file:
|
|
|
|
# shellcheck disable=2034
|
|
|
|
|
2018-07-02 15:34:13 -07:00
|
|
|
rsync=rsync
|
2018-06-26 16:05:02 -07:00
|
|
|
if [[ -d "$SNAP" ]]; then # Running inside a Linux Snap?
|
2018-06-24 10:10:55 -07:00
|
|
|
solana_program() {
|
2018-06-26 18:30:17 -07:00
|
|
|
declare program="$1"
|
2018-07-02 16:54:44 -07:00
|
|
|
if [[ "$program" = wallet ]]; then
|
|
|
|
# TODO: Merge wallet.sh functionality into solana-wallet proper and
|
|
|
|
# remove this special case
|
|
|
|
printf "%s/bin/solana-%s" "$SNAP" "$program"
|
|
|
|
else
|
|
|
|
printf "%s/command-%s.wrapper" "$SNAP" "$program"
|
|
|
|
fi
|
2018-07-13 23:37:56 -07:00
|
|
|
if [[ "$program" = client-demo ]]; then
|
|
|
|
# TODO: Merge client.sh functionality into solana-client-demo proper and
|
|
|
|
# remove this special case
|
|
|
|
printf "%s/bin/solana-%s" "$SNAP" "$program"
|
|
|
|
else
|
|
|
|
printf "%s/command-%s.wrapper" "$SNAP" "$program"
|
|
|
|
fi
|
2018-06-24 10:10:55 -07:00
|
|
|
}
|
2018-07-02 15:34:13 -07:00
|
|
|
rsync="$SNAP"/bin/rsync
|
2018-07-07 08:34:31 -07:00
|
|
|
SOLANA_METRICS_CONFIG="$(snapctl get metrics-config)"
|
2018-06-24 10:10:55 -07:00
|
|
|
SOLANA_CUDA="$(snapctl get enable-cuda)"
|
2018-06-26 16:05:02 -07:00
|
|
|
|
|
|
|
elif [[ -n "$USE_SNAP" ]]; then # Use the Linux Snap binaries
|
|
|
|
solana_program() {
|
2018-06-26 18:30:17 -07:00
|
|
|
declare program="$1"
|
2018-06-26 16:05:02 -07:00
|
|
|
printf "solana.%s" "$program"
|
|
|
|
}
|
2018-06-24 10:10:55 -07:00
|
|
|
elif [[ -n "$USE_INSTALL" ]]; then # Assume |cargo install| was run
|
|
|
|
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"
|
|
|
|
}
|
2018-06-26 16:05:02 -07:00
|
|
|
# CUDA was/wasn't selected at build time, can't affect CUDA state here
|
|
|
|
unset SOLANA_CUDA
|
2018-06-24 10:10:55 -07:00
|
|
|
else
|
|
|
|
solana_program() {
|
2018-06-26 18:30:17 -07:00
|
|
|
declare program="$1"
|
|
|
|
declare features=""
|
2018-06-24 10:10:55 -07:00
|
|
|
if [[ "$program" =~ ^(.*)-cuda$ ]]; then
|
|
|
|
program=${BASH_REMATCH[1]}
|
|
|
|
features="--features=cuda,erasure"
|
|
|
|
fi
|
2018-06-27 10:05:18 -07:00
|
|
|
if [[ -z "$DEBUG" ]]; then
|
|
|
|
maybe_release=--release
|
|
|
|
fi
|
|
|
|
printf "cargo run $maybe_release --bin solana-%s %s -- " "$program" "$features"
|
2018-06-24 10:10:55 -07:00
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
|
|
|
solana_client_demo=$(solana_program client-demo)
|
2018-06-28 12:56:53 -06:00
|
|
|
solana_wallet=$(solana_program wallet)
|
2018-06-24 10:10:55 -07:00
|
|
|
solana_drone=$(solana_program drone)
|
|
|
|
solana_fullnode=$(solana_program fullnode)
|
|
|
|
solana_fullnode_config=$(solana_program fullnode-config)
|
|
|
|
solana_fullnode_cuda=$(solana_program fullnode-cuda)
|
2018-06-27 13:53:01 -06:00
|
|
|
solana_genesis=$(solana_program genesis)
|
2018-07-12 15:42:01 -06:00
|
|
|
solana_keygen=$(solana_program keygen)
|
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
|
2018-07-02 17:35:28 -07:00
|
|
|
|
2018-07-07 08:34:31 -07:00
|
|
|
|
|
|
|
# The SOLANA_METRICS_CONFIG environment variable is formatted as a
|
|
|
|
# comma-delimited list of parameters. All parameters are optional.
|
|
|
|
#
|
|
|
|
# Example:
|
|
|
|
# export SOLANA_METRICS_CONFIG="host=<metrics host>,db=<database name>,u=<username>,p=<password>"
|
|
|
|
#
|
|
|
|
configure_metrics() {
|
|
|
|
[[ -n $SOLANA_METRICS_CONFIG ]] || return
|
|
|
|
|
|
|
|
declare metrics_params
|
|
|
|
IFS=',' read -r -a metrics_params <<< "$SOLANA_METRICS_CONFIG"
|
|
|
|
for param in "${metrics_params[@]}"; do
|
|
|
|
IFS='=' read -r -a pair <<< "$param"
|
|
|
|
if [[ "${#pair[@]}" != 2 ]]; then
|
|
|
|
echo Error: invalid metrics parameter: "$param"
|
|
|
|
else
|
|
|
|
declare name="${pair[0]}"
|
|
|
|
declare value="${pair[1]}"
|
|
|
|
case "$name" in
|
|
|
|
host)
|
|
|
|
export INFLUX_HOST="$value"
|
|
|
|
echo INFLUX_HOST="$INFLUX_HOST"
|
|
|
|
;;
|
|
|
|
db)
|
|
|
|
export INFLUX_DATABASE="$value"
|
|
|
|
echo INFLUX_DATABASE="$INFLUX_DATABASE"
|
|
|
|
;;
|
|
|
|
u)
|
|
|
|
export INFLUX_USERNAME="$value"
|
|
|
|
echo INFLUX_USERNAME="$INFLUX_USERNAME"
|
|
|
|
;;
|
|
|
|
p)
|
|
|
|
export INFLUX_PASSWORD="$value"
|
|
|
|
echo INFLUX_PASSWORD="********"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo Error: Unknown metrics parameter name: "$name"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
configure_metrics
|
|
|
|
|
2018-07-02 17:35:28 -07:00
|
|
|
tune_networking() {
|
2018-07-04 14:17:42 -07:00
|
|
|
# Reference: https://medium.com/@CameronSparr/increase-os-udp-buffers-to-improve-performance-51d167bb1360
|
|
|
|
[[ $(uname) = Linux ]] && (
|
2018-07-13 16:22:02 -07:00
|
|
|
set -x +e
|
2018-07-12 15:56:52 -07:00
|
|
|
# test the existence of the sysctls before trying to set them
|
2018-07-13 16:22:02 -07:00
|
|
|
# go ahead and return true and don't exit if these calls fail
|
2018-07-12 16:17:56 -07:00
|
|
|
sysctl net.core.rmem_max 2>/dev/null 1>/dev/null &&
|
2018-07-12 15:56:52 -07:00
|
|
|
sudo sysctl -w net.core.rmem_max=26214400 1>/dev/null 2>/dev/null
|
|
|
|
|
2018-07-12 16:17:56 -07:00
|
|
|
sysctl net.core.rmem_default 2>/dev/null 1>/dev/null &&
|
2018-07-12 15:56:52 -07:00
|
|
|
sudo sysctl -w net.core.rmem_default=26214400 1>/dev/null 2>/dev/null
|
2018-07-13 16:22:02 -07:00
|
|
|
:
|
2018-07-04 14:17:42 -07:00
|
|
|
)
|
2018-07-13 16:22:02 -07:00
|
|
|
|
2018-07-02 17:35:28 -07:00
|
|
|
}
|
2018-06-24 10:10:55 -07:00
|
|
|
|
|
|
|
SOLANA_CONFIG_DIR=${SNAP_DATA:-$PWD}/config
|
2018-07-02 16:10:55 -07:00
|
|
|
SOLANA_CONFIG_PRIVATE_DIR=${SNAP_DATA:-$PWD}/config-private
|
2018-07-13 11:48:03 -07:00
|
|
|
SOLANA_CONFIG_CLIENT_DIR=${SNAP_USER_DATA:-$PWD}/config-client
|
2018-06-26 16:46:17 -07:00
|
|
|
|
|
|
|
rsync_url() { # adds the 'rsync://` prefix to URLs that need it
|
2018-06-26 18:30:17 -07:00
|
|
|
declare url="$1"
|
2018-06-26 16:46:17 -07:00
|
|
|
|
|
|
|
if [[ "$url" =~ ^.*:.*$ ]]; then
|
|
|
|
# assume remote-shell transport when colon is present, use $url unmodified
|
|
|
|
echo "$url"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -d "$url" ]]; then
|
|
|
|
# assume local directory if $url is a valid directory, use $url unmodified
|
|
|
|
echo "$url"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Default to rsync:// URL
|
|
|
|
echo "rsync://$url"
|
|
|
|
}
|