Skip to content

Commit

Permalink
app-admin/filebeat: new package.
Browse files Browse the repository at this point in the history
Filebeat is part of the Beats family by Elasticsearch. It's a lightweight log
forwarder to Logstash & Elasticsearch.

We already have a binary version of the package in tree, but this non-binary
should eventually remove it.

Package-Manager: portage-2.3.1
Closes: gentoo#2585
Signed-off-by: Patrice Clement <[email protected]>
  • Loading branch information
hydrapolic authored and monsieurp committed Oct 24, 2016
1 parent dbda37e commit 1ed4627
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 0 deletions.
1 change: 1 addition & 0 deletions app-admin/filebeat/Manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DIST filebeat-1.3.1.tar.gz 10225540 SHA256 1d8e41b42a0b2dd59403795ff07cbfd8a9a76477731c38122aa9242b47b054e0 SHA512 60f6d4ae93bb01e74311d7ccc3d367707f888f58898b89a0ea7512c96b6e1369edf7dc2afe3615df97e8c311629d9fc1e9fc2f1abe8edcbb5bc5bcf47c82107c WHIRLPOOL 608b825fa4dc99d792deb9d23672eea0e66318461adb944dc484d42edc3d3acb1cf1f65cd4024cf0437dd5e5ed088ff5b5aeec967f7efad03b82f259793410f0
46 changes: 46 additions & 0 deletions app-admin/filebeat/filebeat-1.3.1.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

EAPI=6

DESCRIPTION="Lightweight log shipper for Logstash and Elasticsearch"
HOMEPAGE="https://www.elastic.co/products/beats"
SRC_URI="https://github.com/elastic/beats/archive/v${PV}.tar.gz -> ${P}.tar.gz"

LICENSE="Apache-2.0"
SLOT="0"
KEYWORDS="~amd64"

DEPEND="dev-lang/go"
RDEPEND="!app-admin/filebeat-bin"

ELASTIC="${WORKDIR}/src/github.com/elastic"
BEATS="${ELASTIC}/beats"
S="${BEATS}"

src_unpack() {
mkdir -p "${ELASTIC}" || die
unpack ${P}.tar.gz
mv beats-${PV} "${BEATS}" || die
}

src_compile() {
cd ${BEATS}/filebeat || die
GOPATH="${WORKDIR}" emake
}

src_install() {
keepdir /etc/${PN}
keepdir /var/lib/${PN}

fperms 0750 /var/lib/${PN}

newconfd "${FILESDIR}/${PN}.confd" ${PN}
newinitd "${FILESDIR}/${PN}.initd" ${PN}

insinto /etc/${PN}
newins ${PN}/etc/${PN}.yml ${PN}.yml.example

dobin filebeat/filebeat
}
12 changes: 12 additions & 0 deletions app-admin/filebeat/files/filebeat.confd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Run filebeat under this user/group
#FILEBEAT_USER=""
#FILEBEAT_GROUP=""

# Configuration path
#FILEBEAT_CONFIG=""

# Path to state directory
#FILEBEAT_STATEDIR=""

# Additional arguments passed to filebeat
#FILEBEAT_OPTS=""
47 changes: 47 additions & 0 deletions app-admin/filebeat/files/filebeat.initd
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/sbin/openrc-run
# Copyright 1999-2016 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_STATEDIR="${FILEBEAT_STATEDIR:-/var/lib/filebeat}"
FILEBEAT_OPTS="${FILEBEAT_OPTS:-}"

command="/usr/bin/filebeat"
command_args="-c ${FILEBEAT_CONFIG} ${FILEBEAT_OPTS}"
extra_commands="checkconfig"
command_background="true"
start_stop_daemon_args="--user ${FILEBEAT_USER}:${FILEBEAT_GROUP} \
--chdir ${FILEBEAT_STATEDIR}"
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_STATEDIR}"
}

stop() {
ebegin "Stopping filebeat"
start-stop-daemon --stop \
--pidfile=${pidfile} \
--retry=TERM/5/KILL/5
}
15 changes: 15 additions & 0 deletions app-admin/filebeat/metadata.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
<pkgmetadata>
<maintainer type="person">
<email>[email protected]</email>
<name>Tomáš Mózes</name>
</maintainer>
<maintainer type="project">
<email>[email protected]</email>
<name>Proxy Maintainers</name>
</maintainer>
<upstream>
<remote-id type="github">elastic/beats</remote-id>
</upstream>
</pkgmetadata>

0 comments on commit 1ed4627

Please sign in to comment.