init 1.22 KB
Newer Older
TonyFord's avatar
TonyFord committed
1
#!/bin/bash
TonyFord's avatar
ts    
TonyFord committed
2
3

# remove containers and volumes
TonyFord's avatar
TonyFord committed
4
docker-compose down -v
TonyFord's avatar
ts    
TonyFord committed
5
6

# initialize database
TonyFord's avatar
TonyFord committed
7
8
9
10
chmod +x ./services/db/create_db.sh
docker-compose up -d db
sleep 20
docker-compose exec -T db /opt/explorer/create_db.sh
TonyFord's avatar
ts    
TonyFord committed
11
12

# create config files and move to correct place
TonyFord's avatar
TonyFord committed
13
14
15
16
17
18
cat ${FAIRCHAINS_CONF} > ./services/faircoin/scripts/fairchains.conf
cat ${FAIRCHAINS_CONF} | sed -e s/netname/\#\ netname/g > ./services/faircoin/scripts/faircoin.conf
export AUTOSTART=0
docker-compose up -d faircoin
docker-compose exec -T faircoin mv -f ./scripts/fairchains.conf .faircoin2/
docker-compose exec -T faircoin mv -f ./scripts/faircoin.conf .faircoin2/
TonyFord's avatar
ts    
TonyFord committed
19
docker-compose exec -T faircoin ./faircoind -disablewallet -daemon
TonyFord's avatar
TonyFord committed
20
21
22
23
24
25
26
27
28
29
30
sleep 180

# wait until blockchain is up-to-date
last=-1
new=0

while [ $new != $last ]
do
  last=$new
  echo $last
  echo "wait.."
TonyFord's avatar
TonyFord committed
31
  sleep 60
TonyFord's avatar
TonyFord committed
32
33
  new=`docker-compose exec -T faircoin ./faircoin-cli getblockcount`
done
TonyFord's avatar
ts    
TonyFord committed
34
35

# start explorer service
36
cat ${CCE_CONF} | sed -e s/MYSQL_USER/${MYSQL_USER}/g -e s/MYSQL_PASSWORD/${MYSQL_PASSWORD}/g > ./services/explorer/cce.conf
37
cat ${SERVER_CONF} > ./services/explorer/server.conf
TonyFord's avatar
TonyFord committed
38
39
docker-compose up -d explorer
sleep 20
TonyFord's avatar
ts    
TonyFord committed
40
41

# first time run of db initialization
TonyFord's avatar
TonyFord committed
42
docker-compose exec -T explorer python3 dbload.py -n -l