# Copyright 1999-2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 inherit eutils webapp toolchain-funcs gnuconfig #MY_P=${PN/-core}-${PV/_} DESCRIPTION="Zenoss Core is an enterprise-grade network and systems monitoring product" HOMEPAGE="http://www.zenoss.com" SRC_URI="http://prdownloads.sourceforge.net/zenoss/zenoss-${PV}.tar.gz" LICENSE="GPL-2" SLOT="0" KEYWORDS="-x86" IUSE="prebundle" ZEN_DIR="/usr/zenoss" ZEN_HOME="/home/zenoss" zenuid="zenoss" zenpass="zenoss" zengid="zenoss" zendb="events" host="localhost" RDEPEND=">=dev-db/mysql-5.0.22 >=dev-lang/python-2.3.4 !prebundle? ( =dev-python/epydoc-2.1 >=media-libs/freetype-2.1.9 >=media-gfx/graphviz-2.8 >=media-libs/libart_lgpl-2.3.17 media-libs/libpng >=net-libs/libsmi-0.4.5 >=net-analyzer/nagios-plugins-1.4.3 dev-python/pycrypto >=dev-python/pydot-0.9.10 >=dev-python/pyparsing-1.4.3 >=net-analyzer/rrdtool-1.2.11 >=net-dialup/sendpage-1.000001 >=dev-python/twisted-2.4.0 >=dev-python/simplejson-1.4 >=yapps-2.1.1 =twistedsnmp-0.3.13 =dev-python/pysnmp-3.4.3 =dev-python/mysql-python-1.2.0-r1)" # twistedsnmp, pysnmp and mysql-python ebuilds # are patched with zenoss-patches, and are in this stage # tied to specific versions. DEPEND="sys-devel/make >=app-admin/zope-config-0.5" pkg_setup() { # check useflags if use prebundle; then einfo einfo "You are building Zenoss with the pre-bundled dependencies." einfo else einfo einfo "You are building Zenoss with native dependencies." einfo fi ewarn "Make sure there are no stray Zenoss processes running!" einfo einfo "Creating a new Zope instance..." einfo # deduce the zope lib dir, use last found local zopedir="$(/bin/ls -d /usr/lib/zope* | tail -n 1)" zope-config --zserv=${zopedir} --zinst=${ZEN_DIR} --zgid=${zengid} \ --zuid=${zenuid} --zinituser &>/dev/null [ $? -eq 1 ] && einfo "Failed to create the Zope instance." && exit 1 elog "New Zope instance 'zenoss' created to $ZEN_DIR." einfo # this also creates /etc/init.d/zenoss, zenuser, zenhome # enewuser [uid] [shell] [homedir] [groups] [params] #enewuser zenoss -1 /bin/bash "${ZEN_HOME}" # enewuser doesn't create the home under ${D}??! # NAGIOS ----------- # sed -i -e 's/^contactgroups$//g' Makefile # # make DESTDIR=${D} install # make DESTDIR=${D} install-config # make DESTDIR=${D} install-commandmode # # docinto sample-configs # dodoc ${D}/etc/nagios/* # rm ${D}/etc/nagios/* # # newdoc ${WORKDIR}/nagios-2.0b.cfg-sample nagios.cfg-sample # # #contribs are not configured by the configure script, we'll configure them overselves... # find ${S}/contrib/ -type f | xargs sed -e 's:/usr/local/nagios/var/rw:/var/nagios/rw:; # s:/usr/local/nagios/libexec:/usr/nagios/libexec:; # s:/usr/local/nagios/etc:/etc/nagios:; # s:/usr/local/nagios/sbin:/usr/nagios/sbin:;' -i # # insinto /usr/share/doc/${PF}/contrib # doins -r contrib/eventhandlers # # exeinto /etc/init.d # doexe ${FILESDIR}/nagios # # insinto /etc/conf.d # newins ${FILESDIR}/conf.d nagios # # chmod 644 ${S}/contrib/*.cgi # into /usr/nagios # for bin in `find contrib/ -type f -perm 0755 -maxdepth 1` ; do # dobin $bin # done # # # Apache Module # if use !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 # if use perl; then # into /usr/nagios ; dosbin contrib/traceroute.cgi # fi # fi # # for dir in etc/nagios usr/nagios var/nagios ; do # chown -R nagios:nagios ${D}/${dir} || die "Failed chown of ${D}/${dir}" # done # # keepdir /etc/nagios # keepdir /var/nagios # keepdir /var/nagios/archives # keepdir /usr/nagios/share/ssi # keepdir /var/nagios/rw # # if use noweb; then # chown -R nagios:nagios ${D}/var/nagios/rw || die "Failed Chown of ${D}/var/nagios/rw" # else # chown -R nagios:apache ${D}/var/nagios/rw || die "Failed Chown of ${D}/var/nagios/rw" # fi # # chmod ug+s ${D}/var/nagios/rw || die "Failed Chmod of ${D}/var/nagios/rw" # chmod 0750 ${D}/etc/nagios || die "Failed chmod of ${D}/etc/nagios" } src_unpack() { unpack ${A} cd ${S} epatch ${FILESDIR}/GNUmakefile.patch # unpack libzenoss (to $S) for i in Products bin ; do tar -xzf libzenoss/$i.tar.gz done } #src_compile() { # local myconf # # 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 # # if use noweb; then # myconf="${myconf} --with-command-grp=nagios" # else # myconf="${myconf} --with-command-grp=apache" # fi # # ./configure ${myconf} \ # --host=${CHOST} \ # --prefix=/usr/nagios \ # --localstatedir=/var/nagios \ # --sysconfdir=/etc/nagios \ # --infodir=/usr/share/info \ # --mandir=/usr/share/man \ # ${myconf} || die "./configure failed" # # emake CC=$(tc-getCC) nagios || die "make failed" # # if use !noweb ; then # # Only compile the CGI's if "noweb" useflag is not set. # make CC=$(tc-getCC) DESTDIR=${D} cgis || die # fi # # emake -C contrib all || "contrib make filed" # #} src_compile() { if use prebundle; then # build as the installer script would do it; # use the bundled dependencies S="${WORKDIR}/${P}" cd ${S} einfo "Following the bundled install script -" ewarn "This may cause sandbox to get alarmed." ewarn # replicate the install script . build-functions.sh . install-functions.sh set_vars # set other internal variables MYSQLEVENTDB="$zendb" MYSQLUSER="$zenuid" MYSQLPASS="$zenpass" ZOPEPASSWD="$zenpass" ZENHOME=${ZEN_DIR} ZOPEHOME=${ZENHOME} #set_make #set_mysql # performs safety checks to make sure the environment is good for install: check_preexist # handle situation where installation already exists check_perf # preserve performance data check_mysql # make sure that variables are set and directories exist check_mysql_config # make sure mysql development environment exists # purge the last backup purge_backup elog "Zenoss will now start compiling. Note that the Zenoss package" elog "comes with pre-bundled dependencies, therefore the install" elog "is a rather long a process." elog emake CC=$(tc-getCC) \ ZOPEPASSWORD="$ZOPEPASSWORD" \ PYTHON=$PYTHON \ ZENHOME=$ZENHOME \ DESTDIR=$DESTDIR \ SVNTAG=$SVNTAG || die "make failed" einfo elog "Build successful. :)" elog fi } src_install() { # create install directories dodir ${ZEN_DIR} into ${ZEN_DIR} if ! use prebundle; then # unpack the Zenoss core Product einfo "Installing Zenoss binaries" dobin bin/* einfo "Installing Zenoss Products" # if doins cannot copy recursively, cp #insinto "${ZEN_DIR}/Products" #doins Products/* cp -r "${S}/Products" "${D}/${ZEN_DIR}" einfo "Installing configuration files" insinto /etc/zenoss/ doins conf/* fi # Set environment variables in the zenoss user environment echo -e "#!/usr/bin/env bash" "\n" \ "export ZENHOME=${ZEN_DIR}" "\n" \ 'export PYTHONPATH=${ZENHOME}/lib/python' "\n" \ 'export PATH=${ZENHOME}/bin:${PATH}' > "${S}/.bashrc" insinto "${ZEN_HOME}" doins "${S}/.bashrc" #ZEN_BASHRC="${D}/${ZEN_HOME}/.bashrc" # install docs dodoc ${S}/*.txt cd ${S}/docs dodoc Zenoss* # the directories below contain jpg, doc and pdf files. # any way to get them recursively into docdir and not gzipped? docinto Admin_Guide_1.0_Screens dodoc Admin_Guide_1.0_Screens/* docinto QuickStartGuide-1.0 dodoc QuickStartGuide-1.0/Zenoss* docinto QuickStartGuide-1.0/QuickStartScreens dodoc QuickStartGuide-1.0/QuickStartScreens/* } pkg_postinst() { if ! use prebundle; then # create database entries einfo "Creating database entries..." webapp_sqlscript mysql ${FILESDIR}/mysql-setup.sql #create_database else # finish as the installer script would do it; S="${WORKDIR}/${P}" cd ${S} # load functions . build-functions.sh . install-functions.sh # load the events database with some initial data run_zeneventbuild # create a zope instance for zenoss #run_mkzopeinstance # create the zeodb run_mkzeoinstance # start up zeodb start_zeodb # wait for processes to start up sleep 2 # populate the zeodb run_zenbuild fi chown zenoss -R ${D}/${ZEN_DIR} } pkg_postrm() { elog elog "The daemons zenping zendisc and zensyslog need to be started as root." elog "To do so add the following to your /etc/sudoers." elog elog "${zenuid} $(hostname) = NOPASSWD: ${ZEN_DIR}/bin/python,/bin/kill" elog elog "If you have env_reset setup in your sudoers file make sure that" elog "PYTHONPATH and ZENHOME get passed properly by doing the following" elog elog "Defaults env_keep += \"PYTHONPATH ZENHOME\"" elog elog "You are adviced to look into /etc/zenoss/sudoers." elog #This script will create several tables as well as a trigger #to move events from status -> history on deletion. This #trigger requires "SUPER" permission which is granted to root #by default (but can be granted to other users manually). elog elog "There seems to be a problem with clustering and the \"in" elog "memory\" table zenoss uses for active events. For now," elog "please use a single mysql instance." elog elog "Access the Zenoss portal" elog "------------------------" elog "By default, the zenoss web server will listen on port 8080." elog "This can changed by modifying $ZEN_DIR/etc/zope.conf and other" elog "references to the port number in deamon configs." elog elog "Go to url http://$(hostname):8080/zenoss/dmd" elog "Use the username ($zenuid) and password ($zenpass)." elog elog "If you want zenoss to start at boot time" elog "remember to execute:" elog " rc-update add zenoss default" elog }