aboutsummaryrefslogtreecommitdiff
path: root/network/barnyard2/rc.barnyard2
blob: 93e899f4c9e952002dcc6354ae9f9cf3076a13ce (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
#!/bin/sh
# Start/stop/restart barnyard2

# Settings
SNORTLOGDIR=${SNORTLOGDIR:-/var/log/snort}
SNORTLOGFILE=${SNORTLOGFILE:-snort.log}
IFACE=${IFACE:-any}
PIDFILE=/var/run/barnyard2_$IFACE.pid
LOGDIR=/var/log/barnyard2


# Start snort:
by2_start() {
  CMDLINE="/usr/bin/barnyard2 -i $IFACE -d $SNORTLOGDIR -f $SNORTLOGFILE -n -D "
  echo -n "Starting Barnyard2 daemon:  $CMDLINE"
  $CMDLINE --pid-path /var/run --create-pidfile -l $LOGDIR
  echo
}

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

# Restart snort:
by2_restart() {
  by2_stop
  sleep 1
  by2_start
}

case "$1" in
'start')
  by2_start
  ;;
'stop')
  by2_stop
  ;;
'restart')
  by2_restart
  ;;
*)
  echo "usage $0 start|stop|restart"
esac