summaryrefslogtreecommitdiffstats
path: root/network/snort/rc.snort
blob: d91941e8227f418057f9a6f8e90b20fce9e64bff (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 snort

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

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

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

# Probably not this either
CONF=/etc/snort/snort.conf

# Start snort:
snort_start() {
  CMDLINE="/usr/bin/snort -d -D -i $IFACE"
  echo -n "Starting Snort daemon:  $CMDLINE"
  $CMDLINE --pid-path /var/run --create-pidfile -l $LOGDIR -c $CONF
  echo
}

# Stop snort:
snort_stop() {
  echo -n "Stopping Snort daemon ($IFACE)..."
  kill $(cat $PIDFILE)
  echo
  sleep 1
  rm -f $PIDFILE
}

# Restart snort:
snort_restart() {
  snort_stop
  sleep 1
  snort_start
}

case "$1" in
'start')
  snort_start
  ;;
'stop')
  snort_stop
  ;;
'restart')
  snort_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac