forked from densmirnov/guncontrol
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathguncontrol.sh
More file actions
executable file
·108 lines (100 loc) · 3.65 KB
/
guncontrol.sh
File metadata and controls
executable file
·108 lines (100 loc) · 3.65 KB
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
#!/bin/bash
## GUNBOT 3.2 CUSTOM LAUNCHER
## version v0.0.1 / May 2017.
##
##
## Denis Smirnov / densmirnov@me.com / densmirnov.com
##
## BTC: 1denG4FjcXDeGSYeiv65R6Eyi3HWo7R8j
## ETH: 0xa4C7fACEFC08e684Cd9043c3e31C86Dfb88DF75a
## LSK: 10061645427951005252L
## -----------------------------------------------
## STARTUP ITEMS
## -----------------------------------------------
export BOLD && export RED && export GREEN && export BLUE && export YELLOW && export WHITE && export RESET && export CMD && export BOTFOLDER
BOLD=$(tput bold)
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
BLUE=$(tput setaf 4)
YELLOW=$(tput setaf 3)
WHITE=$(tput setaf 7)
RESET=$(tput sgr0)
export CMD && export BOTFOLDER && export FILES && export NAME
CMD=$1
BOTFOLDER="${PWD}"
FILES="*-config.js"
echo -e "\n ${GREEN}${BOLD}GUNBOT LAUNCHER - v0.0.1${RESET} ${BLUE} $(date +%d.%m.%Y\ %H:%M)${RESET}"
echo -e "${GREEN}""==============================================\n""${RESET}"
## OPTIONS
## -----------------------------------------------
if [[ -n "$CMD" ]]; then
## START
## -----------------------------------------------
if [[ "$CMD" == "start" ]]; then
for f in $FILES
do
NAME=$(echo $f| cut -d'-' -f 2)
echo -e "${WHITE}""• Checking if ${YELLOW}$NAME ${WHITE}is running...\t${RESET}\c"
if ! screen -list | grep -qw "$NAME"; then
echo -e "${RED}${BOLD}- NO!${RESET}\c"
echo -n "${BLUE} [ starting ${RESET}"
# screen -dmS $NAME
screen -dmS "$NAME" "${BOTFOLDER}"/gunbot "$NAME" poloniex && sleep 1
echo -n "${BLUE}...1 ${RESET}" && sleep 1
echo -n "${BLUE}...2 ${RESET}" && sleep 1
echo -n "${BLUE}...3 ${RESET}" && sleep 1
echo -n "${BLUE}...4 ${RESET}" && sleep 1
echo -e "${BLUE}...5! ] ${RESET}${GREEN}${BOLD}+ Done!${RESET}\n"
else
echo -e "\t${GREEN}${BOLD}+ YES! ${RESET}\c"
echo -n "${BLUE} [ skipping... ]${RESET}"
echo -e " " && sleep 0.2
fi
done
echo -e " "
echo -e "${GREEN}"" ============================\n""${RESET}"
echo -e "${GREEN}""${BOLD}""Done! All Pairs are running!\n""${RESET}"
exit 0
fi
## STOP
## -----------------------------------------------
if [[ "$CMD" == "stop" ]]; then
for f in $FILES
do
NAME=$(echo $f| cut -d'-' -f 2)
echo -e "${WHITE}• Checking if ${YELLOW}$NAME ${WHITE}is running...\t${RESET}\c"
if ! screen -list | grep -q "$NAME"; then
echo -e "${GREEN}${BOLD}【 NO! 】\t${RESET}\c"
echo -n "${BLUE} [ skipping... ]${RESET}"
echo -e " "
else
echo -e "${RED}${BOLD}【 YES! 】${RESET}"
echo -n "${BLUE}[ exiting... ]${RESET}"
echo -e " "
screen -S "$NAME" -X quit && sleep 0.2
fi
done
echo -e " "
echo -e "${GREEN}""============================""${RESET}"
echo -e "${GREEN}${BOLD}Done! All Pairs are stopped! ${RESET}\n"
exit 0
fi
## LIST
## -----------------------------------------------
if [[ "$CMD" == "list" ]]; then
export LOOKUP && export HEADER && export DIVIDER
LOOKUP="ps aux"
HEADER="%-12b\t%-12s\t%-12b\n"
DIVIDER=${BLUE}"------------"${RESET}
echo -e "${BLUE}""\n STRATEGY" " PAIR" " EXCHANGE""${RESET}"
echo -e "${DIVIDER}" "${DIVIDER}" "${DIVIDER}"
$LOOKUP | grep -v grep | grep -v gunctl | grep "SCREEN" | awk '{printf " %-12s\t %-12s\t %-12s\n",$09,$13,$16}'
exit 0
fi
else
echo -e "${RED}"" COMMAND MISSING!""${RESET}"
echo " "
echo -e " ${BLUE}Usage: ${WHITE}bash guncontrol.sh [${GREEN}${BOLD} start [pair] [exchange]${RESET}, ${RED}${BOLD}stop [pair]${RESET}, ${YELLOW}${BOLD}list${RESET} ]${RESET}\c"
echo " "
exit 0
fi