#!/bin/sh
# $FreeBSD: ports/security/snort/files/snort.sh.in,v 1.3 2007/06/14 02:51:01 clsung Exp $

# PROVIDE: snort
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown

# Add the following lines to /etc/rc.conf to enable snort:
# snort_enable (bool):		Set to YES to enable snort
# 				Default: NO
# snort_flags (str):		Extra flags passed to snort
#				Default: -Dq
# snort_interface (str):	Network interface to sniff
#				Default: "" 
# snort_conf (str):		Snort configuration file
#				Default: ${PREFIX}/etc/snort/snort.conf
# snort_expression (str):	filter expression
#				If your expression is very long, set 
#				kern.ps_arg_cache_limit sysctl variable
#				to large value. Otherwise, snort won't
#				restart!
#				Default: ""
#

. /etc/rc.subr

name="snort"
rcvar=`set_rcvar`

command="/usr/local/bin/snort"

load_rc_config $name

[ -z "$snort_enable" ]    && snort_enable="NO"
[ -z "$snort_conf" ]      && snort_conf="/usr/local/etc/snort/snort.conf"
[ -z "$snort_flags" ]     && snort_flags="-Dq"

[ -n "$snort_interface" ] && snort_flags="$snort_flags -i $snort_interface" \
                          && pidfile="/var/run/snort_${snort_interface}.pid"
[ -n "$snort_conf" ]      && snort_flags="$snort_flags -c $snort_conf"
[ -n "$snort_expression" ] && snort_flags="$snort_flags $snort_expression"

run_rc_command "$1"
