|
|
|
|
Snort Forums Archive
Archive Home » Snort Development » Sharing Multiple Sensor Startup Script
Please note that the categories listed below represent an archived version of our forums pages. To view the current version and be able to post and reply to threads, please register and login here to go to the full forums pages.
[ Notice: Full Version of This Topic ]
Sharing Multiple Sensor Startup Script
Posted by jayd on March 10, 2006 10:07:42
I created this little script for starting/stoping multiple sensors, works great.
-----------------------Script start------------------------------------
#!/bin/sh
# $Id: sensorsd v1.0 2006/01/07 jdreger
#
# sensorsd Start/Stop Sensors
#
# This script will stop and start specific sensors according to usage.
SENSOR_BASE="/secure/usr/local/bin/start_s"
usage(){
echo "usage: `basename $0` 1 [start|stop]" >&2
exit 1
}
runit(){
unit=$1
mode=$2
sensor=${SENSOR_BASE}${unit}.sh
snortuser=snort
if [ $1 = all ] && [ $2 = stop ];
then
echo "Stopping all sensors with PID" `/usr/bin/pgrep -f snort`
/usr/bin/pkill -f snort
else
if [ $1 = all ] && [ $2 = start ];
then
echo "Increment sensor script #"
for s in ${SENSOR_BASE}[0-9]*.sh
do
echo "Startting..." $s
$s
done
else
if [ $2 = stop ];
then
echo $sensor $mode stopped
/usr/bin/pkill -f snort.s$unit.conf
else
if [ -f ${sensor} ] && [ -x ${sensor} ]
then
echo $sensor $mode
$sensor $mode
else
echo "whatyoutalkinaboutwillis?"
fi
fi
fi
fi
}
if [ $# -ne 2 ]
then
usage
fi
case $2 in
start|stop) ;;
*) usage ;;
esac
case $1 in
[0-9]) runit $1 $2 ;;
[0-9][0-9]) runit $1 $2 ;;
all) runit $1 $2 ;;
*) usage ;;
esac
|
|
Posted by brevizniak on March 10, 2006 17:34:29
Thanks. You may want to post a link where people can download it as the forum removes all formatting. |
|
|
|
|
|