1
0
mirror of https://github.com/Rikj000/MoniGoMani.git synced 2022-03-06 00:08:05 +03:00

♻️ Refactored installer.sh (Improved OS line colorization support, Updated default command, Added more double quotes to prevent globbing & word splitting, Shortened some lines)

This commit is contained in:
Rik Helsen
2021-08-21 17:36:26 +02:00
parent 5b52c23dc2
commit 460de5a84b
3 changed files with 55 additions and 59 deletions

View File

@@ -43,8 +43,10 @@ Setting it all up requires some knowledge of the entire process, until you found
## Table of Contents
---
- [Installation instructions](#installation-instructions)
- [`mgm-hurry` Command Usage](#mgm-hurry-command-usage)
- [## ⚠️ Disclaimer](#--disclaimer)
- [## Table of Contents](#-table-of-contents)
- [## Installation instructions](#-installation-instructions)
- [## `mgm-hurry` Command Usage](#-mgm-hurry-command-usage)
- [`mgm-hurry --help`](#mgm-hurry---help)
- [`mgm-hurry up`](#mgm-hurry-up)
- [`mgm-hurry install_freqtrade`](#mgm-hurry-install_freqtrade)
@@ -64,11 +66,11 @@ Setting it all up requires some knowledge of the entire process, until you found
- [Options](#options-5)
- [`mgm-hurry start_trader`](#mgm-hurry-start_trader)
- [Option](#option)
- [Example timeranges](#example-timeranges)
- [## Example timeranges](#-example-timeranges)
- [Developer Notes](#developer-notes)
- [Virtual Environment](#Virtual-Environment)
- [Continuous Integration](#Continuous-Integration)
- [Module headers](#Module-headers)
- [### Virtual Environment](#-virtual-environment)
- [### Continuous Integration](#-continuous-integration)
- [### Module headers](#-module-headers)
## Installation instructions
---
@@ -79,7 +81,7 @@ MoniGoMani provides an all-in-one setup tool. It will guide you through the enti
To run the `installer.sh`, just run the following command:
```powershell
bash <(curl -s "https://raw.githubusercontent.com/Rikj000/MoniGoMani/development/installer.sh")
/usr/bin/env sh <(curl -s "https://raw.githubusercontent.com/Rikj000/MoniGoMani/development/installer.sh")
```
After installation all you need to do to get started is run:

View File

@@ -2,14 +2,13 @@
#
######################################################
#
# This file contains the installation procedure to get up and running with
# Freqtrade and the MoniGoMani HyperStrategy.
# 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 Windows WSL distro
# (bash, command, mktemp, pwd, rm, sh, /dev/null)
# (sh, bash, command, mktemp, pwd, rm, /dev/null)
# - Python 3.8+
# - Git
# - Pip3 python package manager
@@ -21,8 +20,8 @@
#
#######################################################
#
# Usage
# bash <(curl -s "https://raw.githubusercontent.com/Rikj000/MoniGoMani/development/installer.sh")
# Usage:
# /usr/bin/env sh <(curl -s "https://raw.githubusercontent.com/Rikj000/MoniGoMani/development/installer.sh")
#
######################################################
@@ -32,10 +31,10 @@ usage() {
cat << EOF
Usage:
bash installer.sh [options]
/usr/bin/env sh installer.sh [options]
Example:
bash installer.sh --dir="./targetdir" --ft_branch="feature/xyz" --mgm_commit="abcd1337"
/usr/bin/env sh installer.sh --dir="./targetdir" --ft_branch="feature/xyz" --mgm_commit="abcd1337"
Optional options:
-h, --help Show this help.
@@ -68,6 +67,15 @@ MGM_COMMIT=""
CWD=`pwd`
# ANSI text coloring
CYAN='\033[0;36m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
WHITE='\033[1;37m'
RED='\033[0;31m'
NOCOLOR='\033[0m'
CLOSE='\033[m'
# Loop through arguments and process them
for arg in "$@"
do
@@ -107,9 +115,9 @@ do
;;
*)
echo ""
echo "installer.sh -- illegal argument(s)"
echo -e "${RED} 🙉 installer.sh - Illegal argument(s) used!${CLOSE}"
echo ""
echo "="
echo " Please see the 'installer.sh --help' output below for the correct usage:"
usage
shift # Remove generic argument from processing
;;
@@ -118,13 +126,6 @@ done
##################
CYAN='\033[0;36m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
WHITE='\033[1;37m'
RED='\033[0;31m'
NC='\033[0m'
confirm() {
local _prompt _default _response
@@ -161,50 +162,50 @@ confirm() {
do_exit() {
echo " cancel."
echo ""
echo "${WHITE} 😽 KTHXBAI "
echo -e "${WHITE} 😽 KTHXBAI ${CLOSE}"
echo ""
exit 1
}
echo ""
echo "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${CLOSE}"
echo ""
echo "${WHITE} ⛱️ Welcome aboard! Let's get started ..."
echo -e "${WHITE} ⛱️ Welcome aboard! Let's get started ...${CLOSE}"
echo ""
echo "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${CLOSE}"
echo ""
echo ""
echo "${WHITE} 🚦 Requirements check"
echo "${WHITE} ======================"
echo -e "${WHITE} 🚦 Requirements check${CLOSE}"
echo -e "${WHITE} ======================${CLOSE}"
echo ""
# Ensure that python3 is installed
command -v python3 >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "${RED} 🙉 Python3 is not installed. Can't proceed. See: https://realpython.com/installing-python/"
echo -e "${RED} 🙉 Python3 is not installed. Can't proceed. See: https://realpython.com/installing-python/${CLOSE}"
exit 1
fi
echo "${GREEN} ✅ Python3 is installed."
echo -e "${GREEN} ✅ Python3 is installed.${CLOSE}"
# Ensure that pip3 is installed
command -v pip3 >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "${RED} 🙉 Pip3 is not installed. Can't proceed. See: https://pypi.org/project/pip/"
echo -e "${RED} 🙉 Pip3 is not installed. Can't proceed. See: https://pypi.org/project/pip/${CLOSE}"
exit 1
fi
echo "${GREEN} ✅ Pip3 is installed."
echo -e "${GREEN} ✅ Pip3 is installed.${CLOSE}"
# Ensure that git is installed
command -v git >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "${RED} 🙉 Git is not installed. Can't proceed. See: https://gist.github.com/derhuerst/1b15ff4652a867391f03"
echo -e "${RED} 🙉 Git is not installed. Can't proceed. See: https://gist.github.com/derhuerst/1b15ff4652a867391f03${CLOSE}"
exit 1
fi
echo "${GREEN} ✅ Git is installed."
echo -e "${GREEN} ✅ Git is installed.${CLOSE}"
echo ""
confirm "👉 Are you ready to proceed?" "(y/n)"
@@ -218,40 +219,33 @@ fi
echo ""
echo ""
echo "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "${WHITE} ⚙️ Downloading MGM-Hurry..."
echo "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${CLOSE}"
echo -e "${WHITE} ⚙️ Downloading MGM-Hurry...${CLOSE}"
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${CLOSE}"
echo ""
git clone -n "$MGM_REPO_URL" "$INSTALL_DIR"
if [ "$MGM_COMMIT" != "" ]; then
cd $INSTALL_DIR \
&& git checkout -b "detached_by_installer" "$MGM_COMMIT" \
&& cd $CWD
cd "$INSTALL_DIR" && git checkout -b "detached_by_installer" "$MGM_COMMIT" && cd "$CWD"
else
cd $INSTALL_DIR \
&& git checkout "$MGM_BRANCH" \
&& cd $CWD
cd "$INSTALL_DIR" && git checkout "$MGM_BRANCH" && cd "$CWD"
fi
echo ""
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "${WHITE} ⚙️ Installing MGM-Hurry..."
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${CLOSE}"
echo -e "${WHITE} ⚙️ Installing MGM-Hurry...${CLOSE}"
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${CLOSE}"
echo ""
cd $INSTALL_DIR && \
pip install -r requirements.txt && \
python3 ./mgm-hurry up
cd "$INSTALL_DIR" && pip install -r requirements.txt && python3 ./mgm-hurry up
echo ""
echo ""
echo "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${CLOSE}"
echo ""
echo " 🎉 ${CYAN}You are all set! We hope you enjoy your ride."
echo " 🎉 ${CYAN}You are all set! We hope you enjoy your ride.${CLOSE}"
echo ""
echo "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo -e "${WHITE}~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~${CLOSE}"
echo ""

View File

@@ -115,25 +115,25 @@ class FreqtradeCli:
:return bool: True if install_type is docker or Freqtrade is found. False otherwise.
"""
if self.install_type is None:
self.cli_logger.warning('FreqtradeCli::installation_exists() failed. No install_type.')
self.cli_logger.warning('FreqtradeCli - installation_exists() failed. No install_type.')
return False
# Well if install_type is docker, we return True because we don't verify if docker is installed
if self.install_type == 'docker':
self.cli_logger.debug(
'FreqtradeCli::installation_exists() succeeded because install_type is set to docker.')
'FreqtradeCli - installation_exists() succeeded because install_type is set to docker.')
return True
if self.freqtrade_binary is None:
self.cli_logger.warning('FreqtradeCli::installation_exists() failed. No freqtrade_binary.')
self.cli_logger.warning('FreqtradeCli - installation_exists() failed. No freqtrade_binary.')
return False
if self.install_type == 'source':
self.cli_logger.debug('FreqtradeCli::installation_exists() install_type is "source".')
self.cli_logger.debug('FreqtradeCli - installation_exists() install_type is "source".')
if os.path.exists('{0}/.env/bin/freqtrade'.format(self.basedir)):
return True
self.cli_logger.warning('FreqtradeCli::installation_exists() failed. '
self.cli_logger.warning('FreqtradeCli - installation_exists() failed. '
'Freqtrade binary not found in {0}/.env/bin/freqtrade.'.format(self.basedir))
return False