blob: da18022c20d75ce747c556d35494ee9313669f1c (
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
|
#!/sbin/openrc-run
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
FILEBEAT_USER="${FILEBEAT_USER:-root}"
FILEBEAT_GROUP="${FILEBEAT_GROUP:-root}"
FILEBEAT_CONFIG="${FILEBEAT_CONFIG:-/etc/filebeat/filebeat.yml}"
FILEBEAT_DATADIR="${FILEBEAT_DATADIR:-/var/lib/filebeat}"
FILEBEAT_LOGDIR="${FILEBEAT_LOGDIR:-/var/log/filebeat}"
FILEBEAT_OPTS="${FILEBEAT_OPTS:-}"
command="/usr/bin/filebeat"
command_args="-c ${FILEBEAT_CONFIG} ${FILEBEAT_OPTS} -path.config $(dirname $FILEBEAT_CONFIG) \
-path.data ${FILEBEAT_DATADIR} -path.home ${FILEBEAT_DATADIR} -path.logs ${FILEBEAT_LOGDIR}"
extra_commands="checkconfig"
command_background="true"
start_stop_daemon_args="--user ${FILEBEAT_USER}:${FILEBEAT_GROUP} \
--chdir ${FILEBEAT_DATADIR}"
pidfile="/run/filebeat/filebeat.pid"
depend() {
use net
after elasticsearch
}
checkconfig() {
if [[ ! -e ${FILEBEAT_CONFIG} ]]; then
eend "Please create a configuration file at ${FILEBEAT_CONFIG}"
return 1
fi
ebegin "Checking your configuration"
${command} ${command_args} -configtest
eend $? "Configuration error. Please fix your configuration files."
}
start_pre() {
checkconfig || return 1
checkpath -d -o "${FILEBEAT_USER}":"${FILEBEAT_GROUP}" -m750 "$(dirname "${pidfile}")"
checkpath -d -o "${FILEBEAT_USER}":"${FILEBEAT_GROUP}" -m750 "${FILEBEAT_DATADIR}"
checkpath -d -o "${FILEBEAT_USER}":"${FILEBEAT_GROUP}" -m750 "${FILEBEAT_LOGDIR}"
}
stop() {
ebegin "Stopping filebeat"
start-stop-daemon --stop \
--pidfile=${pidfile} \
--retry=TERM/5/KILL/5
}
|