-
Notifications
You must be signed in to change notification settings - Fork 347
/
add-p2p-nodes.sh
executable file
·39 lines (34 loc) · 1.31 KB
/
add-p2p-nodes.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Helper script to add/update p2p peers from the permissioned-nodes.json (or static-nodes.js)
# in the case where the p2p layer gets disconnected, or when adding new nodes to the network:
# $> geth attach http://localhost:22000
# > admin.peers
# []
#
# This script can be run to add all the peers in the permissioned-nodes.json file.
# usage:
# ./add-p2p-nodes.sh $PATH/TO/permissioned-nodes.json
PERMISSION_FILE="qdata/dd1/permissioned-nodes.json"
QUORUM_DATA_DIR="qdata"
if [ ! -z $1 ]; then
PERMISSION_FILE=$1
else
echo
echo " Using default permission file $PERMISSION_FILE."
echo " Base Quorum data directory is $QUORUM_DATA_DIR."
echo " to use a different permission file, pass it in as an arg:"
echo
echo " > ./add-p2p-nodes.sh PATH/TO/permissioned-nodes.json"
echo
fi
ADD_PEERS=$(sed -e 's/\[//g' -e 's/\]//g' -e 's/^ *//g' -e '/^$/d' -e 's/,//g' -e 's/^/admin.addPeer(/g' -e 's/,/;/g' -e 's/"$/");/g' $PERMISSION_FILE)
#echo $ADD_PEERS
#ADD_PEERS=$(cat $PERMISSION_FILE | jq '.[]' | sed -e 's/^/admin.addPeer(/g' -e 's/$/)/g')
echo
echo " Adding peers from permission file $PERMISSION_FILE"
echo
echo "$ADD_PEERS" | while read -r addPeer; do
for i in {1..7}; do
PRIVATE_CONFIG=$QUORUM_DATA_DIR/c$i/tm.ipc geth --exec $addPeer attach ipc:$QUORUM_DATA_DIR/dd$i/geth.ipc > /dev/null
done
done