Automatically add rsync:// prefix to URLs that need it
This commit is contained in:
parent
5b5df49e6c
commit
5cd1fb486f
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# usage: $0 <network path to solana repo on leader machine> <number of nodes in the network>"
|
# usage: $0 <rsync network path to solana repo on leader machine> <number of nodes in the network>"
|
||||||
#
|
#
|
||||||
|
|
||||||
here=$(dirname "$0")
|
here=$(dirname "$0")
|
||||||
|
@ -11,10 +11,12 @@ SOLANA_CONFIG_DIR=config-client-demo
|
||||||
leader=${1:-${here}/..} # Default to local solana repo
|
leader=${1:-${here}/..} # Default to local solana repo
|
||||||
count=${2:-1}
|
count=${2:-1}
|
||||||
|
|
||||||
|
rsync_leader_url=$(rsync_url "$leader")
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
mkdir -p $SOLANA_CONFIG_DIR
|
mkdir -p $SOLANA_CONFIG_DIR
|
||||||
rsync -vz "$leader"/config/leader.json $SOLANA_CONFIG_DIR/
|
rsync -vPz "$rsync_leader_url"/config/leader.json $SOLANA_CONFIG_DIR/
|
||||||
rsync -vz "$leader"/config/mint-demo.json $SOLANA_CONFIG_DIR/
|
rsync -vPz "$rsync_leader_url"/config/mint-demo.json $SOLANA_CONFIG_DIR/
|
||||||
|
|
||||||
# shellcheck disable=SC2086 # $solana_client_demo should not be quoted
|
# shellcheck disable=SC2086 # $solana_client_demo should not be quoted
|
||||||
exec $solana_client_demo \
|
exec $solana_client_demo \
|
||||||
|
|
|
@ -47,3 +47,22 @@ export RUST_BACKTRACE=1
|
||||||
[[ $(uname) = Linux ]] && (set -x; sudo sysctl -w net.core.rmem_max=26214400 1>/dev/null 2>/dev/null)
|
[[ $(uname) = Linux ]] && (set -x; sudo sysctl -w net.core.rmem_max=26214400 1>/dev/null 2>/dev/null)
|
||||||
|
|
||||||
SOLANA_CONFIG_DIR=${SNAP_DATA:-$PWD}/config
|
SOLANA_CONFIG_DIR=${SNAP_DATA:-$PWD}/config
|
||||||
|
|
||||||
|
rsync_url() { # adds the 'rsync://` prefix to URLs that need it
|
||||||
|
local url="$1"
|
||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# usage: $0 <network path to solana repo on leader machine>
|
# usage: $0 <rsync network path to solana repo on leader machine>
|
||||||
#
|
#
|
||||||
|
|
||||||
here=$(dirname "$0")
|
here=$(dirname "$0")
|
||||||
|
@ -19,15 +19,16 @@ if [[ -d "$SNAP" ]]; then
|
||||||
# Assume drone is running on the same node as the leader by default
|
# Assume drone is running on the same node as the leader by default
|
||||||
leader_address="localhost"
|
leader_address="localhost"
|
||||||
fi
|
fi
|
||||||
leader=rsync://"$leader_address"
|
leader="$leader_address"
|
||||||
else
|
else
|
||||||
leader=${1:-${here}/..} # Default to local solana repo
|
leader=${1:-${here}/..} # Default to local solana repo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
rsync_leader_url=$(rsync_url "$leader")
|
||||||
set -ex
|
set -ex
|
||||||
mkdir -p $SOLANA_CONFIG_DIR
|
mkdir -p $SOLANA_CONFIG_DIR
|
||||||
rsync -vz "$leader"/config/leader.json $SOLANA_CONFIG_DIR/
|
rsync -vPz "$rsync_leader_url"/config/leader.json $SOLANA_CONFIG_DIR/
|
||||||
rsync -vz "$leader"/config/mint-demo.json $SOLANA_CONFIG_DIR/
|
rsync -vPz "$rsync_leader_url"/config/mint-demo.json $SOLANA_CONFIG_DIR/
|
||||||
|
|
||||||
# shellcheck disable=SC2086 # $solana_drone should not be quoted
|
# shellcheck disable=SC2086 # $solana_drone should not be quoted
|
||||||
exec $solana_drone \
|
exec $solana_drone \
|
||||||
|
|
|
@ -4,7 +4,11 @@ here=$(dirname "$0")
|
||||||
source "$here"/common.sh
|
source "$here"/common.sh
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "usage: $0 [network path to solana repo on leader machine] [network ip address of leader]"
|
if [[ -n "$1" ]]; then
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
echo "usage: $0 [rsync network path to solana repo on leader machine] [network ip address of leader]"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,13 +24,28 @@ if [[ -d "$SNAP" ]]; then
|
||||||
# Select leader from the Snap configuration
|
# Select leader from the Snap configuration
|
||||||
leader_address="$(snapctl get leader-address)"
|
leader_address="$(snapctl get leader-address)"
|
||||||
if [[ -z "$leader_address" ]]; then
|
if [[ -z "$leader_address" ]]; then
|
||||||
# Assume drone is running on the same node as the leader by default
|
# Assume public testnet by default
|
||||||
leader_address="localhost"
|
leader_address=35.230.65.68 # testnet.solana.com
|
||||||
fi
|
fi
|
||||||
leader=rsync://"$leader_address"
|
leader="$leader_address"
|
||||||
else
|
else
|
||||||
leader=${1:-${here}/..} # Default to local solana repo
|
if [[ -n "$3" ]]; then
|
||||||
leader_address=${2:-127.0.0.1} # Default to local leader
|
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
|
||||||
fi
|
fi
|
||||||
leader_port=8001
|
leader_port=8001
|
||||||
|
|
||||||
|
@ -42,10 +61,12 @@ fi
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rsync_leader_url=$(rsync_url "$leader")
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
SOLANA_LEADER_CONFIG_DIR="$SOLANA_CONFIG_DIR"/leader-config
|
SOLANA_LEADER_CONFIG_DIR="$SOLANA_CONFIG_DIR"/leader-config
|
||||||
rm -rf "$SOLANA_LEADER_CONFIG_DIR"
|
rm -rf "$SOLANA_LEADER_CONFIG_DIR"
|
||||||
rsync -vPrz "${leader}"/config/ "$SOLANA_LEADER_CONFIG_DIR"
|
rsync -vPrz "$rsync_leader_url"/config/ "$SOLANA_LEADER_CONFIG_DIR"
|
||||||
ls -lh "$SOLANA_LEADER_CONFIG_DIR"
|
ls -lh "$SOLANA_LEADER_CONFIG_DIR"
|
||||||
|
|
||||||
# shellcheck disable=SC2086 # $program should not be quoted
|
# shellcheck disable=SC2086 # $program should not be quoted
|
||||||
|
|
Loading…
Reference in New Issue