Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove IPADDR, which was making Rob feel ill #417

Merged
merged 3 commits into from
Jun 23, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions multinode-demo/client.sh
Original file line number Diff line number Diff line change
@@ -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] <number of nodes in the network>"
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}
Expand Down
24 changes: 18 additions & 6 deletions multinode-demo/leader.sh
Original file line number Diff line number Diff line change
@@ -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

IPADDR="$(ifconfig | awk '/inet (addr)?/ {print $2}' | cut -d: -f2 | grep -v '127.0.0.1')"
[[ $(uname) = Linux ]] && sudo sysctl -w net.core.rmem_max=26214400 1>/dev/null 2>/dev/null

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
52 changes: 52 additions & 0 deletions multinode-demo/myip.sh
Original file line number Diff line number Diff line change
@@ -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
14 changes: 8 additions & 6 deletions multinode-demo/setup.sh
Original file line number Diff line number Diff line change
@@ -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
cargo run --release --bin solana-genesis-demo < mint-demo.json > genesis.log
num_tokens=${1:-1000000000}

IPADDR="$(ifconfig | awk '/inet (addr)?/ {print $2}' | cut -d: -f2 | grep -v '127.0.0.1')"
cargo run --release --bin solana-mint-demo <<<"${num_tokens}" > mint-demo.json
cargo run --release --bin solana-genesis-demo < mint-demo.json > genesis.log

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
28 changes: 18 additions & 10 deletions multinode-demo/validator.sh
Original file line number Diff line number Diff line change
@@ -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