# Template file for 'elasticsearch'
pkgname=elasticsearch
version=5.1.2
revision=1
wrksrc="elasticsearch-${version}"
only_for_archs="i686 x86_64"
depends="virtual?java-runtime"
short_desc="A distributed, open source search and analytics engine"
maintainer="dota? =op <rogi@skylittlesystem.org>"
license="Apache-2.0"
homepage="http://www.elastic.co"
distfiles="https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${version}.tar.gz"
checksum=74d752f9a8b46898d306ad169b72f328e17215c0909149e156a576089ef11c42
system_accounts="elastic"
conf_files="/etc/elasticsearch/elasticsearch.yml /etc/elasticsearch/jvm.options /etc/elasticsearch/log4j2.properties"

do_install() {
	ES="usr/share/elasticsearch"

	rm -f bin/*.{bat,exe}
	vmkdir $ES

	vcopy bin $ES
	vcopy lib $ES
	vcopy modules $ES
	vcopy plugins $ES

	vmkdir usr/bin

	ln -sf /$ES/bin/elasticsearch "$DESTDIR/usr/bin"

	vmkdir etc/elasticsearch
	vcopy config/* etc/elasticsearch

	ln -sf /etc/elasticsearch "$DESTDIR/$ES/config"

	vmkdir var/lib/elasticsearch/data
	ln -sf /var/lib/elasticsearch/data "$DESTDIR/$ES/data"

	vmkdir var/log/elasticsearch
	ln -sf /var/log/elasticsearch "$DESTDIR/$ES/logs"

	vlicense LICENSE.txt
	vlicense NOTICE.txt
	vdoc README.textile

	vsv elasticsearch
}
