Last active
April 29, 2019 18:50
-
-
Save stefanbenten/2e1bc6506e886d1c6ae1490e1852dedf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Prerequisite: go and tmux installed and ssh-keys installed on this machine | |
# | |
IP1=10.0.20.10 #This is the bootstrap/main address and localhost youre running on | |
IP2=10.0.20.11 | |
IP3=10.0.20.12 | |
IP4=10.0.20.13 | |
setup() { | |
fetchRepo | |
installSim | |
storj-sim network setup | |
ssh root@$IP2 'storj-sim network setup' | |
ssh root@$IP3 'storj-sim network setup' | |
ssh root@$IP4 'storj-sim network setup' | |
setbootstrap | |
} | |
fetchRepo() { | |
git clone https://github.com/storj/storj | |
ssh root@$IP2 'git clone https://github.com/storj/storj' | |
ssh root@$IP3 'git clone https://github.com/storj/storj' | |
ssh root@$IP4 'git clone https://github.com/storj/storj' | |
} | |
installSim() { | |
cd storj && go install ./... | |
ssh root@$IP2 'cd storj && go install ./...' | |
ssh root@$IP3 'cd storj && go install ./...' | |
ssh root@$IP4 'cd storj && go install ./...' | |
} | |
destroy() { | |
storj-sim network destroy | |
ssh root@$IP2 'storj-sim network destroy' | |
ssh root@$IP3 'storj-sim network destroy' | |
ssh root@$IP4 'storj-sim network destroy' | |
} | |
setbootstrap() { | |
#find ~/.local/share/storj/local-network/ -type f -name "config.yaml" -exec sed -i "/kademlia.bootstrap/s/127.0.0.1:13000/$IP1:13000/" {} + | |
ssh root@$IP2 'find ~/.local/share/storj/local-network/ -type f -name "config.yaml" -exec sed -i "/kademlia.bootstrap/s/127.0.0.1:13000/$IP1:13000/" {} +' | |
ssh root@$IP3 'find ~/.local/share/storj/local-network/ -type f -name "config.yaml" -exec sed -i "/kademlia.bootstrap/s/127.0.0.1:13000/$IP1:13000/" {} +' | |
ssh root@$IP4 'find ~/.local/share/storj/local-network/ -type f -name "config.yaml" -exec sed -i "/kademlia.bootstrap/s/127.0.0.1:13000/$IP1:13000/" {} +' | |
} | |
setpublickey() { | |
#find ~/.local/share/storj/local-network/ -type f -name "config.yaml" -exec sed -i "/kademlia.bootstrap/s/127.0.0.1:13000/$IP1:13000/" {} + | |
ssh root@$IP2 'find ~/.local/share/storj/local-network/ -type f -name "config.yaml" -exec sed -i "/minio.access-key/s/127.0.0.1:13000/$IP1:13000/" {} +' | |
ssh root@$IP3 'find ~/.local/share/storj/local-network/ -type f -name "config.yaml" -exec sed -i "/minio.access-key/s/127.0.0.1:13000/$IP1:13000/" {} +' | |
ssh root@$IP4 'find ~/.local/share/storj/local-network/ -type f -name "config.yaml" -exec sed -i "/minio.access-key/s/127.0.0.1:13000/$IP1:13000/" {} +' | |
} | |
setsecretkey() { | |
#find ~/.local/share/storj/local-network/ -type f -name "config.yaml" -exec sed -i "/kademlia.bootstrap/s/127.0.0.1:13000/$IP1:13000/" {} + | |
ssh root@$IP2 'find ~/.local/share/storj/local-network/ -type f -name "config.yaml" -exec sed -i "/minio.access-key/s/127.0.0.1:13000/$IP1:13000/" {} +' | |
ssh root@$IP3 'find ~/.local/share/storj/local-network/ -type f -name "config.yaml" -exec sed -i "/minio.access-key/s/127.0.0.1:13000/$IP1:13000/" {} +' | |
ssh root@$IP4 'find ~/.local/share/storj/local-network/ -type f -name "config.yaml" -exec sed -i "/minio.access-key/s/127.0.0.1:13000/$IP1:13000/" {} +' | |
} | |
startsystem() { | |
tmux new-session -d -s network "storj-sim network run" | |
ssh root@$IP2 'tmux new-session -d -s network "storj-sim network run"' | |
ssh root@$IP3 'tmux new-session -d -s network "storj-sim network run"' | |
ssh root@$IP4 'tmux new-session -d -s network "storj-sim network run"' | |
} | |
raise_error() { | |
local error_message="$@" | |
echo "${error_message}" 1>&2; | |
} | |
display_usage() { | |
echo | |
echo "Usage: $0" | |
echo | |
echo " -s, --setup Creates network" | |
echo " -d, --delete Deletes the network" | |
echo " -r, --run Starts the network" | |
echo | |
} | |
commd="$1" | |
if [[ -z $commd ]] ; then | |
raise_error "Expected runtime flag to be present" | |
display_usage | |
else | |
case $commd in | |
-s|--setup) | |
setup | |
;; | |
-d|--delete) | |
destroy | |
;; | |
-r|--run) | |
startsystem | |
;; | |
*) | |
raise_error "Unknown argument: ${commd}" | |
display_usage | |
;; | |
esac | |
fi |
Show Dashboard of individual nodes: storagenode dashboard --address 127.0.0.1:14001
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
run it like:
bash ./script.sh -s