#!/bin/sh
#
# Startup script for Snort IDE - Software. 
#
# chkconfig: 345 85 15
# description:  Programa de deteccion de intrusos.
#	      
# processname: snort
#  
# By Federico Rena ( Telematica SRL )
#

# Source function library.
. /etc/rc.d/init.d/functions


# if you have Guardian install
GUARDIAN="/opt/Snort/contrib/Guardian/Guardian.pl"

# Snort - path from execute.
SNORT="/usr/local/bin/snort"


# Config File path.
# 
CONFIGFILE="/opt/Snort/snort.conf"


[ -f $SNORT    ] || echo -en "Don't have snort pleace verify the config file \n"


# See how we were called.
case "$1" in

  start)
	echo -n "Starting snort ..." 
	$SNORT -A full -v -d -c $CONFIGFILE >/dev/tty11  & 
	touch /var/lock/subsys/snort
	;;

  startfull)

        [ -f $GUARDIAN ] || echo -en "Don't have Guardian pleace verify the config file \n\n"
	echo -n "Starting snort + Guardian " 	
	$SNORT -A full -v -d -c $CONFIGFILE > /dev/tty11 & 
 	$GUARDIAN -c /etc/guardian.conf & 
	touch /var/lock/subsys/snort
	;;

  stop)
	echo -n "Shutting down snort: "
	killproc snort
	killproc Guardian.pl
	echo
	rm -f /var/lock/subsys/snort
	rm -f /var/run/snort.pid
	;;

  status)
	status snort
	;;

  restart)
	$0 stop
	$0 start
	;;

  reload)
	echo -n "Reloading snort: "
	killproc snort -HUP
	echo
	;;
  *)
	echo "Usage: $0 {start|startfull|stop|restart|reload|status}"
	exit 1
esac


exit 0
