app-admin/filebeat: new package.
authorTomas Mozes <hydrapolic@gmail.com>
Tue, 18 Oct 2016 09:49:07 +0000 (11:49 +0200)
committerPatrice Clement <monsieurp@gentoo.org>
Mon, 24 Oct 2016 11:25:43 +0000 (13:25 +0200)
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: https://github.com/gentoo/gentoo/pull/2585
Signed-off-by: Patrice Clement <monsieurp@gentoo.org>
app-admin/filebeat/Manifest [new file with mode: 0644]
app-admin/filebeat/filebeat-1.3.1.ebuild [new file with mode: 0644]
app-admin/filebeat/files/filebeat.confd [new file with mode: 0644]
app-admin/filebeat/files/filebeat.initd [new file with mode: 0644]
app-admin/filebeat/metadata.xml [new file with mode: 0644]

diff --git a/app-admin/filebeat/Manifest b/app-admin/filebeat/Manifest
new file mode 100644 (file)
index 0000000..d9e426f
--- /dev/null
@@ -0,0 +1 @@
+DIST filebeat-1.3.1.tar.gz 10225540 SHA256 1d8e41b42a0b2dd59403795ff07cbfd8a9a76477731c38122aa9242b47b054e0 SHA512 60f6d4ae93bb01e74311d7ccc3d367707f888f58898b89a0ea7512c96b6e1369edf7dc2afe3615df97e8c311629d9fc1e9fc2f1abe8edcbb5bc5bcf47c82107c WHIRLPOOL 608b825fa4dc99d792deb9d23672eea0e66318461adb944dc484d42edc3d3acb1cf1f65cd4024cf0437dd5e5ed088ff5b5aeec967f7efad03b82f259793410f0
diff --git a/app-admin/filebeat/filebeat-1.3.1.ebuild b/app-admin/filebeat/filebeat-1.3.1.ebuild
new file mode 100644 (file)
index 0000000..12dee30
--- /dev/null
@@ -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
+}
diff --git a/app-admin/filebeat/files/filebeat.confd b/app-admin/filebeat/files/filebeat.confd
new file mode 100644 (file)
index 0000000..88b7408
--- /dev/null
@@ -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=""
diff --git a/app-admin/filebeat/files/filebeat.initd b/app-admin/filebeat/files/filebeat.initd
new file mode 100644 (file)
index 0000000..3eb2fca
--- /dev/null
@@ -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
+}
diff --git a/app-admin/filebeat/metadata.xml b/app-admin/filebeat/metadata.xml
new file mode 100644 (file)
index 0000000..cd032aa
--- /dev/null
@@ -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>hydrapolic@gmail.com</email>
+    <name>Tomáš Mózes</name>
+  </maintainer>
+  <maintainer type="project">
+    <email>proxy-maint@gentoo.org</email>
+    <name>Proxy Maintainers</name>
+  </maintainer>
+  <upstream>
+    <remote-id type="github">elastic/beats</remote-id>
+  </upstream>
+</pkgmetadata>