forked from jagerzhang/CCKiller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cckiller_servicefile
76 lines (69 loc) · 1.47 KB
/
cckiller_servicefile
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
#!/bin/bash
# chkconfig: 35 10 90
# description: CCKiller Service
EXEC_PATH=/usr/local/cckiller
EXEC=cckiller
DAEMON=$EXEC_PATH/$EXEC
PID_FILE=/var/run/$EXEC.pid
test -f /etc/rc.d/init.d/functions && . /etc/rc.d/init.d/functions
if [ ! -f $DAEMON ] ; then
echo "ERROR: $DAEMON not found"
exit 1
else
chmod +x $DAEMON
fi
stop()
{
echo -n "Shutting down $EXEC ..."
ps aux | grep "$DAEMON" | grep -v grep | kill -9 `awk '{print $2}'` >/dev/null 2>&1
rm -f $PID_FILE
sleep 0.5
echo -e " [ \033[36mOK\033[0m ]"
}
start()
{
if [[ -f $PID_FILE ]]
then
echo "CCKiller is Already Running in Backend !"
exit 1
fi
echo -n "Starting $EXEC ..."
$DAEMON --process > /dev/null &
#pidof $EXEC > $PID_FILE
PID=$(ps aux | grep "$DAEMON" | grep -v grep | awk '{print $2}')
if [[ ! -z $PID ]]
then
sleep 0.5
echo $PID > $PID_FILE
echo -e " [ \033[36mOK\033[0m ]"
else
echo " [ \033[31mFailed\033[0m ]"
fi
}
restart()
{
stop
echo
start
}
echo
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
$DAEMON --show
status -p $PID_FILE $DAEMON
;;
*)
echo "Usage: service $EXEC {start|stop|restart|status}"
exit 1
esac
echo
exit $?