forked from DeckerSU/komodo-explorers-install
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-explorer.sh
executable file
·145 lines (125 loc) · 3.93 KB
/
install-explorer.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
#
# (c) Decker, 2018
#
# Additional info:
#
# If previous installation of all explorers failure in some reasons, plz remove *-explorer folders, *-explorer-start.sh files,
# and node_modules folder before you run ./install-explorer.sh again (!). It will prevent from uncomplete installation errors.
#
# https://askubuntu.com/questions/558280/changing-colour-of-text-and-background-of-terminal
STEP_START='\e[1;47;42m'
STEP_END='\e[0m'
CUR_DIR=$(pwd)
echo Current directory: $CUR_DIR
echo -e "$STEP_START[ Step 1 ]$STEP_END Installing dependencies"
sudo apt --yes install git
sudo apt --yes install build-essential pkg-config libc6-dev libevent-dev m4 g++-multilib autoconf libtool libncurses5-dev unzip git python zlib1g-dev wget bsdmainutils automake libboost-all-dev libssl-dev libprotobuf-dev protobuf-compiler libqt4-dev libqrencode-dev libdb++-dev ntp ntpdate
sudo apt --yes install libcurl4-gnutls-dev
sudo apt --yes install curl screen
echo -e "$STEP_START[ Step 3 ]$STEP_END Installing NodeJS and Bitcore Node"
# install nodejs, n and other stuff
sudo apt --yes install libsodium-dev npm
sudo apt --yes install libzmq3-dev
# install nvm
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
# switch node setup with nvm
nvm install v4
npm install git+https://[email protected]/StakedChain/bitcore-node-komodo # npm install bitcore
# Start ports
rpcport=8232
zmqport=8332
webport=3001
# now we need to create assets configs for komodod and create explorers for each asset
ac_json=$(curl https://raw.githubusercontent.com/StakedChain/StakedNotary/master/assetchains.json 2>/dev/null)
echo $ac_json | jq .[] > /dev/null 2>&1
outcome=$(echo $?)
if [[ $outcome != 0 ]]; then
echo -e "\033[1;31m ABORTING!!! assetchains.json is invalid, Help Human! \033[0m"
exit
fi
echo $ac_json > assetchains.json
if [[ -z $1 ]]; then
specificchain=0
else
specificchain=$1
fi
listassetchains () {
if [[ $specificchain = "0" ]]; then
./listassetchains.py
else
echo $specificchain
fi
}
listassetchains | while read i; do
echo -e "$STEP_START[ Step 4.$i ]$STEP_END Preparing $i"
rpcport=$((rpcport+1))
zmqport=$((zmqport+1))
webport=$((webport+1))
#printf "%10s: rpc.$rpcport zmq.$zmqport web.$webport\n" $i
mkdir -p $HOME/.komodo/$i
touch $HOME/.komodo/$i/$i.conf
cat <<EOF > $HOME/.komodo/$i/$i.conf
server=1
whitelist=127.0.0.1
txindex=1
addressindex=1
timestampindex=1
spentindex=1
zmqpubrawtx=tcp://127.0.0.1:$zmqport
zmqpubhashblock=tcp://127.0.0.1:$zmqport
rpcallowip=127.0.0.1
rpcport=$rpcport
rpcuser=bitcoin
rpcpassword=local321
uacomment=bitcore
showmetrics=0
EOF
$CUR_DIR/node_modules/bitcore-node-komodo/bin/bitcore-node create $i-explorer
cd $i-explorer
$CUR_DIR/node_modules/bitcore-node-komodo/bin/bitcore-node install git+https://[email protected]/StakedChain/insight-api-komodo git+https://[email protected]/StakedChain/insight-ui-komodo
cd $CUR_DIR
cat << EOF > $CUR_DIR/$i-explorer/bitcore-node.json
{
"network": "mainnet",
"port": $webport,
"services": [
"bitcoind",
"insight-api-komodo",
"insight-ui-komodo",
"web"
],
"servicesConfig": {
"bitcoind": {
"connect": [
{
"rpchost": "127.0.0.1",
"rpcport": $rpcport,
"rpcuser": "bitcoin",
"rpcpassword": "local321",
"zmqpubrawtx": "tcp://127.0.0.1:$zmqport"
}
]
},
"insight-api-komodo": {
"rateLimiterOptions": {
"whitelist": ["::ffff:127.0.0.1","127.0.0.1"],
"whitelistLimit": 500000,
"whitelistInterval": 3600000
}
}
}
}
EOF
# creating launch script for explorer
cat << EOF > $CUR_DIR/$i-explorer-start.sh
#!/bin/bash
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
cd $i-explorer
nvm use v4; ./node_modules/bitcore-node-komodo/bin/bitcore-node start
EOF
chmod +x $i-explorer-start.sh
done