-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathup.sh
executable file
·83 lines (65 loc) · 2.93 KB
/
up.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
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
docker build --tag ethereum-artifacts .
rm -rf geth-tmp
mkdir geth-tmp
cp -r genesis-template.json geth-tmp/genesis.json
docker run -v $(pwd)/geth-tmp:/geth-tmp ethereum-artifacts \
bash -c '
for i in {1..2}; do
geth account new --datadir /geth-tmp/ --password <(echo password)
done
for keystore in /geth-tmp/keystore/*; do
ACCOUNT_ID=0x$(jq -r ".address" < $keystore)
mv /geth-tmp/genesis.json{,.bak}
cat > /geth-tmp/genesis.json \
<(cat /geth-tmp/genesis.json.bak | jq --arg account_id $ACCOUNT_ID ".alloc |= .+ {(\$account_id): {\"balance\": \"1000000000000000000\"}}")
done
geth init --datadir="/geth-tmp/" /geth-tmp/genesis.json
bootnode --genkey /geth-tmp/bootnode.key
bootnode --writeaddress --nodekey /geth-tmp/bootnode.key > /geth-tmp/bootnode.pub
chown -R 1000:1000 /geth-tmp
'
rm -rf pcf-root
mkdir -p pcf-root/data
cp -r geth-tmp/{geth,keystore,genesis.json} pcf-root/data
docker run -v $(pwd)/pcf-root:/pcf-root ethereum-artifacts \
cp /usr/bin/geth /usr/bin/bootnode /pcf-root
cf push bootnodes -f manifests/bootnode-manifest.yml -p pcf-root/ --no-start
cf push miners -f manifests/miner-manifest.yml -p pcf-root/ --no-start
cf push nodes -f manifests/node-manifest.yml -p pcf-root/ --no-start
BOOTNODE_PORT=33445
BOOTNODE_KEY=$(< geth-tmp/bootnode.key)
cf set-env bootnodes BOOTNODE_PORT $BOOTNODE_PORT
cf set-env bootnodes BOOTNODE_KEY $BOOTNODE_KEY
cf start bootnodes
NETWORK_ID="12345"
BOOTNODE_PUBKEY=$(< geth-tmp/bootnode.pub)
BOOTNODE_IP=$(cf ssh bootnodes -c "hostname --ip-address")
cf set-env miners NETWORK_ID $NETWORK_ID
cf set-env miners BOOTNODE_PORT $BOOTNODE_PORT
cf set-env miners BOOTNODE_PUBKEY $BOOTNODE_PUBKEY
cf set-env miners BOOTNODE_IP $BOOTNODE_IP
cf set-env nodes NETWORK_ID $NETWORK_ID
cf set-env nodes BOOTNODE_PORT $BOOTNODE_PORT
cf set-env nodes BOOTNODE_PUBKEY $BOOTNODE_PUBKEY
cf set-env nodes BOOTNODE_IP $BOOTNODE_IP
cf start miners
cf start nodes
if ! grep -q network-policy <(cf plugins); then
cf install-plugin -f network-policy
fi
cf allow-access miners nodes --protocol udp --port 30303
cf allow-access miners nodes --protocol tcp --port 30303
cf allow-access nodes nodes --protocol udp --port 30303
cf allow-access nodes nodes --protocol tcp --port 30303
cf allow-access nodes miners --protocol udp --port 30303
cf allow-access nodes miners --protocol tcp --port 30303
cf allow-access miners miners --protocol udp --port 30303
cf allow-access miners miners --protocol tcp --port 30303
cf allow-access nodes bootnodes --protocol udp --port $BOOTNODE_PORT
cf allow-access miners bootnodes --protocol udp --port $BOOTNODE_PORT
echo "Mining a block to confirm DAG is created and cluster is up and settled. May take several minutes (expect true):"
cf run-task bootnodes 'geth attach --exec "admin.sleepBlocks(1); miner.stop()" data/geth.ipc && echo INIT_COMPLETE' && cf logs bootnodes | grep -m1 'INIT_COMPLETE'