summaryrefslogtreecommitdiff
path: root/security/ossec-hids-server/files/ossec-hids.in
blob: bd6c7e96f36027f42d3eab9456bd3e22a6e6b142 (plain) (blame)
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
#!/bin/sh
# 
# PROVIDE: ossechids
# REQUIRE: DAEMON
# BEFORE:  LOGIN
# KEYWORD: shutdown

. /etc/rc.subr

name="ossechids"
rcvar=ossechids_enable

load_rc_config $name

: ${ossechids_enable="NO"}
: ${ossechids_user="ossec"}
: ${ossechids_group="ossec"}

start_precmd=%%PRECMD%%
start_cmd="ossechids_command start"
stop_cmd="ossechids_command stop"
restart_cmd="ossechids_command restart"
status_cmd="ossechids_command status"

command="%%PREFIX%%/%%PORTNAME%%/bin/ossec-control"
required_files="%%PREFIX%%/%%PORTNAME%%/etc/ossec.conf"

fts_queue=%%PREFIX%%/%%PORTNAME%%/queue/fts/fts-queue
ig_queue=%%PREFIX%%/%%PORTNAME%%/queue/fts/ig-queue

ossechids_start_precmd() {
    # These files are not created by the daemons with the correct
    # ownership, so create them here before starting up the system,
    # if they don't already exist. This is only done for the "local" and
    # "server" installation types.
    if [ ! -e ${fts_queue} ]; then
        touch ${fts_queue}
        chown ${ossechids_user}:${ossechids_group} ${fts_queue}
        chmod 640 ${fts_queue}
    fi
    if [ ! -e ${ig_queue} ]; then
        touch ${ig_queue}
        chown ${ossechids_user}:${ossechids_group} ${ig_queue}
        chmod 640 ${ig_queue}
    fi
}

ossechids_command() {
	${command} ${rc_arg}
}

run_rc_command "$1"