nrpe-2.15-r3.ebuild 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. # Copyright 1999-2015 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. inherit eutils systemd toolchain-funcs multilib user autotools
  5. DESCRIPTION="Nagios Remote Plugin Executor"
  6. HOMEPAGE="http://www.nagios.org/"
  7. SRC_URI="mirror://sourceforge/nagios/${P}.tar.gz"
  8. LICENSE="GPL-2+"
  9. SLOT="0"
  10. KEYWORDS="~alpha ~amd64 ~hppa ~ppc ~ppc64 ~sparc ~x86"
  11. IUSE="command-args minimal selinux ssl tcpd"
  12. DEPEND="ssl? ( dev-libs/openssl:0 )
  13. !minimal? ( tcpd? ( sys-apps/tcp-wrappers ) )"
  14. RDEPEND="${DEPEND}
  15. !minimal? (
  16. || ( net-analyzer/nagios-plugins net-analyzer/monitoring-plugins )
  17. )
  18. selinux? ( sec-policy/selinux-nagios )"
  19. pkg_setup() {
  20. enewgroup nagios
  21. enewuser nagios -1 /bin/bash /dev/null nagios
  22. elog "If you plan to use \"nrpe_check_control\" then you may want to specify"
  23. elog "different command and services files. You can override the defaults"
  24. elog "through the \"NAGIOS_COMMAND_FILE\" and \"NAGIOS_SERVICES_FILE\" environment variables."
  25. elog "NAGIOS_COMMAND_FILE=${NAGIOS_COMMAND_FILE:-/var/rw/nagios.cmd}"
  26. elog "NAGIOS_SERVICES_FILE=${NAGIOS_SERVICES_FILE:-/etc/services.cfg}"
  27. }
  28. src_prepare() {
  29. # Add support for large output,
  30. # http://opsview-blog.opsera.com/dotorg/2008/08/enhancing-nrpe.html
  31. epatch "${FILESDIR}"/${PN}-2.14-multiline.patch
  32. # fix configure, among others #326367, #397603
  33. epatch "${FILESDIR}"/${PN}-2.15-tcpd-et-al.patch
  34. # otherwise autoconf will overwrite the custom include/config.h.in
  35. epatch "${FILESDIR}"/${PN}-2.15-autoconf-header.patch
  36. # improve handling of metachars for security
  37. epatch "${FILESDIR}"/${PN}-2.15-metachar-security-fix.patch
  38. # Fix build with USE="-ssl".
  39. epatch "${FILESDIR}"/${PN}-2.15-no-ssl.patch
  40. sed -i -e '/define \(COMMAND\|SERVICES\)_FILE/d' \
  41. contrib/nrpe_check_control.c || die
  42. # change the default location of the pid file
  43. sed -i -e '/pid_file/s:/var/run:/run:' sample-config/nrpe.cfg.in || die
  44. # fix TFU handling of autoheader
  45. sed -i -e '/#undef/d' include/config.h.in || die
  46. eautoreconf
  47. }
  48. src_configure() {
  49. local myconf
  50. if use minimal; then
  51. myconf="--disable-tcp-wrapper --disable-command-args"
  52. else
  53. myconf="$(use_enable tcpd tcp-wrapper) $(use_enable command-args)"
  54. fi
  55. econf \
  56. --libexecdir=/usr/$(get_libdir)/nagios/plugins \
  57. --localstatedir=/var/nagios \
  58. --sysconfdir=/etc/nagios \
  59. --with-nrpe-user=nagios \
  60. --with-nrpe-group=nagios \
  61. $(use_enable ssl) \
  62. ${myconf}
  63. }
  64. src_compile() {
  65. emake -C src check_nrpe $(use minimal || echo nrpe)
  66. # Add nifty nrpe check tool
  67. $(tc-getCC) ${CPPFLAGS} ${CFLAGS} \
  68. -DCOMMAND_FILE=\"${NAGIOS_COMMAND_FILE:-/var/rw/nagios.cmd}\" \
  69. -DSERVICES_FILE=\"${NAGIOS_SERVICES_FILE:-/etc/services.cfg}\" \
  70. ${LDFLAGS} -o nrpe_check_control contrib/nrpe_check_control.c || die
  71. }
  72. src_install() {
  73. dodoc LEGAL Changelog README SECURITY \
  74. contrib/README.nrpe_check_control \
  75. $(use ssl && echo README.SSL)
  76. exeinto /usr/$(get_libdir)/nagios/plugins
  77. doexe src/check_nrpe nrpe_check_control
  78. use minimal && return 0
  79. ## NON-MINIMAL INSTALL FOLLOWS ##
  80. insinto /etc/nagios
  81. newins sample-config/nrpe.cfg nrpe.cfg
  82. fowners root:nagios /etc/nagios/nrpe.cfg
  83. fperms 0640 /etc/nagios/nrpe.cfg
  84. exeinto /usr/libexec
  85. doexe src/nrpe
  86. newinitd "${FILESDIR}"/nrpe.init nrpe
  87. systemd_dounit "${FILESDIR}/${PN}.service"
  88. insinto /etc/xinetd.d/
  89. newins "${FILESDIR}/nrpe.xinetd.2" nrpe
  90. if use tcpd; then
  91. sed -i -e '/^reload()/, /^}/ d' -e '/extra_started_commands/s:reload::' \
  92. "${D}"/etc/init.d/nrpe
  93. fi
  94. }
  95. pkg_postinst() {
  96. elog "If you are using the nrpe daemon, remember to edit"
  97. elog "the config file /etc/nagios/nrpe.cfg"
  98. if use command-args ; then
  99. ewarn ""
  100. ewarn "You have enabled command-args for NRPE. This enables"
  101. ewarn "the ability for clients to supply arguments to commands"
  102. ewarn "which should be run. "
  103. ewarn "THIS IS CONSIDERED A SECURITY RISK!"
  104. ewarn "Please read /usr/share/doc/${PF}/SECURITY.bz2 for more info"
  105. fi
  106. }