-
Notifications
You must be signed in to change notification settings - Fork 96
/
Copy pathbuild-conf.sh
executable file
·60 lines (49 loc) · 1.45 KB
/
build-conf.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# This script creates the configuration for a Babble testnet with a variable
# number of nodes. It will generate crytographic key pairs and assemble a
# peers.json file in the format used by Babble. The files are copied into
# individual folders for each node so that these folders can be used as the
# datadir that Babble reads configuration from.
set -e
N=${1:-4}
WEBRTC=${2:-false}
DEST=${3:-"$PWD/conf"}
IPBASE=${4:-172.77.5.}
PORT=${5:-1337}
for i in $(seq 1 $N)
do
dest=$DEST/node$i
mkdir -p $dest
echo "Generating key pair for node$i"
docker run \
-u $(id -u) \
-v $dest:/.babble \
--rm mosaicnetworks/babble:latest keygen
echo "$IPBASE$i:$PORT" > $dest/addr
done
PFILE=$DEST/peers.json
echo "[" > $PFILE
for i in $(seq 1 $N)
do
com=","
if [[ $i == $N ]]; then
com=""
fi
printf "\t{\n" >> $PFILE
if "$WEBRTC"; then
printf "\t\t\"NetAddr\":\"$(cat $DEST/node$i/key.pub)\",\n" >> $PFILE
else
printf "\t\t\"NetAddr\":\"$(cat $DEST/node$i/addr)\",\n" >> $PFILE
fi
printf "\t\t\"PubKeyHex\":\"$(cat $DEST/node$i/key.pub)\",\n" >> $PFILE
printf "\t\t\"Moniker\":\"node$i\"\n" >> $PFILE
printf "\t}%s\n" $com >> $PFILE
done
echo "]" >> $PFILE
for i in $(seq 1 $N)
do
dest=$DEST/node$i
cp $DEST/peers.json $dest/
cp $DEST/peers.json $dest/peers.genesis.json
cp $PWD/../src/net/signal/wamp/test_data/cert.pem $dest/cert.pem
done