aboutsummaryrefslogtreecommitdiff
path: root/network/suricata/rc.suricata
blob: e4eb06f1a6d91588c4cbe6cc2d1a0598c315f5f5 (plain)
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
#!/bin/sh
# Start/stop/restart suricata
# This file written from James Bond <evanton@tut.by>

# This tell suricata which interface to listen on (any for every interface)
IFACE=${IFACE:-eth0}

# Make sure this matches your IFACE
PIDFILE=/var/run/suricata_$IFACE.pid

# You probably don't want to change this, but in case you do
LOGDIR="/var/log/suricata"

# Probably not this either
CONF=/etc/suricata/suricata.yaml

# Start suricata:
suricata_start() {
  CMDLINE="/usr/bin/suricata -D -i $IFACE"
  echo "Starting Suricata daemon:  $CMDLINE"
  $CMDLINE --pidfile $PIDFILE -l $LOGDIR -c $CONF
  echo
}

# Stop suricata:
suricata_stop() {
  echo -n "Stopping Suricata daemon ($IFACE)..."
  kill $(cat $PIDFILE)
  echo
  sleep 1
  rm -f $PIDFILE
}

# Restart suricata:
suricata_restart() {
  suricata_stop
  sleep 1
  suricata_start
}

case "$1" in
'start')
  suricata_start
  ;;
'stop')
  suricata_stop
  ;;
'restart')
  suricata_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac