-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathguncontrol.sh
executable file
Β·101 lines (92 loc) Β· 4.78 KB
/
guncontrol.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
#!/bin/bash
## GUNCONTROL β’ GUNBOT 3.2 CUSTOM LAUNCHER
## version v0.0.2 / May 2017.
##
##
## Denis Smirnov / [email protected] / densmirnov.com
## Also credits goes to [email protected] for his GunBot Start/Stop Bash Script
##
## BTC: 1denG4FjcXDeGSYeiv65R6Eyi3HWo7R8j
## LTC: Li1ojtx9cwB7SpruVdBAojcUs9j2VLgU6G
## ETH: 0xa4C7fACEFC08e684Cd9043c3e31C86Dfb88DF75a
## LSK: 10061645427951005252L
## -----------------------------------------------
## STARTUP ITEMS
## -----------------------------------------------
export RESET && export BOLD && export RED && export GREEN && export BLUE && export YELLOW && export WHITE && export BOTTOM
RESET=$(tput sgr0) && BOLD=$(tput bold) && RED=$(tput setaf 1) && GREEN=$(tput setaf 2) && BLUE=$(tput setaf 4) && YELLOW=$(tput setaf 3) && WHITE=$(tput setaf 7) && BOTTOM="\n βββββββββββββββββββββββββββββββββββββββββββββββββββββββ \n"
export CMD && export ARCH && export BOTFOLDER && export FILES && export NAME && export NAME1 && export GUNTHY
CMD=$1 && ARCH=$(uname -m) && BOTFOLDER="$(pwd)" && FILES="*-config.js" && GUNTHY=""
## OS DETECTION
## -----------------------------------------------
if [[ "$OSTYPE" == "linux-gnu" && "$ARCH" == "x86_64" ]]; then
GUNTHY="gunthy-linuxx64"
elif [[ "$OSTYPE" == "linux-gnu" && "$ARCH" == "i686" ]]; then
GUNTHY="gunthy-linuxx86"
elif [[ "$OSTYPE" == "darwin"* ]]; then
GUNTHY="gunthy-macos"
else
GUNTHY="Unknown OS"
fi
## MAIN SCRIPT
## -----------------------------------------------
# clear
echo -e "${BLUE}""\nβββββββββββββββββββββββββββββββββββββββββββββββββββββββββ\n${BLUE}β${RESET} ${GREEN}GUNBOT LAUNCHER v0.0.2${RESET} ${BLUE}$(date +%d.%m.%Y\ %H:%M)${RESET} ${BLUE}β\nβββββββββββββββββββββββββββββββββββββββββββββββββββββββββ\n""${RESET}"
if [[ -n "$CMD" ]]; then
## START
## -----------------------------------------------
if [[ "$CMD" == "start" ]]; then
echo -e "${WHITE}"" STARTING GUNBOT...$BOTTOM" "${RESET}"
for f in $FILES
do
echo -e "${WHITE}"" β’ Checking ${YELLOW}$NAME${WHITE}...\t${RESET}\c"
NAME=$(echo "$f"| cut -d'-' -f 2)
if ! screen -list | grep -qw "$NAME"; then
echo -e "${BLUE}"" \t\t\t STOPPED!\n Starting \c""${RESET}"
screen -dmS "$NAME" "${BOTFOLDER}"/"$GUNTHY" "$NAME" poloniex && sleep 0.25
echo -n "${BLUE}...1 ${RESET}" && sleep 0.25
echo -n "${BLUE}...2 ${RESET}" && sleep 0.25
echo -e "${BLUE}...3! ${RESET} ${GREEN}DONE!${RESET}"
else
echo -e "${BLUE}""\t\t\tRUNNING!\n Skipping... ${GREEN}DONE!""${RESET}" && sleep 0.25
fi
done
echo -e "${WHITE}""$BOTTOM ALL PAIRS ARE RUNNING!" "${RESET}"
exit 0
fi
## STOP
## -----------------------------------------------
if [[ "$CMD" == "stop" ]]; then
echo -e "${WHITE}"" STOPPING GUNBOT...$BOTTOM" "${RESET}"
for f in $FILES
do
echo -e "${WHITE} β’ Checking ${YELLOW}$NAME ${WHITE}... \t\t\t${RESET}\c"
NAME=$(echo "$f"| cut -d'-' -f 2)
if ! screen -list | grep -qw "$NAME"; then
echo -e "${BLUE}""\tSTOPPED!\n Skipping... ${GREEN}DONE!""${RESET}" && sleep 0.25
else
echo -e "${BLUE}""\tRUNNING!\n Stopping... ${GREEN}DONE!""${RESET}" && sleep 0.25
screen -S "$NAME" -X quit && sleep 0.25
fi
done
echo -e "${WHITE}""$BOTTOM ALL PAIRS ARE STOPPED!" "${RESET}"
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 "${WHITE}"" RUNNING PAIRS:$BOTTOM" "${RESET}"
$LOOKUP | grep -v grep | grep "SCREEN" | awk '{printf " β’ %-09s\n", $13}'
echo -e "${WHITE}""$BOTTOM" "${RESET}"
exit 0
fi
else
echo -e "${RED}"" COMMAND MISSING$BOTTOM""${RESET}"
echo -e " ${BLUE}Usage: ${WHITE}bash guncontrol.sh [${GREEN}${BOLD} start ${RESET}| ${RED}${BOLD}stop ${RESET}| ${YELLOW}${BOLD}list${RESET} ]${RESET}"
echo -e "${RED}""$BOTTOM" "${RESET}"
exit 0
fi