-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
install
175 lines (152 loc) · 7.03 KB
/
install
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/bin/bash -l
#$ -S /bin/bash
#$ -N $1
# Environment variables
red=`tput setaf 1`
purple=`tput setaf 93`
blue=`tput setaf 21`
green=`tput setaf 2`
yellow=`tput setaf 214`
reset=`tput sgr0`
case $1 in
Testnet|t|testnet|T)
echo "Starting Testnet IoTeX Full Node Build System"
MODE_flag="Testnet" ;;
Mainnet|m|mainnet|M)
echo "Starting Mainnet IoTeX Full Node Build System"
MODE_flag="Mainnet" ;;
*)
echo "${red}Use <./install m> for Mainnet or <./install t> for Testnet ${reset}"
exit 0 ;;
esac
echo "|---------------------------------------------|"
echo "| |"
echo "| starting IoTeX Full Node Build System |"
echo "| |"
echo "|---------------------------------------------|"
# Environment variables
DEBUG_flag=``
DOWNLOADDATA_flag=``
COST_flag="minimal"
latestversion=$(curl --silent "https://api.github.com/repos/iotexproject/iotex-core/releases/latest" | grep -Po '"tag_name": "\K.*?(?=")')
export JRPC=$PWD
export JRPC_version=$latestversion
case $2 in
D|d|Debug|debug)
echo "Debug mode selected"
DEBUG_flag="" ;;
R|r|Release|release)
echo "Release mode selected"
DEBUG_flag="-d" ;;
*)
echo "No mode selected, defaulting to Release"
DEBUG_flag="" ;;
esac
case $3 in
Y|y|Yes|yes)
echo "Downloading latest data"
DOWNLOADDATA_flag="true" ;;
N|n|No|no)
echo "Not downloading latest data"
DOWNLOADDATA_flag="false" ;;
*)
echo "No selection made, defaulting to No"
DOWNLOADDATA_flag="false" ;;
esac
case $MODE_flag in
Mainnet|Testnet)
# make directory for JRPC log files
mkdir -p $JRPC/log/$MODE_flag/JRPC
LOGFILE=$JRPC/log/$MODE_flag/JRPC/message.log
echo -e "\n**************" | tee -a "$LOGFILE"
echo "$(date)" | tee -a "$LOGFILE"
echo "Mode: $MODE_flag" | tee -a "$LOGFILE"
case "$DEBUG" in
D|d) echo "Debug: Debug" | tee -a "$LOGFILE" ;;
R|r) echo "Debug: Release" | tee -a "$LOGFILE" ;;
*) echo "Debug: $DEBUG_flag" ;;
esac
echo "Additional Costs (trial period free): $COST_flag" | tee -a "$LOGFILE"
echo "Download Data: $DOWNLOADDATA_flag" | tee -a "$LOGFILE"
echo -e "*************\n" | tee -a "$LOGFILE" ;;
*)
echo -e "\n**************"
echo "$(date)"
echo "Mode: $MODE_flag"
case "$DEBUG" in
D|d) echo "Debug: Debug" ;;
R|r) echo "Debug: Release" ;;
*) echo "Debug: $DEBUG_flag" ;;
esac
echo "Additional Costs (trial period free): $COST_flag"
echo "Download Data: $DOWNLOADDATA_flag"
echo -e "*************\n"
echo "${red}Please review your choices and make sure you make a valid selection. Terminating${reset}"
exit 0 ;;
esac
# Set URL to get testnet or mainnet data, depending on user's choice
URL=https://t.iotex.me/$MODE_flag-data-with-idx-latest
# Confirm if we continue with the installation of the latest version - and inform the user of the download data filesize
case $DOWNLOADDATA_flag in
true)
echo "This will download ${blue}$(curl -sIL https://t.iotex.me/$MODE_flag-data-with-idx-latest | grep -i x-goog-stored-content-length | awk '{print $2/1024/1024/1024 " GB"}')${reset} from https://t.iotex.me/$MODE_flag-data-with-idx-latest" ;;
false)
echo "This script will attempt to use data located in ${green}$JRPC/data/$MODE_flag/IoTeX${reset}"
echo "If there is no data in this directory, the blockchain will attempt to synchronize from block height 0. You will need to provide your Infura, Pocket or ANKR endpoint in the configuration files" ;;
*)
echo "${red}Not a valid Data Download answer. Terminating${reset}"
exit 0 ;;
esac
echo "We will now install the $MODE_flag IoTeX server node $latestversion"
# Setting up file and folder structure, and extract the downloaded data into it
echo "${green}Creating $JRPC/data/$MODE_flag/IoTeX directory${reset}"
mkdir -p $JRPC/data/$MODE_flag/IoTeX
echo "${green}Creating $JRPC/log/$MODE_flag/IoTeX directory${reset}"
mkdir -p $JRPC/log/$MODE_flag/IoTeX
echo "${green}Creating $JRPC/temp/$MODE_flag/IoTeX directory${reset}"
mkdir -p $JRPC/temp/$MODE_flag/IoTeX
case $COST_flag in
minimal)
echo "${green}Building IoTeX node in minimal cost mode${reset}" ;;
analytics)
echo "${green}Building IoTeX node with additional $COST_flag. Additiona charges may apply. This feature is still in testing phase, and is therefore free.${reset}" ;;
*)
echo "${red}Not a valid Additional Costs mode. Please make a valid selection and try again. Terminating${reset}"
exit 0 ;;
esac
case $MODE_flag in
Mainnet)
# If in future releases IoTeX requires a data patch, uncomment this script to attempt to download the latest patch and install it.
echo "${green}Downloading latest patch${reset}"
curl https://raw.githubusercontent.com/iotexproject/iotex-bootstrap/v1.8.2/trie.db.patch > $JRPC/data/$MODE_flag/IoTeX/trie.db.patch ;;
esac
case $DOWNLOADDATA_flag in
true)
echo "${green}Downloading latest data${reset}"
curl -L -o $JRPC/temp/$MODE_flag/IoTeX/data.tar.gz https://t.iotex.me/$MODE_flag-data-with-idx-latest
echo "${green}Extracting data to temporary directory${reset}"
tar xvf $JRPC/temp/$MODE_flag/IoTeX/data.tar.gz -C $JRPC/temp/$MODE_flag/IoTeX/
echo "${green}Moving data files to the destination directory and cleaning up the $JRPC/temp directory${reset}"
mv $JRPC/temp/$MODE_flag/IoTeX/data/* $JRPC/data/$MODE_flag/IoTeX
rm -r $JRPC/temp/$MODE_flag/IoTeX/data/ ;;
false)
echo "This script will attempt to use data located in ${green}$JRPC/data/$MODE_flag/IoTeX${reset}"
echo "If there is no data in this directory, the blockchain will attempt to synchronize from block height 0. You will need to provide your Infura, Pocket or ANKR endpoint in the configuration files" ;;
# If the node does not start synching from block height 0, it might be due to incorrect Pocket Ethereum Mainnet Tracing endpoint."
# If you do not have any endpoints to use, you can uncomment the below line to download the static poll.db data files, which will overcome the need to connect to Mainnet Ethereum Tracing nodes.
# echo "${green}Downloading latest poll.db file${reset}"
# curl -L https://storage.googleapis.com/blockchain-golden/poll."${MODE_flag,}".tar.gz > $JRPC/temp/$MODE_flag/IoTeX/poll.tar.gz; tar -xzf $JRPC/temp/$MODE_flag/IoTeX/poll.tar.gz -C $JRPC/data/$MODE_flag/IoTeX/ ;;
*)
echo "${red}Not a valid answer. Terminating${reset}"
exit 0 ;;
esac
# Start the build scripts for the iotex-core
case $MODE_flag in
Testnet|Mainnet)
echo "${green}Building the $MODE_flag IoTeX server node${reset}"
echo "${green}Starting docker-compose scripts${reset}"
echo "running command ${purple} docker-compose -p jrpc-"${MODE_flag,}" -f $JRPC/etc/$MODE_flag/Docker/docker-compose.yaml up $DEBUG_flag --no-deps --build${reset}"
docker-compose -p jrpc-"${MODE_flag,}" -f $JRPC/etc/$MODE_flag/Docker/docker-compose.yaml up $DEBUG_flag --no-deps --build ;;
*)
echo "${red}Not a valid mode. Please enter in M for Mainnet or T for Testnet${reset}" ;;
esac