aboutsummaryrefslogtreecommitdiffstats
path: root/testing/ossec-hids/ossec-hids.initd
blob: fd08d0b408351651d8ec7031cb9818845f28b9d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/sbin/openrc-run
DIRECTORY="/var/ossec"
OSSEC_CONTROL="${DIRECTORY}/bin/ossec-control"

depend() {
	need net
	use logger
}

configtest() {
	ebegin "Checking OSSEC Configuration"
	checkconfig
	eend $?
}

checkconfig() {
	CONFIGFILE="${CONFIGFILE:-${DIRECTORY}/etc/ossec.conf}"
	if [ ! -r "${CONFIGFILE}" ]; then
		eerror "Unable to read configuration file: ${CONFIGFILE}"
		return 1
	fi

	# Maybe put some kind of config file syntax checking in here?  XML is a little different
	# so maybe not.	
	return $ret
}

start() {
	checkconfig || return 1
	ebegin "Starting ossec-hids"
	${OSSEC_CONTROL} start > /dev/null 2>&1
	eend $?
}

stop() {
	checkconfig || return 1
	ebegin "Stopping ossec-hids"
	${OSSEC_CONTROL} stop > /dev/null 2>&1
	eend $?
}

restart() {
	if ! service_started "${myservice}" ; then
		eerror "OSSEC is not running! Please start it before trying to reload it."
	else
		checkconfig || return 1
		ebegin "Reloading ossec"
		svc_stop ${OSSEC_CONTROL}
		svc_start ${OSSEC_CONTROL}
		eend $?
	fi
}

status() {
	checkconfig || return 1
	${OSSEC_CONTROL} status
}