forked from Rikj000/MoniGoMani
-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer.sh
executable file
·300 lines (252 loc) · 9.27 KB
/
installer.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
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
#!/bin/bash
# === Description ======================================================================================================
#
# This file contains the installation procedure to get up and running with Freqtrade and the MoniGoMani HyperStrategy.
#
# === Requirements =====================================================================================================
#
# - UNIX Distro, macOS, or a POSIX compliant WSL Distro (sh, bash, command, mktemp, pwd, rm, /dev/null)
# - Python 3.8+
# - Git
# - Pip3 python package manager
#
# Windows Specific Notes:
# This script has been made with the intention to run on UNIX systems and it makes use of UNIX command line tools..
# However if you really have no other option, it should also be able to run under WSL (Windows Subsystem for Linux)!
# - See for installation: https://docs.microsoft.com/en-us/windows/wsl/install-win10
# - Then change 'sh' to 'bash': https://unix.stackexchange.com/a/442517
#
# === Usage ============================================================================================================
#
# /usr/bin/env sh <(curl -s "https://raw.githubusercontent.com/Rikj000/MoniGoMani/development/installer.sh")
#
# === Settings =========================================================================================================
INSTALL_FOLDER_NAME="freqtrade-mgm" # By default the folder will be created under the current working directory
MGM_REPO_URL="https://github.com/Rikj000/MoniGoMani.git"
MGM_BRANCH="development"
MGM_COMMIT=""
# ======================================================================================================================
usage() {
cat << EOF
Usage:
/usr/bin/env sh installer.sh [options]
Example:
/usr/bin/env sh installer.sh --dir="./targetdir" --mgm_branch="feature/xyz" --mgm_commit="abcd1337"
Optional options:
-h, --help Show this help.
--dir=<path> Path to directory to install Freqtrade with MoniGoMani.
Will be created or overwritten when it's existing.
--mgm_url=<url> URL to Git repository. (eg. https://github.com/Rikj000/MoniGoMani.git)
--mgm_branch=<branch> Specific branch to checkout from Git repository. (eg. development)
--mgm_commit=<commit hash> Specific commit hash to checkout from Git repository.
(Note: will skip --mgm_branch if set)
--dev-break Break before launching MGM-Hurry
EOF
exit 0
}
CURRENT_DIR=$(pwd)
INSTALL_DIR="$CURRENT_DIR/$INSTALL_FOLDER_NAME"
# ANSI text coloring
BLUE='\033[94m'
CYAN='\033[0;36m'
DARKCYAN='\033[36m'
GREEN='\033[0;32m'
PURPLE='\033[95m'
RED='\033[0;31m'
WHITE='\033[1;37m'
YELLOW='\033[1;33m'
NOCOLOR='\033[0m'
UNDERLINE='\033[4m'
BOLD='\033[1m'
END='\033[m'
# Loop through arguments and process them
DEV_BREAK="false"
for arg in "$@"
do
case $arg in
--dir=*)
INSTALL_DIR="${arg#*=}"
shift
;;
--mgm_url=*)
MGM_REPO_URL="${arg#*=}"
shift
;;
--mgm_branch=*)
MGM_BRANCH="${arg#*=}"
shift
;;
--mgm_commit=*)
MGM_COMMIT="${arg#*=}"
shift
;;
--dev-break)
DEV_BREAK="true"
shift
;;
-h|--help)
usage
shift
;;
*)
echo ""
echo -e "${RED} 🙉 installer.sh - Illegal argument(s) used!${END}"
echo ""
echo " Please see the 'installer.sh --help' output below for the correct usage:"
usage
shift # Remove generic argument from processing
;;
esac
done
##################
confirm() {
local _prompt _default _response
_prompt="Are you sure?"
if [ "$1" ]; then _prompt="$1"; fi
_prompt2="$_prompt [y/n]"
if [ "$2" ]; then _prompt2="$_prompt $2"; fi
# Loop forever until the user enters a valid response (Y/N or Yes/No).
while true; do
read -r -p " $_prompt2
" _response
case "$_response" in
[Yy][Ee][Ss]|[Yy]) # Yes or Y (case-insensitive).
REPLY="0"
return $REPLY
;;
[Nn][Oo]|[Nn]) # No or N.
REPLY="1"
return $REPLY
;;
[Hh]) # H or h. H stands for Half.
REPLY="2"
return $REPLY
;;
*) # Anything else (including a blank) is invalid.
;;
esac
done
}
do_exit() {
echo " cancel."
echo ""
echo -e "${WHITE} 😽 KTHXBAI ${END}"
echo ""
exit 1
}
trap do_exit SIGINT
echo ""
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${END}"
echo ""
echo -e "${WHITE} ⛱️ Welcome aboard! Let's get started ...${END}"
echo ""
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${END}"
echo ""
echo ""
confirm "👉 MoniGoMani will automatically share test results created with it's community, are you okay with this?" "(y/n)"
if [ "$REPLY" == "1" ] # 1 = False, why shell why..
then
echo -e "${RED} Aborting installation... (This project is only intended for users who seek to contribute to the MGM community)${END}"
do_exit
exit 1
fi
echo ""
echo -e "${WHITE} 🚦 Requirements check${END}"
echo -e "${WHITE} ======================${END}"
echo ""
# Ensure that python3 is installed
command -v python3 >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo -e "${RED} 🙉 Python3 is not installed. Can't proceed. See: https://realpython.com/installing-python/${END}"
exit 1
fi
echo -e "${GREEN} ✅ Python3 is installed.${END}"
# Ensure that pip3 is installed
command -v pip3 >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo -e "${RED} 🙉 Pip3 is not installed. Can't proceed. See: https://pypi.org/project/pip/${END}"
exit 1
fi
echo -e "${GREEN} ✅ Pip3 is installed.${END}"
# Ensure that python3-venv is installed
OS=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
if [ "$OS" == "\"Ubuntu\"" -o "$OS" == "\"Debian\"" ]; then
VENV_PACKAGE_NAME="`readlink -f $(which python3) | awk -F'/' '{print $NF}'`-venv"
dpkg -s $VENV_PACKAGE_NAME | grep "ok installed" >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo -e "${RED} 🙉 Python3-venv is not installed. Can't proceed. install it with: sudo apt-get install ${VENV_PACKAGE_NAME}${END}"
exit 1
fi
echo -e "${GREEN} ✅ Python3-venv is installed.${END}"
fi
# Ensure that git is installed
command -v git >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo -e "${RED} 🙉 Git is not installed. Can't proceed. See: https://gist.github.com/derhuerst/1b15ff4652a867391f03${END}"
exit 1
fi
echo -e "${GREEN} ✅ Git is installed.${END}"
# Ensure that cURL is installed
command -v curl >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo -e "${RED} 🙉 cURL is not installed. Can't proceed. See: https://www.tecmint.com/install-curl-in-linux/${END}"
exit 1
fi
echo -e "${GREEN} ✅ cURL is installed.${END}"
# Ensure that expect is installed
command -v expect >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo -e "${RED} 🙉 Expect is not installed. Can't proceed. See: https://core.tcl-lang.org/expect/index${END}"
exit 1
fi
echo -e "${GREEN} ✅ Expect is installed.${END}"
# ToDo: Remove after updating Freqtrade (There TA-Lib installation process is improved)
# Ensure that TA-Lib (C dependency package) is installed
command -v ta-lib-config >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo -e "${RED} 🙉 TA-Lib (C dependency package) is not installed. Can't proceed. See: https://github.com/mrjbq7/ta-lib#dependencies${END}"
exit 1
fi
echo -e "${GREEN} ✅ TA-Lib (C dependency package) is installed.${END}"
echo ""
confirm "👉 Are you ready to proceed?" "(y/n)"
if [ "$REPLY" == "1" ] # 1 = False, why shell why..
then
do_exit
exit 1
fi
echo ""
echo ""
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${END}"
echo -e "${WHITE} ⚙️ Downloading required files...${END}"
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${END}"
echo ""
git clone -n "$MGM_REPO_URL" "$INSTALL_DIR/monigomani"
if [ "$MGM_COMMIT" != "" ]; then
cd "$INSTALL_DIR/monigomani" && git checkout -b "detached_by_installer" "$MGM_COMMIT"
else
cd "$INSTALL_DIR/monigomani" && git checkout "$MGM_BRANCH"
fi
if [ "$DEV_BREAK" == "true" ]; then
echo ""
confirm "👉 Are you ready to proceed?" "(y/n)"
if [ "$REPLY" == "1" ] # 1 = False, why shell why..
then
do_exit
exit 1
fi
fi
echo ""
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${END}"
echo -e "${WHITE} ⚙️ Installing dependency packages...${END}"
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${END}"
echo ""
cd "$INSTALL_DIR" && pip3 install -r ./monigomani/requirements-mgm.txt && python3 ./monigomani/mgm-hurry up
echo ""
echo ""
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${END}"
echo ""
echo -e "${CYAN} 🎉 You are all set! We hope you enjoy your ride.${END}"
echo ""
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${END}"
echo ""