]>
Commit | Line | Data |
---|---|---|
4dee4001 AM |
1 | #!/bin/sh |
2 | # | |
1396af1f | 3 | # snort Start/Stop the snort IDS daemon. |
4dee4001 | 4 | # |
1396af1f | 5 | # chkconfig: 2345 85 24 |
6 | # description: snort is a lightweight network intrusion detection tool that | |
4dee4001 AM |
7 | # currently detects more than 1100 host and network |
8 | # vulnerabilities, portscans, backdoors, and more. | |
9 | # | |
10 | ||
11 | # Source function library. | |
12 | . /etc/rc.d/init.d/functions | |
06da3568 | 13 | . /etc/sysconfig/network |
4dee4001 AM |
14 | |
15 | # Get service config - may override defaults | |
16 | [ -f /etc/sysconfig/snort ] && . /etc/sysconfig/snort | |
17 | ||
18 | # Check that networking is up. | |
19 | if is_yes "${NETWORKING}"; then | |
1396af1f | 20 | if [ ! -f /var/lock/subsys/network ]; then |
21 | # nls "ERROR: Networking is down. %s can't be run." <service> | |
22 | msg_network_down snort | |
23 | exit 1 | |
24 | fi | |
4dee4001 | 25 | else |
1396af1f | 26 | exit 0 |
4dee4001 AM |
27 | fi |
28 | ||
86cb99cc | 29 | |
4dee4001 AM |
30 | # See how we were called. |
31 | case "$1" in | |
32 | start) | |
1396af1f | 33 | # Check if the service is already running? |
34 | if [ ! -f /var/lock/subsys/snort ]; then | |
35 | # show "Starting %s service." <service> | |
36 | msg_starting snort | |
197e01fd | 37 | # we need full path here; see SnortUsersManual.pdf |
1396af1f | 38 | daemon /usr/sbin/snort \ |
c649dd1c | 39 | -u snort -g snort -d -D \ |
197e01fd | 40 | -l /var/log/snort -c /etc/snort/snort.conf |
1396af1f | 41 | RETVAL=$? |
42 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/snort | |
43 | else | |
44 | # show "%s service is already running." <service> | |
45 | msg_already_running snort | |
46 | exit 1 | |
47 | fi | |
4dee4001 AM |
48 | ;; |
49 | stop) | |
1396af1f | 50 | if [ -f /var/lock/subsys/snort ]; then |
86cb99cc | 51 | # Stop daemons. |
52 | # show "Stopping %s service" <service> | |
1396af1f | 53 | msg_stopping snort |
54 | killproc snort | |
55 | RETVAL=$? | |
56 | rm -f /var/lock/subsys/snort | |
86cb99cc | 57 | ;; |
58 | reload|force-reload) | |
59 | if [ -f /var/lock/subsys/snort ]; then | |
60 | msg_reloading snort | |
61 | killproc snort -HUP | |
62 | RETVAL=$? | |
1396af1f | 63 | else |
64 | # show "%s service is not running." <service> | |
65 | msg_not_running snort | |
66 | exit 1 | |
67 | fi | |
4dee4001 AM |
68 | ;; |
69 | restart) | |
70 | $0 stop | |
71 | $0 start | |
72 | ;; | |
73 | status) | |
74 | status snort | |
75 | ;; | |
76 | *) | |
86cb99cc | 77 | msg_usage "$0 {start|stop|restart|reload|force-reload|status}" |
4dee4001 AM |
78 | exit 1 |
79 | esac | |
80 | ||
81 | exit $RETVAL |