-
Notifications
You must be signed in to change notification settings - Fork 5
/
bot.sh
executable file
·59 lines (54 loc) · 1.17 KB
/
bot.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
#!/bin/sh
# Start/Stop script for Robinhood Bot
#
BOTPID=`ps -ef | grep '/usr/bin/python[3] -u ./core.py' | awk '{ print $2 }'`
start() {
if [ -z "$BOTPID" ]; then
/usr/bin/nohup ./core.py > status.log 2>&1 &
sleep 3
BOTPID=`ps -ef | grep '/usr/bin/python[3] -u ./core.py' | awk '{ print $2 }'`
if [ -z "$BOTPID" ]; then
echo "Unable to start bot."
else
echo "[PID:$BOTPID] Bot started."
fi
else
echo "Bot already running. Did you mean 'restart'?"
fi
}
stop() {
if [ -z "$BOTPID" ]; then
echo "Bot not running."
else
kill $BOTPID
sleep 3
echo "[PID:$BOTPID] Bot stopped."
BOTPID=`ps -ef | grep '/usr/bin/python[3] -u ./core.py' | awk '{ print $2 }'`
fi
}
status() {
if [ -z "$BOTPID" ]; then
echo "Bot not running."
else
echo "[PID:$BOTPID] Bot running."
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: service {start|stop|restart|status}"
exit 1
esac
exit 0