-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
executable file
·74 lines (63 loc) · 2.43 KB
/
start.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
#!/bin/sh
cd $ERIS/dapps/hellohugo
echo ""
echo ""
echo "My environment good sir:"
# this is here as I find it helpful for debugging, feel free to remove
printenv
echo ""
echo ""
echo "Am fetching the genesis block and catching up the chain."
echo ""
# first we need to fetch from the blockchain deployed via the
# erisdb container (that is a raw, no contracts, no genDoug
# chain).
epm fetch --checkout --name hellohugo helloworldmaster:15256
# the sleep is here to allow epm run to connect to the peer
# and pull the chain.
epm --log ${LOG_LEVEL:=3} run & sleep 2 && kill $(epm plop pid)
# Ensure unique key_sessions && set default local port and local_host (binding these
# to hostname via env vars so that the host which the peer broadcasts will operate
# properly and the peers can find each other as linked containers).
key_session="$(strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 10 | tr -d '\n' ; echo)"
epm config key_session:${KEY_SESSION:=$key_session}
epm config local_host:0.0.0.0 local_port:15254
# when connecting to a remote chain these are the necessary minimums
remote_host="helloworldmaster"
remote_port="15254"
epm config remote_host:$remote_host remote_port:$remote_port use_seed:true
# now its time to deploy the contracts on
# the checked out chain.
cd contracts && epm --log 4 deploy && cd ..
# another small catchup command to make the chain plays nice
# post deployment
epm --log ${LOG_LEVEL:=3} run & sleep 2 && kill $(epm plop pid)
# Capture the primary variables
BLOCKCHAIN_ID=$(epm plop chainid)
if [ -z $ROOT_CONTRACT ] || [ $ROOT_CONTRACT = "" ]
then
ROOT_CONTRACT=$(epm plop vars | cut -d : -f 2)
fi
echo ""
echo ""
echo "Configuring package.json with BLOCKCHAIN_ID ($BLOCKCHAIN_ID) and "
echo "ROOT_CONTRACT ($ROOT_CONTRACT) and "
echo "PEER_SERVER ($remote_host:$remote_port)"
mv package.json /tmp/
jq '.module_dependencies[0].data |= . * {peer_server_address: "'$remote_host:$remote_port'", blockchain_id: "'$BLOCKCHAIN_ID'", root_contract: "'$ROOT_CONTRACT'"}' /tmp/package.json \
> $ERIS/dapps/hellohugo/package.json
echo ""
echo ""
echo "My package.json now looks like this."
# this is here for debugging, feel free to remove
cat $ERIS/dapps/hellohugo/package.json
echo ""
echo ""
echo "My chain config now looks like this."
epm plop config
# put the helloworld DApp in focus
echo ""
echo ""
echo "Starting up! (Wheeeeeee says the marmot)"
sleep 5 && curl http://localhost:3000/admin/switch/hellohugo &
decerver