Imported Upstream version 2.3
[ossec-hids.git] / src / init / ossec-hids-suse.init
1 #!/bin/sh
2 # Author: Scott Knauss scott@knauss.com
3 #
4 # /etc/init.d/ossec
5 #
6 #
7 ### BEGIN INIT INFO
8 # Provides:       ossec
9 # Required-Start: $syslog
10 # Required-Stop:
11 # Default-Start:  2 3 5
12 # Default-Stop:
13 # Description:    Start the ossec HIDS daemon
14 ### END INIT INFO
15
16 # Shell functions sourced from /etc/rc.status:
17 #      rc_check         check and set local and overall rc status
18 #      rc_status        check and set local and overall rc status
19 #      rc_status -v     ditto but be verbose in local rc status
20 #      rc_status -v -r  ditto and clear the local rc status
21 #      rc_failed        set local and overall rc status to failed
22 #      rc_failed <num>  set local and overall rc status to <num>
23 #      rc_reset         clear local rc status (overall remains)
24 #      rc_exit          exit appropriate to overall rc status
25 . /etc/rc.status
26
27 # First reset status of this service
28 rc_reset
29
30 # Return values acc. to LSB for all commands but status:
31 # 0 - success
32 # 1 - generic or unspecified error
33 # 2 - invalid or excess argument(s)
34 # 3 - unimplemented feature (e.g. "reload")
35 # 4 - insufficient privilege
36 # 5 - program is not installed
37 # 6 - program is not configured
38 # 7 - program is not running
39
40 # Note that starting an already running service, stopping
41 # or restarting a not-running service as well as the restart
42 # with force-reload (in case signalling is not supported) are
43 # considered a success.
44
45
46 # Reading ossec init conf.
47 if [ -f /etc/ossec-init.conf ]; then
48     . /etc/ossec-init.conf
49 fi
50     
51 if [ "X${DIRECTORY}" = "X" ]; then
52     DIRECTORY="/var/ossec"
53 fi
54
55
56 #Just to make sure ossec is installed ...
57 CONTROL="$DIRECTORY/bin/ossec-control"
58
59 test -x $CONTROL || { echo "$CONTROL not installed"; 
60     if [ "$1" = "stop" ]; then exit 0;
61     else exit 5; fi; }
62     
63     
64 start() {
65         ${DIRECTORY}/bin/ossec-control start
66 }
67
68 stop() {
69         ${DIRECTORY}/bin/ossec-control stop
70 }
71
72 status() {
73         ${DIRECTORY}/bin/ossec-control status
74 }
75
76
77 case "$1" in
78   start)
79         start
80         ;;
81   stop) 
82         stop
83         ;;
84   restart)
85         stop
86         start
87         ;;
88   status)
89     status
90         ;;
91   *)
92         echo "*** Usage: $0 {start|stop|restart|status}"
93         exit 1
94 esac
95
96 exit 0