11#! /usr/bin/env bash
22
3- DBURL=" https://s3.us-east-2.amazonaws.com/node-dbs.chainweb.com/db-chainweb-node-ubuntu.18.04-latest.tar.gz"
4- DBDIR=" /data/chainweb-db"
3+ DBDIR=" /data/chainweb-db/0"
4+ # Double check if dbdir already exists, only download bootstrap if it doesn't
5+ if [ -d $DBDIR ]
6+ then
7+ echo " Directory $DBDIR already exists, we will not download any bootstrap, if you want to download the bootstrap you need to delete the folder first"
8+ else
9+ echo " $DBDIR does not exists, lets download the bootstrap"
10+ # Getting Kadena bootstrap from Zel Servers
11+ BOOTSTRAPLOCATIONS[0]=" https://cdn-1.fluxos.network/zelapps/zelshare/getfile/db-chainweb-node-ubuntu.18.04-latest.tar.gz"
12+ BOOTSTRAPLOCATIONS[1]=" https://cdn-2.fluxos.network/db-chainweb-node-ubuntu.18.04-latest.tar.gz"
13+ BOOTSTRAPLOCATIONS[2]=" https://cdn-3.fluxos.network/zelapps/zelshare/getfile/db-chainweb-node-ubuntu.18.04-latest.tar.gz"
14+ BOOTSTRAPLOCATIONS[3]=" https://cdn-4.fluxos.network/zelapps/zelshare/getfile/db-chainweb-node-ubuntu.18.04-latest.tar.gz"
15+
16+ httpstatus=0
17+ retry=0
18+ while [ $httpstatus != " 200" ] && [ " $retry " -lt 3 ]
19+ do
20+ index=$( shuf -i 0-3 -n 1)
21+ echo " Testing bootstrap location ${BOOTSTRAPLOCATIONS[$index]} "
22+ httpstatus=$( curl --write-out ' %{http_code}' --silent --connect-timeout 5 --head --output /dev/null ${BOOTSTRAPLOCATIONS[$index]} )
23+ echo " Http status $httpstatus "
24+ retry=` expr $retry + 1`
25+ done
526
6- #
7-
8- # Install database
9- mkdir -p " $DBDIR /0" && \
10- curl " $DBURL " | tar -xzC " $DBDIR /0"
27+ if [ $httpstatus == " 200" ]
28+ then
29+ echo " Bootstrap location valid"
30+ echo " Downloading bootstrap and extract it to $DBDIR "
31+ # Install database
32+ mkdir -p " $DBDIR " && \
33+ curl " ${BOOTSTRAPLOCATIONS[$index]} " | tar -xzC " $DBDIR "
1134
35+ echo " Bootstrap downloaded and extracted"
36+ else
37+ echo " None bootstrap was found, will download blockchain from node peers"
38+ fi
39+ fi
0 commit comments