new upstream release (3.3.0); modify package compatibility for Stretch
[ossec-hids.git] / src / init / ossec-hids-gentoo.init
1 #!/sbin/runscript
2 # Gentoo init script
3 # by gentuxx <gentuxx@gmail.com>
4
5 opts="${opts} status configtest"
6
7 # Finding where ossec is installed
8 . /etc/ossec-init.conf
9 if [ "X${DIRECTORY}" = "X" ]; then
10     DIRECTORY="/var/ossec"
11 fi
12
13 OSSEC_CONTROL="${DIRECTORY}/bin/ossec-control"
14
15 depend() {
16     need net
17     use logger
18 }
19
20 configtest() {
21     ebegin "Checking OSSEC Configuration"
22     checkconfig
23     eend $?
24 }
25
26 checkconfig() {
27     CONFIGFILE="${CONFIGFILE:-${DIRECTORY}/etc/ossec.conf}"
28     if [ ! -r "${CONFIGFILE}" ]; then
29         eerror "Unable to read configuration file: ${CONFIGFILE}"
30         return 1
31     fi
32
33     # Maybe put some kind of config file syntax checking in here?  XML is a little different
34     # so maybe not.
35     return $ret
36 }
37
38 start() {
39     checkconfig || return 1
40     ebegin "Starting ossec-hids"
41     ${OSSEC_CONTROL} start > /dev/null 2>&1
42     eend $?
43 }
44
45 stop() {
46     checkconfig || return 1
47     ebegin "Stopping ossec-hids"
48     ${OSSEC_CONTROL} stop > /dev/null 2>&1
49     eend $?
50 }
51
52 restart() {
53     if ! service_started "${myservice}" ; then
54         eerror "OSSEC is not running! Please start it before trying to reload it."
55     else
56         checkconfig || return 1
57         ebegin "Reloading ossec"
58         svc_stop ${OSSEC_CONTROL}
59         svc_start ${OSSEC_CONTROL}
60         eend $?
61     fi
62 }
63
64 status() {
65     checkconfig || return 1
66     ${OSSEC_CONTROL} status
67 }