# Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-x86/net-analyzer/nagios-core/nagios-core-2.0b_p2.ebuild,v 1.2 2005/06/25 20:26:07 vanquirius Exp $ inherit eutils depend.apache toolchain-funcs MY_P=${PN/-core}-${PV/_p} DESCRIPTION="Nagios Core - Check daemon, CGIs, docs" HOMEPAGE="http://www.nagios.org/" SRC_URI="mirror://sourceforge/nagios/${MY_P}.tar.gz" LICENSE="GPL-2" SLOT="0" KEYWORDS="~x86 ~sparc ~ppc ~amd64" IUSE="perl debug apache2 noweb" DEPEND="virtual/mailx !noweb? ( >=media-libs/gd-1.8.3-r5 ${APACHE_DEPEND} ) perl? ( >=dev-lang/perl-5.6.1-r7 )" S="${WORKDIR}/${MY_P}" # FIXED: # # do not use command output, use built_with_use instead # this ebuild doesn't directly DEPEND on libpng or jpeg, gd does, see pkg_setup # for more info # * bug #12483 # # 'USE="jpeg" emerge gd' doesn't work for csh users # # user nagios shouldn't have shell # # remove duplicated myconf # # drop "contrib", if you really need them, write nagios-contrib ebuild # * bug #24865 # * eventually, we'll need "(no)contrib" USE flag which makes things # complicated further (what if a contrib script has additional (R)DEPEND?) # * just being useful is not sufficient to be included # * the scripts in contrib is not that useful # * convertcfg.c: old "host" config has been deprecated for years # * daemonchk.cgi: doesn't work for 2.x # * htaccess.sample: could be useful # * nagios-2 doesn't have RDBMS support anymore # * eventhandler/ which is mentioned in the documentation should be installed # # remove "dodoc SAMPLE_FILES", install them into /etc/${PN} instead # drop dodoc and gunzip sample files, let "make install-config" do the job # * bug #103945 bug #69415 # * bug #39926 http://bugs.gentoo.org/show_bug.cgi?id=39926#c8 # * no, sample configs should be installed in /etc/${PN} because users will # notice the nice diff when upstream changes default value, syntax or other # things in examples. additionally, you don't have to merge real config and # example one. this is NOT nagios-specific. # * always use # insinto /etc/${PN} # newins ${PN}.conf ${PN}.conf-dist # instead of # insinto /etc/${PN} # doins /etc/${PN}.conf # never do if you cannot catch up with upstream # insinto /etc/${PN} # doins MY_ORIGINAL_EXAMPLE_CONFIG.conf # * docs/config.html mentions it's installed "into your settings directory" # * see bug #103945 # # use doinitd instead of newexe # # sed needs to die() if failed # # add MY_NAGIOS_* variables, if set correctly, ./configure and 'make # install' should take care of the permission issue # # use econf instead of ./configure # BUG: # virtual/httpd or something is needed # * Nagios should run on any CGI-enabled web server # TODO: # proper migration step from older version should be considered # make sure noweb USE works (it doesn't yet) pkg_setup() { # this ebuild doesn't directly DEPEND on libpng or jpeg, gd does # TODO: # make sure nagios can display GIF but not PNG or JPEG without +png +jpeg # * http://bugs.gentoo.org/show_bug.cgi?id=12483 # * successfully compiled nagios-core with gd '-jpeg -png' if ! use noweb ; then if ! built_with_use gd jpeg ; then einfo "Your gd has been compiled without jpeg support." einfo "If you want JPEG images in the CGI," einfo "re-emerge gd with jpeg USE flag enabled." fi if ! built_with_use gd png ; then einfo "Your gd has been compiled without png support." einfo "If you want PNG images in the CGI," einfo "re-emerge gd with png USE flag enabled." fi fi enewgroup nagios # BUG: # who needs nagios user with shell access? # if you do, explain why enewuser nagios -1 -1 /dev/null nagios # BUG: # docs/installing.html suggests group "nagcmd" # * what should i do if USE=noweb # * work on this later # usermod -G apache nagios } src_unpack() { unpack ${A} cd ${S} epatch ${FILESDIR}/2.x-series-nsca.patch # BUG: # consider to drop # http://bugs.gentoo.org/show_bug.cgi?id=103945 # gunzip -c ${FILESDIR}/nagios.cfg-sample.gz > ./nagios.cfg-sample } src_compile() { local myconf local MY_NAGIOS_USER local MY_NAGIOS_GROUP local MY_NAGIOS_CMD_GROUP MY_NAGIOS_USER="nagios" MY_NAGIOS_GROUP="nagios" MY_NAGIOS_CMD_GROUP="apache" if use noweb ; then MY_NAGIOS_CMD_GROUP="nagios" fi if use perl then myconf="${myconf} --enable-embedded-perl --with-perlcache" fi if use debug; then myconf="${myconf} --enable-DEBUG0" myconf="${myconf} --enable-DEBUG1" myconf="${myconf} --enable-DEBUG2" myconf="${myconf} --enable-DEBUG3" myconf="${myconf} --enable-DEBUG4" myconf="${myconf} --enable-DEBUG5" fi # strip cgi-related parts from Makefile.in # CGI is not required in distributed monitoring environment # i'm not for it but don't drop noweb USE flag, either # BUG: # ugly, a simple patch should be fine if use noweb ; then sed -i -e 's/^[[:space:]]*cd $(SRC_CGI) && $(MAKE).*/# noweb USE flag/g' Makefile.in \ || die "sed failed" sed -i -e 's/^[[:space:]]*cd $(SRC_HTM) && $(MAKE).*/# noweb USE flag/g' Makefile.in \ || die "sed failed" fi # TODO: # update apache conf accordingly econf \ --host=${CHOST} \ --prefix=/usr \ --sbindir=/usr/libexec/nagios/cgi-bin \ --datadir=/usr/share/nagios \ --libexecdir=/usr/libexec/nagios \ --localstatedir=/var/lib/nagios \ --sysconfdir=/etc/nagios \ --infodir=/usr/share/info \ --mandir=/usr/share/man \ --with-nagios-user=${MY_NAGIOS_USER} \ --with-nagios-group=${MY_NAGIOS_GROUP} \ --with-command-group=${MY_NAGIOS_CMD_GROUP} \ ${myconf} || die "econf failed" emake all || die "emake failed" } src_install() { dodoc Changelog INSTALLING LEGAL LICENSE README UPGRADING use noweb || dodoc contrib/htaccess.sample # BUG: # where should it be? # TODO: # einfo /usr/libexec/nagios/eventhandler exeinto /usr/libexec/nagios/eventhandlers local MY_FILES MY_FILES=`find contrib/eventhandlers -type f` doexe ${MY_FILES} # BUG: # what's is this all about? # > sed -e 's/^contactgroups$//g' Makefile > Makefile.sed # > diff -u Makefile Makefile.sed # shows nothing. # sed -i -e 's/^contactgroups$//g' Makefile || die "sed failed" make DESTDIR="${D}" install make DESTDIR="${D}" install-config make DESTDIR="${D}" install-commandmode # BUG: # consider to drop # "make install-config" installs example config into /etc/${PN} #-------------------------------------------------- # docinto sample-configs # dodoc ${D}/etc/nagios/* # rm ${D}/etc/nagios/* #-------------------------------------------------- # dodoc ${S}/nagios.cfg-sample doinitd ${FILESDIR}/nagios newconfd ${FILESDIR}/conf.d nagios #-------------------------------------------------- # # TODO: # # do we still need this? if so, upstream should fix # for dir in etc/nagios usr/nagios var/nagios # do # chown -R nagios:nagios ${D}/${dir} || die "Failed chown of ${D}/${dir}" # done #-------------------------------------------------- # BUG: # make sure it works in new apache environment, which i don't have (yet) # change 99_nagios.conf accordingly #Apache Module if ! noweb ; then if use apache2; then insinto ${APACHE2_MODULES_CONFDIR} doins ${FILESDIR}/99_nagios.conf else insinto ${APACHE1_MODULES_CONFDIR} doins ${FILESDIR}/nagios.conf fi fi } pkg_preinst() { # BUG: # einfo what users should do to deinstall nagios-core completely # cfgpro takes care of this # keepdir /etc/nagios keepdir /var/lib/nagios keepdir /var/lib/nagios/archives if ! noweb ; then # BUG: # by default, nothing is installed in ssi keepdir /usr/share/nagios/ssi fi keepdir /var/lib/nagios/rw # BUG: # ./configure takes care of this # drwxrwsr-x 2 nagios apache 48 Sep 21 12:39 rw/ # * bug #76011 #-------------------------------------------------- # chown nagios:apache ${D}/var/lib/nagios/rw || die "Failed Chown of ${D}/var/lib/nagios/rw" # chmod ug+s ${D}/var/lib/nagios/rw || die "Failed Chmod of ${D}/var/lib/nagios/rw" #-------------------------------------------------- } pkg_postinst() { einfo einfo "The example config files are located at /usr/share/doc/${PF}/sample-configs/." einfo einfo "Also, if you want nagios to start at boot time" einfo "remember to execute:" einfo " rc-update add nagios default" einfo if use apache2; then einfo " Edit /etc/conf.d/apache2 and add \"-D NAGIOS\"" else einfo " Edit /etc/conf.d/apache and add \"-D NAGIOS\"" fi einfo einfo "That will make nagios's web front end visable via" einfo "http://localhost/nagios/" einfo einfo # BUG: # what should users do, then? einfo "If your kernel has /proc protection, nagios" einfo "will not be happy as it relies on accessing the proc" einfo "filesystem. You can fix this by adding nagios into" einfo "the group wheel, but this is not recomended." einfo } pkg_prerm() { /etc/init.d/nagios stop }