Skip to content

Commit

Permalink
Actualización de los scripts para que no se tengan que reiniciar los …
Browse files Browse the repository at this point in the history
…nodos cada vez que se añade un nuevo integrante en la test-net.
  • Loading branch information
Marcos Serradilla Diez committed Dec 12, 2017
1 parent c49a6da commit 97f145d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 30 deletions.
39 changes: 13 additions & 26 deletions scripts/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,6 @@ PWD="$(pwd)"
CONSTELLATION_NODES=$(cat ../data/constellation-nodes.json)
STATIC_NODES=$(cat ../data/static-nodes.json)

update_constellation_nodes() {
NODE_IP="$1"
CONSTELLATION_PORT="$2"
URL=",
\"http://$NODE_IP:$CONSTELLATION_PORT/\"
]"
CONSTELLATION_NODES=${CONSTELLATION_NODES::-2}
CONSTELLATION_NODES="$CONSTELLATION_NODES$URL"
echo "$CONSTELLATION_NODES" > ~/alastria-node/data/constellation-nodes.json
}

update_static_nodes() {
ENODE=",
\"$1\"
]"
STATIC_NODES=${STATIC_NODES::-2}
STATIC_NODES="$STATIC_NODES$ENODE"
echo "$STATIC_NODES" > ~/alastria-node/data/static-nodes.json
}

generate_conf() {
#define parameters which are passed in.
NODE_IP="$1"
Expand Down Expand Up @@ -87,7 +67,7 @@ verbosity = 2
EOF
}

echo "[*] Cleaning up temporary data directories"
echo "[*] Cleaning up temporary data directories."
rm -rf ~/alastria
mkdir -p ~/alastria/data/{keystore,geth,constellation}
mkdir -p ~/alastria/data/constellation/{data,keystore}
Expand All @@ -101,21 +81,28 @@ geth --datadir ~/alastria/data init ~/alastria-node/data/genesis.json
cd ~/alastria/data/geth
bootnode -genkey nodekey
ENODE_KEY=$(bootnode -nodekey nodekey -writeaddress)
echo "ENODE -> ${ENODE_KEY}"
echo "ENODE -> 'enode://${ENODE_KEY}@${CURRENT_HOST_IP}:21000?raftport=41000'"
cd ~
update_static_nodes "enode://${ENODE_KEY}@${CURRENT_HOST_IP}:21000?raftport=41000"
cp ~/alastria-node/data/static-nodes.json ~/alastria/data/static-nodes.json
if [[ "$CURRENT_HOST_IP" == "52.56.69.220" ]]; then
cp ~/alastria-node/data/static-nodes.json ~/alastria/data/static-nodes.json
cp ~/alastria-node/data/static-nodes.json ~/alastria/data/permissioned-nodes.json
fi

echo " Por favor, introduzca como contraseña 'Passw0rd'."
geth --datadir ~/alastria/data account new

echo "[*] Initializing Constellation node"
update_constellation_nodes "${CURRENT_HOST_IP}" "9000"
echo "[*] Initializing Constellation node."
generate_conf "${CURRENT_HOST_IP}" "9000" "$CONSTELLATION_NODES" "${PWD}" > ~/alastria/data/constellation/constellation.conf
cd ~/alastria/data/constellation/keystore
cat ~/alastria/data/passwords.txt | constellation-node --generatekeys=node
echo "______"
cd ~

echo "[*] Initialization was completed successfully."
echo " "
echo " Update DIRECTORY.md from alastria-node repository and send a Pull Request."
echo " The network administrator will send a RAFT_ID file. It will be stored in '~/alastria/data/' directory."
echo " "

set +u
set +e
24 changes: 20 additions & 4 deletions scripts/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@
set -u
set -e

NETID=963252369
CURRENT_HOST_IP="$(dig +short myip.opendns.com @resolver1.opendns.com 2>/dev/null || curl -s --retry 2 icanhazip.com)"

if [[ ! -f ~/alastria/data/RAFT_ID && "$CURRENT_HOST_IP" != "52.56.69.220" ]]; then
echo "[*] The node don't have ~/alastria/data/RAFT_ID file, please:"
echo " "
echo " Update DIRECTORY.md from alastria-node repository and send a Pull Request."
echo " The network administrator will send a RAFT_ID file. It will be stored in '~/alastria/data/' directory."
echo " "
exit
fi
echo "DONE"
exit

NETID=963262369
GLOBAL_ARGS="--networkid $NETID --raft --rpc --rpcaddr 0.0.0.0 --rpcapi admin,db,eth,debug,miner,net,shh,txpool,personal,web3,quorum,raft"

_TIME=$(date +%Y%m%d%H%M%S)
Expand All @@ -13,10 +26,13 @@ sleep 6

echo "[*] Starting quorum node"
PRIVATE_CONFIG=~/alastria/data/constellation/constellation.conf
if ( [ $# -ne 1 ] ); then
nohup geth --datadir ~/alastria/data $GLOBAL_ARGS --rpcport 22000 --port 21000 --raftport 41000 --password ~/alastria/data/passwords.txt 2>> ~/alastria/logs/quorum_"${_TIME}".log &
if [ -f ~/alastria/data/RAFT_ID ]; then
mapfile -t RAFT_ID <~/alastria/data/RAFT_ID
nohup geth --datadir ~/alastria/data $GLOBAL_ARGS --permissioned --rpcport 22000 --port 21000 --raftport 41000 --raftjoinexisting $RAFT_ID 2>> ~/alastria/logs/quorum_"${_TIME}".log &
else
nohup geth --datadir ~/alastria/data $GLOBAL_ARGS --rpcport 22000 --port 21000 --raftport 41000 --unlock 0 --password ~/alastria/data/passwords.txt 2>> ~/alastria/logs/quorum_"${_TIME}".log &
if [[ "$CURRENT_HOST_IP" == "52.56.69.220" ]]; then
nohup geth --datadir ~/alastria/data $GLOBAL_ARGS --permissioned --rpcport 22000 --port 21000 --raftport 41000 --unlock 0 --password ~/alastria/data/passwords.txt 2>> ~/alastria/logs/quorum_"${_TIME}".log &
fi
fi

set +u
Expand Down

0 comments on commit 97f145d

Please sign in to comment.