-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathbot
executable file
·66 lines (53 loc) · 2.01 KB
/
bot
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
#!/usr/bin/env sh
set -e
e_error() {
printf "$(tput setaf 1)✖ %s$(tput sgr0)\n" "$@"
}
FULL_PATH=$(realpath $0)
SCRIPT_DIRECTORY=$(dirname $FULL_PATH)
MANAGER_TMP_DIRECTORY="/tmp/freqtrade-manager"
if [ ! -d "${MANAGER_TMP_DIRECTORY}" ]; then
mkdir ${MANAGER_TMP_DIRECTORY}
fi
if [ -z "${BOT_CONFIG_DIRECTORY}" ]; then
BOT_CONFIG_DIRECTORY=${PWD}
fi
if [ ! -f "${BOT_CONFIG_DIRECTORY}/manager.yaml" ]; then
e_error "You seem not to be into a Freqtrade Manager working directory. Please take a look at the documentation."
exit
fi
if [ -t 1 ]; then
DOCKER_TTY_ARGS="-it"
else
DOCKER_TTY_ARGS="-i"
fi
# Development (from PHP app sources)
if [ -f "${SCRIPT_DIRECTORY}/composer.json" ]; then
if [ -d ${MANAGER_TMP_DIRECTORY}/resources ]; then
rm -rf ${MANAGER_TMP_DIRECTORY}/resources
fi
if [[ -f ${MANAGER_TMP_DIRECTORY}/resources || -L ${MANAGER_TMP_DIRECTORY}/resources ]]; then
rm ${MANAGER_TMP_DIRECTORY}/resources
fi
if [ -L ${MANAGER_TMP_DIRECTORY}/resources ]; then
${MANAGER_TMP_DIRECTORY}/resources
fi
ln -s ${SCRIPT_DIRECTORY}/resources ${MANAGER_TMP_DIRECTORY}/resources
docker run ${DOCKER_TTY_ARGS} --rm --name "freqtrade-manager-$(uuidgen)" --privileged=true \
-e HOST_CONFIGURATION_DIRECTORY=${BOT_CONFIG_DIRECTORY} \
-e HOST_BOT_SCRIPT_PATH=${FULL_PATH} \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ${BOT_CONFIG_DIRECTORY}:/config:rw \
-v ${MANAGER_TMP_DIRECTORY}/:/tmp/manager/:rw \
-v ${SCRIPT_DIRECTORY}:/app \
ph3nol/freqtrade-manager $*
# Staging (from Docker image)
else
docker run ${DOCKER_TTY_ARGS} --rm --name "freqtrade-manager-$(uuidgen)" --privileged=true \
-e HOST_CONFIGURATION_DIRECTORY=${BOT_CONFIG_DIRECTORY} \
-e HOST_BOT_SCRIPT_PATH=${FULL_PATH} \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ${BOT_CONFIG_DIRECTORY}:/config:rw \
-v ${MANAGER_TMP_DIRECTORY}/:/tmp/manager/:rw \
ph3nol/freqtrade-manager $*
fi