-
Notifications
You must be signed in to change notification settings - Fork 0
/
snifferctl
executable file
·72 lines (61 loc) · 1.8 KB
/
snifferctl
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
#!/bin/sh
# locker Start/Stop script for Locker Enterprise
#
# chkconfig: 2345 99 08
. /etc/rc.d/init.d/functions
HOME_PATH=/opt/sniffer
DAEMON_PROG=$HOME_PATH/sniffer
A_DAEMON_PROG=$HOME_PATH/analyzer
PID_FILE=$HOME_PATH/sniffer.pid
A_PID_FILE=$HOME_PATH/analyzer.pid
A_LOG_FILE=/var/log/sniffer/analyzer.log
STOP_TIMEOUT=120
start() {
echo -n "Starting ${DAEMON_PROG##*/}: ";
cd $HOME_PATH
$DAEMON_PROG -i eth1 not host 10.1.1.82 and not host 10.1.1.83 and not host 10.1.1.84 and not host 10.1.1.85 and not host 10.1.1.86 and not host 10.1.1.87 and not host 10.1.1.88 and not host 10.1.1.91 and not host 10.1.1.92 and not host 10.1.1.93 and not host 10.1.1.125 and not host 10.1.1.128 and not host 10.1.1.5 and not host 10.1.1.25 >> $HOME_PATH/log/sniffer.log 2>/dev/null &
pid="$!"
RETVAL=$?
[ $RETVAL = 0 ] && success && echo $pid > $PID_FILE
[ $RETVAL != 0 ] && failure && rm -f $PID_FILE
echo
echo -n "Starting ${A_DAEMON_PROG##*/}: ";
$A_DAEMON_PROG >> $A_LOG_FILE 2>&1 &
a_pid="$!"
A_RETVAL=$?
[ $A_RETVAL = 0 ] && success && echo $a_pid > $A_PID_FILE
[ $A_RETVAL != 0 ] && failure && rm -f $A_PID_FILE
echo
return $RETVAL && $A_RETVAL;
}
stop() {
echo -n "Stopping ${DAEMON_PROG##*/}: ";
killproc -p ${A_PID_FILE} -d ${STOP_TIMEOUT} ${A_DAEMON_PROG}
A_RETVAL=$?
[ $A_RETVAL = 0 ] && success && rm -f $A_PID_FILE
[ $A_RETVAL != 0 ] && failure
echo
echo -n "Stopping ${A_DAEMON_PROG##*/}: ";
killproc -p ${PID_FILE} -d ${STOP_TIMEOUT} ${DAEMON_PROG}
RETVAL=$?
[ $RETVAL = 0 ] && success && rm -f $PID_FILE
[ $RETVAL != 0 ] && failure
echo
return $RETVAL && $A_RETVAL
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage $0 {start | stop | restart}"
RETVAL=2
esac
exit $RETVAL