Imported Upstream version 2.7
[ossec-hids.git] / src / init / ossec-hids-rh.init
1 #!/bin/sh
2 # OSSEC         Controls OSSEC HIDS on Redhat-based systems
3 # Author:       Kayvan A. Sylvan <kayvan@sylvan.com>
4 # Author:       Daniel B. Cid <dcid@ossec.net>
5 #
6 # chkconfig: 2345 99 15
7 # description: Starts and stops OSSEC HIDS (Host Intrusion Detection System)
8 #
9 # This will work on Redhat systems (maybe others too)
10
11 # Source function library.
12 export LANG=C
13
14 . /etc/init.d/functions
15 . /etc/ossec-init.conf
16
17 if [ "X${DIRECTORY}" = "X" ]; then
18     DIRECTORY="/var/ossec"
19 fi
20
21 start() {
22         echo -n "Starting OSSEC: "
23         ${DIRECTORY}/bin/ossec-control start > /dev/null
24         RETVAL=$?
25         if [ $RETVAL -eq 0 ]; then
26                 success
27         else
28                 failure
29         fi
30         echo
31         return $RETVAL
32 }
33
34 stop() {
35         echo -n "Stopping OSSEC: "
36         ${DIRECTORY}/bin/ossec-control stop > /dev/null
37         RETVAL=$?
38         if [ $RETVAL -eq 0 ]; then
39                 success
40         else
41                 failure
42         fi
43         echo
44         return $RETVAL
45 }
46
47 status() {
48         ${DIRECTORY}/bin/ossec-control status
49         RETVAL=$?
50         return $RETVAL
51 }
52
53
54 case "$1" in
55   start)
56         start
57         ;;
58   stop) 
59         stop
60         ;;
61   restart)
62         stop
63         start
64         ;;
65   status)
66     status
67         ;;
68   *)
69         echo "*** Usage: ossec {start|stop|restart|status}"
70         exit 1
71 esac
72
73 exit $?