Skip to content

Commit 9fb433b

Browse files
committed
Fix Identation
1 parent 43598a0 commit 9fb433b

File tree

1 file changed

+36
-42
lines changed

1 file changed

+36
-42
lines changed

initialize-db.sh

Lines changed: 36 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,18 @@
66
# timeout is given by TIMEOUT in seconds (default 1.)
77
#
88
# Successive backoffs double the timeout.
9-
function with_backoff {
9+
function with_backoff() {
1010
local max_attempts=${ATTEMPTS-5}
1111
local timeout=${TIMEOUT-1}
1212
local attempt=1
1313
local exitCode=0
1414

15-
while (( $attempt < $max_attempts ))
16-
do
17-
if "$@"
18-
then
15+
while (($attempt < $max_attempts)); do
16+
if "$@"; then
1917
echo "Bootstrap downloaded creating $DBDIR"
2018
mkdir -p "$DBDIR"
2119
echo "Extracting bootstrap to $DBDIR"
22-
tar -xvf bootstrap.tar.gz -C "$DBDIR"
20+
tar -xzvf bootstrap.tar.gz -C "$DBDIR"
2321
rm bootstrap.tar.gz
2422
echo "Bootstrap extract finish"
2523
return 0
@@ -29,12 +27,11 @@ function with_backoff {
2927

3028
echo "Failure! Retrying in $timeout.." 1>&2
3129
sleep $timeout
32-
attempt=$(( attempt + 1 ))
33-
timeout=$(( timeout * 2 ))
30+
attempt=$((attempt + 1))
31+
timeout=$((timeout * 2))
3432
done
3533

36-
if [[ $exitCode != 0 ]]
37-
then
34+
if [[ $exitCode != 0 ]]; then
3835
rm -rf /data/chainweb-db/
3936
echo "Failed for the last time! ($@)" 1>&2
4037
fi
@@ -44,37 +41,34 @@ function with_backoff {
4441

4542
DBDIR="/data/chainweb-db/0"
4643
# Double check if dbdir already exists, only download bootstrap if it doesn't
47-
if [ -d $DBDIR ]
48-
then
49-
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"
44+
if [ -d $DBDIR ]; then
45+
echo "Directory $DBDIR already exists, we will not download any bootstrap, if you want to download the bootstrap you need to delete chainweb-db folder first"
5046
else
51-
echo "$DBDIR does not exists, lets download the bootstrap"
52-
# Getting Kadena bootstrap from Zel Servers
53-
BOOTSTRAPLOCATIONS[0]="https://cdn-1.fluxos.network/zelapps/zelshare/getfile/db-chainweb-node-ubuntu.18.04-latest.tar.gz"
54-
BOOTSTRAPLOCATIONS[1]="https://cdn-2.fluxos.network/db-chainweb-node-ubuntu.18.04-latest.tar.gz"
55-
BOOTSTRAPLOCATIONS[2]="https://cdn-3.fluxos.network/zelapps/zelshare/getfile/db-chainweb-node-ubuntu.18.04-latest.tar.gz"
56-
BOOTSTRAPLOCATIONS[3]="https://cdn-4.fluxos.network/zelapps/zelshare/getfile/db-chainweb-node-ubuntu.18.04-latest.tar.gz"
57-
58-
httpstatus=0
59-
retry=0
60-
while [ $httpstatus != "200" ] && [ "$retry" -lt 3 ]
61-
do
62-
index=$(shuf -i 0-3 -n 1)
63-
echo "Testing bootstrap location ${BOOTSTRAPLOCATIONS[$index]}"
64-
httpstatus=$(curl --write-out '%{http_code}' --silent --connect-timeout 5 --head --output /dev/null ${BOOTSTRAPLOCATIONS[$index]})
65-
echo "Http status $httpstatus"
66-
retry=`expr $retry + 1`
67-
done
47+
echo "$DBDIR does not exists, lets download the bootstrap"
48+
# Getting Kadena bootstrap from Zel Servers
49+
BOOTSTRAPLOCATIONS[0]="https://cdn-1.fluxos.network/zelapps/zelshare/getfile/db-chainweb-node-ubuntu.18.04-latest.tar.gz"
50+
BOOTSTRAPLOCATIONS[1]="https://cdn-2.fluxos.network/db-chainweb-node-ubuntu.18.04-latest.tar.gz"
51+
BOOTSTRAPLOCATIONS[2]="https://cdn-3.fluxos.network/zelapps/zelshare/getfile/db-chainweb-node-ubuntu.18.04-latest.tar.gz"
52+
BOOTSTRAPLOCATIONS[3]="https://cdn-4.fluxos.network/zelapps/zelshare/getfile/db-chainweb-node-ubuntu.18.04-latest.tar.gz"
6853

69-
if [ $httpstatus == "200" ]
70-
then
71-
echo "Bootstrap location valid"
72-
echo "Downloading bootstrap"
73-
# Install database
74-
with_backoff curl --keepalive-time 30 \
75-
-C - \
76-
-o bootstrap.tar.gz "${BOOTSTRAPLOCATIONS[$index]}"
77-
else
78-
echo "None bootstrap was found, will download blockchain from node peers"
79-
fi
80-
fi
54+
httpstatus=0
55+
retry=0
56+
while [ $httpstatus != "200" ] && [ "$retry" -lt 3 ]; do
57+
index=$(shuf -i 0-3 -n 1)
58+
echo "Testing bootstrap location ${BOOTSTRAPLOCATIONS[$index]}"
59+
httpstatus=$(curl --write-out '%{http_code}' --silent --connect-timeout 5 --head --output /dev/null ${BOOTSTRAPLOCATIONS[$index]})
60+
echo "Http status $httpstatus"
61+
retry=$(expr $retry + 1)
62+
done
63+
64+
if [ $httpstatus == "200" ]; then
65+
echo "Bootstrap location valid"
66+
echo "Downloading bootstrap"
67+
# Install database
68+
with_backoff curl --keepalive-time 30 \
69+
-C - \
70+
-o bootstrap.tar.gz "${BOOTSTRAPLOCATIONS[$index]}"
71+
else
72+
echo "None bootstrap was found, will download blockchain from node peers"
73+
fi
74+
fi

0 commit comments

Comments
 (0)