5
# Required-Start: $time $network $local_fs $remote_fs
6
# Required-Stop: $remote_fs
7
# Default-Start: 2 3 4 5
9
# Short-Description: Next Generation IDS/IPS
10
# Description: Intrusion detection system that will
11
# capture traffic from the network cards and will
12
# match against a set of known attacks.
15
. /lib/lsb/init-functions
17
# Source function library.
18
if test -f /etc/default/suricata; then
19
. /etc/default/suricata
21
echo "/etc/default/suricata is missing... bailing out!"
24
# We'll add up all the options above and use them
29
# Use this if you want the user to explicitly set 'RUN' in
31
if [ "x$RUN" != "xyes" ] ; then
32
log_failure_msg "$NAME disabled, please adjust the configuration to your needs "
33
log_failure_msg "and then set RUN to 'yes' in /etc/default/$NAME to enable it."
38
if [ "$(id -u)" != "0" ]; then
39
log_failure_msg "You must be root to start, stop or restart $NAME."
45
if [ ! -e /proc/net/netfilter/nf_queue ]; then
46
log_failure_msg "NFQUEUE support not found !"
47
log_failure_msg "Please ensure the nfnetlink_queue module is loaded or built in kernel"
53
if [ ! -d /var/run/suricata ]; then
54
mkdir /var/run/suricata
55
chmod 0755 /var/run/suricata
65
IDMODE="IPS (nfqueue)"
66
LISTEN_OPTIONS=" -q $NFQUEUE"
71
LISTEN_OPTIONS=" -i $IFACE"
74
IDMODE="IDS (af-packet)"
75
LISTEN_OPTIONS=" --af-packet"
78
echo "Unsupported listen mode $LISTENMODE, aborting"
83
SURICATA_OPTIONS=" -c $SURCONF --pidfile $PIDFILE $LISTEN_OPTIONS -D"
85
# See how we were called.
88
if [ -f $PIDFILE ]; then
90
if kill -0 "$PID1" 2>/dev/null; then
91
echo "$NAME is already running with PID $PID1"
96
echo -n "Starting suricata in $IDMODE mode..."
97
if [ -f /usr/lib/libtcmalloc_minimal.so.0 ] && [ "x$TCMALLOC" = "xYES" ]; then
98
export LD_PRELOAD="/usr/lib/libtcmalloc_minimal.so.0"
99
#echo "Using googles tcmalloc for minor performance boost!?!"
101
$DAEMON $SURICATA_OPTIONS > /var/log/suricata/suricata-start.log 2>&1 &
105
echo -n "Stopping suricata: "
106
if [ -f $PIDFILE ]; then
109
echo " No PID file found; not running?"
112
start-stop-daemon --oknodo --stop --quiet --pidfile=$PIDFILE --exec $DAEMON
113
if [ -n "$PID2" ]; then
117
if kill -0 "$PID2" 2>/dev/null; then
121
while kill -0 "$PID2" 2>/dev/null; do
123
cnt=`expr "$cnt" + 1`
124
if [ "$cnt" -gt 10 ]; then
133
if [ -e $PIDFILE ]; then
134
rm $PIDFILE > /dev/null 2>&1
139
# Check if running...
140
if [ -s $PIDFILE ]; then
142
if kill -0 "$PID3" 2>/dev/null; then
143
echo "$NAME is running with PID $PID3"
146
echo "PID file $PIDFILE exists, but process not running!"
149
echo "$NAME not running!"
161
echo "Usage: $0 {start|stop|restart|status}"