diff --git a/multinode-demo/client.sh b/multinode-demo/client.sh index 10b6305de5..ef69e6de4e 100755 --- a/multinode-demo/client.sh +++ b/multinode-demo/client.sh @@ -1,15 +1,14 @@ #!/bin/bash if [[ -z $1 ]]; then - printf 'usage: %s [network path to solana repo on leader machine] [number of nodes in the network if greater then 1]' "$0" - exit 1 + echo "usage: $0 [network path to solana repo on leader machine] " + exit 1 fi LEADER=$1 COUNT=${2:-1} -set -x -rsync -v "$LEADER"/{leader.json,mint-demo.json} . || exit $? +rsync -vz "$LEADER"/{leader.json,mint-demo.json} . || exit $? # if RUST_LOG is unset, default to info export RUST_LOG=${RUST_LOG:-solana=info} diff --git a/multinode-demo/leader.sh b/multinode-demo/leader.sh index 70a2bee217..2f7e8edbc5 100755 --- a/multinode-demo/leader.sh +++ b/multinode-demo/leader.sh @@ -1,14 +1,26 @@ #!/bin/bash +here=$(dirname $0) +. "${here}"/myip.sh + +myip=$(myip) || exit $? + +[[ -f leader-"${myip}".json ]] || { + echo "I can't find a matching leader config file for \"${myip}\"... +Please run ${here}/setup.sh first. +" + exit 1 +} # if RUST_LOG is unset, default to info export RUST_LOG=${RUST_LOG:-solana=info} -set -x -[[ $(uname) = Linux ]] && sudo sysctl -w net.core.rmem_max=26214400 +[[ $(uname) = Linux ]] && sudo sysctl -w net.core.rmem_max=26214400 1>/dev/null 2>/dev/null -IPADDR="$(ifconfig | awk '/inet (addr)?/ {print $2}' | cut -d: -f2 | grep -v '127.0.0.1')" - -cp leader-"$IPADDR".json leader.json +# this makes a leader.json file available alongside genesis, etc. for +# validators and clients +cp leader-"${myip}".json leader.json cargo run --release --bin solana-fullnode -- \ - -l leader.json < genesis.log tx-*.log > tx-"$(date -u +%Y%m%d%k%M%S%N)".log + -l leader-"${myip}".json \ + < genesis.log tx-*.log \ + > tx-"$(date -u +%Y%m%d%H%M%S%N)".log diff --git a/multinode-demo/myip.sh b/multinode-demo/myip.sh new file mode 100755 index 0000000000..084046026e --- /dev/null +++ b/multinode-demo/myip.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +function myip() +{ + declare ipaddrs=( + $(curl -s ifconfig.co) # query interwebs + $(ifconfig | awk '/inet(6)? (addr:)?/ {print $2}') # machine interfaces + ) + + if (( ! ${#ipaddrs[*]} )) + then + echo " +myip: error: I'm having trouble determining what our IP address is... + Are we connected to a network? + +" + return 1 + fi + + + declare prompt=" +Please choose the IP address you want to advertise to the network: + + 0) ${ipaddrs[0]} <====== this one was returned by the interwebs... +" + + for ((i=1; i < ${#ipaddrs[*]}; i++)) + do + prompt+=" $i) ${ipaddrs[i]} +" + done + + while read -p "${prompt} +please enter a number [0 for default]: " which + do + [[ -z ${which} ]] && break; + [[ ${which} =~ [0-9]+ ]] && (( which < ${#ipaddrs[*]} )) && break; + echo "Ug. invalid entry \"${which}\"... +" + sleep 1 + done + + which=${which:-0} + + echo "${ipaddrs[which]}" + +} + +if [[ ${0} == ${BASH_SOURCE[0]} ]] +then + myip "$@" +fi diff --git a/multinode-demo/setup.sh b/multinode-demo/setup.sh index 61b61ab27b..1f393782e3 100755 --- a/multinode-demo/setup.sh +++ b/multinode-demo/setup.sh @@ -1,11 +1,13 @@ #!/bin/bash +here=$(dirname $0) +. "${here}"/myip.sh -TOKENS=${1:-1000000000} +myip=$(myip) || exit $? -cargo run --release --bin solana-mint-demo <<<"${TOKENS}" > mint-demo.json +num_tokens=${1:-1000000000} + +cargo run --release --bin solana-mint-demo <<<"${num_tokens}" > mint-demo.json cargo run --release --bin solana-genesis-demo < mint-demo.json > genesis.log -IPADDR="$(ifconfig | awk '/inet (addr)?/ {print $2}' | cut -d: -f2 | grep -v '127.0.0.1')" - -cargo run --release --bin solana-fullnode-config -- -d > leader-"$IPADDR".json -cargo run --release --bin solana-fullnode-config -- -b 9000 -d > validator-"$IPADDR".json +cargo run --release --bin solana-fullnode-config -- -d > leader-"${myip}".json +cargo run --release --bin solana-fullnode-config -- -b 9000 -d > validator-"${myip}".json diff --git a/multinode-demo/validator.sh b/multinode-demo/validator.sh index 298f0c9825..499c42c86a 100755 --- a/multinode-demo/validator.sh +++ b/multinode-demo/validator.sh @@ -1,22 +1,30 @@ #!/bin/bash +here=$(dirname $0) +. "${here}"/myip.sh -if [[ -z $1 ]]; then - printf 'usage: %s [network path to solana repo on leader machine]\n' "$0" +leader=$1 + +[[ -z ${leader} ]] && { + echo "usage: $0 [network path to solana repo on leader machine]" exit 1 -fi +} -LEADER=$1 +myip=$(myip) || exit $? -set -x +[[ -f validator-"$myip".json ]] || { + echo "I can't find a matching validator config file for \"${myip}\"... +Please run ${here}/setup.sh first. +" + exit 1 +} -rsync -v "$LEADER"/{mint-demo.json,leader.json,genesis.log,tx-*.log} . || exit $? +rsync -vz "${leader}"/{mint-demo.json,leader.json,genesis.log,tx-*.log} . || exit $? -[[ $(uname) = Linux ]] && sudo sysctl -w net.core.rmem_max=26214400 +[[ $(uname) = Linux ]] && sudo sysctl -w net.core.rmem_max=26214400 1>/dev/null 2>/dev/null # if RUST_LOG is unset, default to info export RUST_LOG=${RUST_LOG:-solana=info} -IPADDR="$(ifconfig | awk '/inet (addr)?/ {print $2}' | cut -d: -f2 | grep -v '127.0.0.1')" - cargo run --release --bin solana-fullnode -- \ - -l validator-"$IPADDR".json -v leader.json < genesis.log tx-*.log + -l validator-"${myip}".json -v leader.json \ + < genesis.log tx-*.log