# Contributor: Ramanathan Sivagurunathan <ramzthecoder@gmail.com>
# Maintainer: Ramanathan Sivagurunathan <ramzthecoder@gmail.com>
pkgname=metricbeat
pkgver=6.2.3
pkgrel=0
pkgdesc="MetricBeat - Lightweight shipper for system and service statistics"
pkgusers="root"
url="https://www.elastic.co/products/beats"
arch="all !aarch64 !armhf"
license="ASL 2.0"
depends=""
makedepends="go"
install=""
subpackages=""
source="beats-${pkgver}.tar.gz::https://github.com/elastic/beats/archive/v$pkgver.tar.gz
	metricbeat.initd
	metricbeat.confd
	metricbeat.yml
	"
builddir="$srcdir/src/github.com/elastic/beats/$pkgname"

prepare() {
	mkdir -p "$srcdir/src/github.com/elastic/"
	mv "$srcdir/beats-${pkgver}" "$srcdir/src/github.com/elastic/beats" || return 1
	default_prepare
}

build() {
	cd "$builddir"
	GOPATH="$srcdir" go build -v || return 1
}

package() {
	cd "$builddir"
	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname || return 1
	install -Dm644 "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname || return 1
	install -Dm644 "$srcdir/metricbeat.yml" "$pkgdir/etc/$pkgname/metricbeat.yml" || return 1
	install -Dm755 "$builddir/metricbeat" "$pkgdir/usr/bin/metricbeat" || return 1
}

sha512sums="b0628bc8df6460ac6b1610d7bb6cc2bb93898887f0617324d79727dbeca5cce6de28dc8b584663c66888fc23912ced1b3e231c046ecb343e09899df3026c997e  beats-6.2.3.tar.gz
a846db44732077c38fd0699592ad27371af75ee8a53419c79197c4e5d727e1745c5145ebefd21073304cb624c5947686626f693e87406b122892f99cebe38f5b  metricbeat.initd
91fad211c1ac8b3bb97848f1ff97f7e708cfd100b174ae1839c4dd60d501cd8b7b4e9f0f4dbb936134c4ef19595bf39c53b256990f08f003c3e88893e0c94212  metricbeat.confd
b05e083c2ea2337cebd650f2898385ff40fb7f4fe2d7d46109cec3e960d80566129756e8a45e71ed53ec40c33539295453d363feafb60caec8747ae8d09f9124  metricbeat.yml"
