@@ -116,6 +116,22 @@ function deleteOldFile() {
116
116
fi
117
117
}
118
118
119
+ function downloadFile()
120
+ {
121
+ echo " Downloading file: $1 "
122
+ curl -Ss --connect-timeout 10 \
123
+ --max-time 10 \
124
+ --retry 10 \
125
+ --retry-delay 0 \
126
+ --retry-max-time 180 \
127
+ $1 > $2
128
+ response=$?
129
+ if test " $response " ! = " 0" ; then
130
+ echo -e " ${RED} Download of configuration failed with following: $response "
131
+ exit 1
132
+ fi
133
+ }
134
+
119
135
function preDockerCompose() {
120
136
# set monitor home
121
137
IOTEX_MONITOR_HOME=$IOTEX_HOME /monitor
@@ -124,15 +140,15 @@ function preDockerCompose() {
124
140
125
141
export IOTEX_HOME IOTEX_MONITOR_HOME IOTEX_IMAGE
126
142
127
- curl -Ss https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/monitor/docker-compose.yml.gateway > $IOTEX_MONITOR_HOME /docker-compose.yml.gateway
128
- curl -Ss https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/monitor/docker-compose.yml > $IOTEX_MONITOR_HOME /docker-compose.yml.default
129
- curl -Ss https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/monitor/.env > $IOTEX_MONITOR_HOME /.env
143
+ downloadFile " https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/monitor/docker-compose.yml.gateway" " $IOTEX_MONITOR_HOME /docker-compose.yml.gateway"
144
+ downloadFile " https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/monitor/docker-compose.yml" " $IOTEX_MONITOR_HOME /docker-compose.yml.default"
145
+ downloadFile " https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/monitor/.env" " $IOTEX_MONITOR_HOME /.env"
130
146
}
131
147
132
148
function enableMonitor() {
133
149
echo " Download config files for monitor"
134
- curl -Ss https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/monitor/prometheus.yml > $IOTEX_MONITOR_HOME /prometheus.yml
135
- curl -Ss https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/monitor/alert.rules > $IOTEX_MONITOR_HOME /alert.rules
150
+ downloadFile " https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/monitor/prometheus.yml" " $IOTEX_MONITOR_HOME /prometheus.yml"
151
+ downloadFile " https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/monitor/alert.rules" " $IOTEX_MONITOR_HOME /alert.rules"
136
152
}
137
153
138
154
function checkPrivateKey() {
@@ -215,13 +231,13 @@ function determinPrivKey() {
215
231
216
232
function downloadConfig() {
217
233
echo " download new config"
218
- curl -Ss https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/${version} /config_${env} .yaml > $IOTEX_HOME /etc/config.yaml
219
- curl -Ss https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/${version} /genesis_${env} .yaml > $IOTEX_HOME /etc/genesis.yaml
234
+ downloadFile " https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/${version} /config_${env} .yaml" " $IOTEX_HOME /etc/config.yaml"
235
+ downloadFile " https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/${version} /genesis_${env} .yaml" " $IOTEX_HOME /etc/genesis.yaml"
220
236
221
237
# Download patch file
222
238
if [ " ${_ENV_} X" = " mainnetX" ]; then
223
239
echo -e " Downloading the patch file"
224
- curl https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/${version} /trie.db.patch > $IOTEX_HOME /data/trie.db.patch
240
+ downloadFile " https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/${version} /trie.db.patch" " $IOTEX_HOME /data/trie.db.patch"
225
241
fi
226
242
227
243
SED_IS_GNU=0
@@ -340,12 +356,12 @@ function startAutoUpdate() {
340
356
# Download auto-update command
341
357
mkdir -p $IOTEX_HOME /bin
342
358
if [ " $( uname) " X = " Darwin" X ]; then
343
- curl -Ss https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/tools/auto-update/auto-update_darwin-amd64 > $IOTEX_HOME /bin/auto-update || exit 1
359
+ downloadFile " https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/tools/auto-update/auto-update_darwin-amd64" " $IOTEX_HOME /bin/auto-update" || exit 1
344
360
else
345
- curl -Ss https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/tools/auto-update/auto-update_linux-amd64 > $IOTEX_HOME /bin/auto-update || exit 1
361
+ downloadFile " https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/tools/auto-update/auto-update_linux-amd64" " $IOTEX_HOME /bin/auto-update" || exit 1
346
362
fi
347
363
348
- curl -Ss https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/scripts/update_silence.sh > $IOTEX_HOME /bin/update_silence.sh || exit 1
364
+ downloadFile " https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/master/scripts/update_silence.sh" " $IOTEX_HOME /bin/update_silence.sh" || exit 1
349
365
chmod +x $IOTEX_HOME /bin/auto-update $IOTEX_HOME /bin/update_silence.sh
350
366
351
367
# Run background
0 commit comments