-
Notifications
You must be signed in to change notification settings - Fork 15
/
jabberbot
executable file
·55 lines (49 loc) · 895 Bytes
/
jabberbot
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
#!/bin/bash
is_running() {
PID=`ps -ef | grep runbot.php | grep -v grep | awk {'print $2'}`;
if [ ! -z $PID ]; then
echo $PID;
return 0
fi
return 1
}
start() {
if [ ! -d Log ]; then
mkdir Log;
fi
if [ ! -f Log/JabberBot.log ]; then
touch Log/JabberBot.log;
fi
php Scripts/runbot.php >> Log/JabberBot.log 2>&1
}
case $1 in
start)
if ! is_running; then
start;
echo "Bot Started";
else
echo "Bot is already Running";
fi
;;
stop)
if ! is_running; then
echo "Bot is not running"
else
PID=$(is_running);
kill $PID;
echo "Bot killed"
fi
;;
restart)
if is_running; then
PID=$(is_running);
kill $PID;
echo 'Killed.... pausing'
sleep 5
fi
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
;;
esac