forked from acidpop/xpebot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.sh.ori
executable file
·70 lines (59 loc) · 1.39 KB
/
bot.sh.ori
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
#! ./bash
DSM_ACCOUNT="admin"
PYTHON_PATH="/usr/bin/python"
XPEBOT_MAIN="/var/services/homes/$DSM_ACCOUNT/xpebot/main.py"
XPEBOT_CFG_PATH="/var/services/homes/$DSM_ACCOUNT/xpebot/xpebot.cfg"
function ProcChk()
{
PID=`/bin/ps w | /bin/grep "python" | /bin/grep "main.py" | /usr/bin/awk '{print $1}'`
if [ "$PID" ] ; then
printf "%16s : [36m[1mRunning[0m\n" "XPEnology Telegram BOT";
else
printf "%16s : [31m[1mStopped[0m\n" "XPEnology Telegram BOT";
fi;
}
function BOTStart()
{
echo "[36m[1mStarting XPEnology Telegram BOT...[0m"
PID=`/bin/ps w | /bin/grep "python" | /bin/grep "main.py" | /usr/bin/awk '{print $1}'`
if [ "$PID" ]; then
echo "XPEnology Telegram BOT Already Running"
# exit 1
else
$PYTHON_PATH "$XPEBOT_MAIN" "$XPEBOT_CFG_PATH" &
sleep 1
ProcChk
fi
}
function BOTStop()
{
echo "XPEnology Telegram BOT safe stop Trying"
PID=`/bin/ps w | /bin/grep "python" | /bin/grep "main.py" | /usr/bin/awk '{print $1}'`
if [ -z "$PID" ]; then
echo "XPEnology Telegram BOT Already Stop"
# exit 1
else
kill -9 $PID
fi
sleep 1
}
case "$1" in
start)
BOTStart
;;
stop)
BOTStop
ProcChk
;;
restart)
BOTStop
ProcChk
BOTStart
;;
chk)
ProcChk
;;
*)
echo "Usage : `basename $0` [ start | stop | restart | chk ]"
;;
esac