#!/bin/sh
#
# snort         Starts snort in intrusion-detection mode
#
# chkconfig: 345 93 07
# description: snort is a network intrusion detection system 
# pidfile: /var/run/snort_$SNORT_IFACE.pid

ICFG=/etc/config.d/snort/snort.sysconfig
SNORTBIN=`which snort`
SNORT_CFGFILE=/etc/snort.conf
if [ -e $ICFG ]; then
   . $ICFG
else
   echo " Snort has not been configured! Please configure snort! "
   exit 0
fi

SNPID=/var/run/snort_$SNORT_IFACE.pid

case $1 in
     start|restart)  echo   "$1ing Snort, Intrusion Detection System."
                     if [ -s $SNPID ]; then
                        kill -9  `cat $SNPID`
			rm -f $SNPID
                     fi
                     $SNORTBIN -D -i $SNORT_IFACE $SNORT_OPTIONS -c $SNORT_CFGFILE
                     ;;
              stop)  echo   "$1ping Snort."
                     if [ ! -s $SNPID ]; then
                        echo "Snort not running"
                     else
                        kill -9 `cat $SNPID`
			rm -f $SNPID
                     fi
                     ;;
                 *)  echo   "Usage: $0 {start|stop|restart}"
                     ;;
esac
