]> git.ipfire.org Git - ipfire-2.x.git/blame - src/initscripts/init.d/snort
IPFire-Seeder gebaut...
[ipfire-2.x.git] / src / initscripts / init.d / snort
CommitLineData
bd3a8a50 1#!/bin/sh
83843a1c
MT
2########################################################################
3# Begin $rc_base/init.d/snort
4#
5# Description : Snort Initscript
6#
7# Authors : Michael Tremer for ipfire.org - mitch@ipfire.org
8#
9# Version : 01.00
bd3a8a50 10#
83843a1c
MT
11# Notes :
12#
13########################################################################
14
15. /etc/sysconfig/rc
16. ${rc_functions}
bd3a8a50 17
bd3a8a50 18eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
83843a1c 19eval $(/usr/local/bin/readhash /var/ipfire/snort/settings)
bd3a8a50 20
83843a1c
MT
21if [ "$ENABLE_SNORT_ORANGE" == "on" ]; then
22 HOME_NET+="$ORANGE_ADDRESS,"
23 DEVICES+="$ORANGE_DEV "
24fi
bd3a8a50 25
83843a1c
MT
26if [ "$ENABLE_SNORT_GREEN" == "on" ]; then
27 HOME_NET+="$GREEN_ADDRESS,"
28 DEVICES+="$GREEN_DEV "
29fi
bd3a8a50 30
83843a1c
MT
31if [ "$ENABLE_SNORT_BLUE" == "on" ]; then
32 HOME_NET+="$BLUE_ADDRESS,"
33 DEVICES+="$BLUE_DEV "
34fi
bd3a8a50 35
83843a1c
MT
36if [ "$ENABLE_SNORT" == "on" ]; then
37 LOCAL_IP=`cat /var/ipfire/red/local-ipaddress`
38 if [ "$LOCAL_IP" ]; then
39 HOME_NET+="$LOCAL_IP,"
40 else
41 exit 1 ## Add error handling here
42 fi
43 DEVICES+="`cat /var/ipfire/red/iface` "
44fi
bd3a8a50 45
83843a1c
MT
46COUNT=`echo $HOME_NET | wc -m`
47HOME_NET=`echo $HOME_NET | cut -c $[$COUNT - 2]`
48
49echo "var HOME_NET [$HOME_NET]" > /etc/snort/vars
50echo "var EXTERNAL_NET ANY" >> /etc/snort/vars
bd3a8a50 51
83843a1c
MT
52DNS1=`cat /var/ipfire/red/dns1`
53DNS2=`cat /var/ipfire/red/dns2`
54
55if [ "$DNS2" ]; then
56 echo "var DNS_SERVERS [$DNS1,$DNS2]" >> /etc/snort/vars
57else
3ef6c343 58 echo "var DNS_SERVERS $DNS1" >> /etc/snort/vars
83843a1c 59fi
bd3a8a50
RZ
60
61case "$1" in
62 start)
83843a1c
MT
63 for DEVICE in $DEVICES; do
64 boot_mesg "Starting Intrusion Detection System on $DEVICE..."
3ef6c343
MT
65 /usr/sbin/snort -c /etc/snort/snort.conf -i $DEVICE -D -l /var/log/snort --pid-path /var/run/snort_$DEVICE.pid
66 evaluate_retval
c6c9630e 67 chmod 644 /var/run/snort_$DEVICE.pid
83843a1c 68 done
bd3a8a50 69 ;;
3ef6c343 70
bd3a8a50 71 stop)
f5be2265
CS
72 DEVICES=""
73 if [ -r /var/run/snort_$BLUE_DEV.pid ]; then
74 DEVICES+="$BLUE_DEV "
75 fi
76 if [ -r /var/run/snort_$GREEN_DEV.pid ]; then
77 DEVICES+="$GREEN_DEV "
78 fi
79 if [ -r /var/run/snort_$ORANGE_DEV.pid ]; then
80 DEVICES+="$ORANGE_DEV "
81 fi
83843a1c
MT
82 for DEVICE in $DEVICES; do
83 boot_mesg "Stopping Intrusion Detection System on $DEVICE..."
84 killproc -p /var/run/snort_$DEVICE.pid /var/run
85 done
bd3a8a50 86 ;;
3ef6c343 87
bd3a8a50
RZ
88 status)
89 statusproc /usr/sbin/snort
90 ;;
3ef6c343 91
83843a1c
MT
92 restart)
93 $0 stop
94 $0 start
95 ;;
96
bd3a8a50 97 *)
3ef6c343 98 echo "Usage: $0 {start|stop|restart|status}"
bd3a8a50
RZ
99 exit 1
100 ;;
101esac
102
103# End $rc_base/init.d/snort