# Maintainer: Jeff Bilyk <jbilyk@gmail.com>
pkgname=nrpe
pkgver=2.15
pkgrel=7
pkgusers="nagios"
pkggroups="nagios"
pkgdesc="NRPE allows you to remotely execute Nagios plugins on other Linux/Unix machines."
url="http://www.nagios.org/download/addons"
arch="all"
license="GPL"
makedepends="libressl-dev perl"
install="nrpe.pre-install"
subpackages="$pkgname-plugin"
source="http://downloads.sourceforge.net/nagios/$pkgname-$pkgver.tar.gz
	stay-in-foreground.patch
	sample-config.patch
	nrpe.initd
	nrpe.confd"
builddir="$srcdir/$pkgname-$pkgver"

prepare() {
	default_prepare
	update_config_sub
}

build() {
	cd "$builddir"

	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--libexecdir=/usr/lib/nagios/plugins \
		--enable-command-args
	make
}

package() {
	cd "$builddir"

	make DESTDIR="$pkgdir" install install-daemon-config

	# Remove plugin since its in separate package.
	rm -rf "$pkgdir"/usr/lib
	install -Dm755 "$srcdir"/nrpe.initd "$pkgdir"/etc/init.d/nrpe
	install -Dm644 "$srcdir"/nrpe.confd "$pkgdir"/etc/conf.d/nrpe
}

plugin() {
	pkgdesc="Nagios plugin to check result via NRPE daemon"

	cd "$builddir"
	make DESTDIR="$subpkgdir" install-plugin
}

sha512sums="03ce9774b5112d03235dc9da075770d89d1bcc5ffa5faf221ff7ea8ec5c92ded1e1ae9222581a87cf53736d190ac047e1acce7edc2f31f26c432d786cdef0e73  nrpe-2.15.tar.gz
53e4060a81768058d03262ebb1f2e72b1faebc59d42b5a1deea64b917cc4d4f1ab308f122f84fe31af174198f8cfc7c13858ab91aaeb88c7b55a2d3981d22fda  stay-in-foreground.patch
4ac80b51fbde6e2a54764e5ecc83e0cbec43534cb5f29e8efc7f4b0442afe72200d5d92f1e2785c021c20a111464af6897d5e89ba467b06d3f08a324a302669d  sample-config.patch
b2f23bab97384ef8f1760c79d0cbadb4e81d4bb8134887a38662033a7f0c30480222b9ecb78c3ae276bd8b35470b3db316143f591baa2c535f5fb26c34ad2824  nrpe.initd
05a0f1f5f75345370cae3262f9988d537e24dfcbb6c14a1ff3486193625481045d0844c035f7be491e74ca9ad45ed0fae7b7005616936cc274cd7e8a851c8628  nrpe.confd"
