This repository has been archived by the owner on Oct 4, 2023. It is now read-only.
forked from drr00t/parity-poa-playground
-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.sh
95 lines (71 loc) · 2.73 KB
/
setup.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
declare -A loc mm mmE mmlog
green=`tput setaf 2`
reset=`tput sgr0`
# cleanup any previous attempts of running this script
docker-compose down
rm -rf parity/config/secret/db.*
rm -rf parity/config/db.*
# get up to speed
docker-compose pull ss1 alice
# setup of 3 secret nodes
for i in {1..3}
do
# generating good config files
loc[$i]=parity/config/secret/ss$i.toml
cp parity/config/secret/ss$i.bak.toml ${loc[$i]}
# create secret accounts
ss[$i]=$(docker run --rm -i -v $PWD/parity/config:/parity/config kryha/parity:secretstore --config ${loc[$i]} account new)
# cutting the 0x
ssx[$i]=$(echo ${ss[$i]}|cut -d "x" -f 2)
# replacing dummy variables with accounts
sed -i '' -e s,"accountx","${ssx[$i]}",g -e "/self_secret/s/^#//g" ${loc[$i]}
# grabbing the enode and server public key from the logs
sslog[$i]=$(timeout 10s docker-compose up ss$i)
ssp[$i]=$(echo "${sslog[$i]}"|grep "SecretStore node:"|cut -d "x" -f 2)
ssE[$i]=$(echo "${sslog[$i]}"|grep "Public node URL:"|cut -d "/" -f 3)
docker kill $(docker ps -q)
done
# setup alice bob and charlie
for i in alice bob charlie;
do
#copy configs
loc[$i]=parity/config/$i.toml
cp parity/config/$i.bak.toml ${loc[$i]}
# create accounts
mm[$i]=$(docker run --rm -i -v $PWD/parity/config:/parity/config kryha/parity:beta --config ${loc[$i]} account new)
# grep enode
mmlog[$i]=$(timeout 10s docker-compose up $i)
mmE[$i]=$(echo "${mmlog[$i]}"|grep "Public node URL:"|cut -d "/" -f 3)
docker kill $(docker ps -q)
done
# replacing dummy variables with accounts, enodes and public addresses
for i in alice bob charlie 1 2 3;
do
# accounts
sed -i '' -e "/validators/s/^#//g" -e "/signer/s/^#//g" \
-e "/account/s/^#//g" -e "/unlock/s/^#//g" \
-e "/bootnodes/s/^#//g" -e "/nodes/s/^#//g" \
-e "s,accountx,${mm[$i]},g" ${loc[$i]}
# echo $i
# echo ${loc[$i]}
for j in alice bob charlie 1 2 3;
do
# enodes and public addresses
sed -i '' -e "s,mmE$j,${mmE[$j]},g" -e "s,ssE$j,${ssE[$j]},g" \
-e s,ssp$j,${ssp[$j]},g ${loc[$i]}
done
done
read -p "Do you want to deploy the acl permissioning contract? (RECOMMENDED) ${green}(y/n)${reset}? " CONT
if [ "$CONT" = "y" ]; then
# deploy acl
pass=$(cat parity/config/secret/alice.pwd)
bash acl.sh ${mm["alice"]} ${mm["bob"]} $pass
#private contract
read -p "Do you want to deploy the example private contract? ${green}(y/n)${reset}? " CONT
if [ "$CONT" = "y" ]; then
bash private.sh ${mm["alice"]} ${mm["bob"]} $pass
else
echo -e "${green}Setup done!${reset}"
fi
fi