# Copyright 1999-2006 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.5.ebuild,v 1.2 2006/10/21 22:07:13 tcort Exp $ inherit eutils webapp toolchain-funcs gnuconfig #MY_P=${PN/-core}-${PV/_} DESCRIPTION="" HOMEPAGE="" SRC_URI="http://prdownloads.sourceforge.net/zenoss/zenoss-1.0.1.tar.gz" LICENSE="GPL-2" SLOT="0" KEYWORDS="-x86" IUSE="doc prebundle svn" ZEN_DIR="/usr/zenoss" ZEN_HOME="/home/zenoss" zenuser="zenoss" zenpass="zenoss" host="localhost" # mysql postgres DEPEND=">=dev-db/mysql-5.0.22 sys-devel/make svn? (dev-util/subversion) !prebundle? ( >=net-zope/zope-2.8.8 >=dev-python/epydoc-2.1 >=freetype-2.1.9 >=graphviz-2.8 >=libart_lgpl-2.3.17 libpng >=libsmi-0.4.5 >=mysql-python-1.2.0 >=nagios-plugins-1.4.3 dev-python/pycrypto >=pydot-0.9.10 >=pyparsing-1.4.3 >=pysnmp-3.4.2 >=rrdtool-1.2.11 dev-python/twistedsnmp >=sendpage-1.000001 >=twisted-2.4.0)" # not found in portage #>=simplejson-1.4 #>=twistedsnmp-0.3.13 #>=yapps-2.1.1 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 if use svn; then einfo "Trying to build Zenoss from SVN." einfo fi # enewuser [uid] [shell] [homedir] [groups] [params] enewuser zenoss -1 /bin/bash "${ZEN_HOME}" ZEN_BASHRC="${D}/${ZEN_HOME}/.bashrc" # create home directory mkdir -p ${D}/${ZEN_HOME} # Set ZENHOME and PYTHONPATH environment variables in the zenoss user # environment; add the following to the appropriate rc or profile # for your shell (e.g., .bashrc, .profile, etc.): # ZENHOME is the path to your zenoss install. PYTHONPATH lets python # find the libraries we use. #cp "${FILESDIR}/80zenoss" "${D}/etc/env.d/" echo -e "#!/usr/bin/env bash" "\n" \ "export ZENHOME=${ZEN_DIR}" "\n" \ 'export PYTHONPATH=${ZENHOME}/lib/python' "\n" \ 'export PATH=${ZENHOME}/bin:${PATH}' > "${ZEN_BASHRC}" # shut down zope einfo "Shutting down zope..." /etc/init.d/zope stop einfo ewarn "Make sure there are no stray Zenoss / Zope processes running!" einfo } src_unpack() { unpack ${A} # ppc64 may need this #gnuconfig_update } src_compile() { epatch ${FILESDIR}/GNUmakefile.patch S="${WORKDIR}/${P}" cd ${S} # replicate the install script . build-functions.sh . build-functions.sh set_vars #set_make #set_mysql MYSQLEVENTDB="events" MYSQLUSER="$zenuser" MYSQLPASS="$zenpass" ZOPEPASSWD="$zenpass" ZENHOME=${ZEN_DIR} ZOPEHOME=$ZENHOME # 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 if use prebundle; then einfo "Zenoss will now start compiling. Note that the Zenoss package" einfo "comes with pre-bundled dependencies, therefore the install" einfo "is a rather long a process. Feel free to improve the ebuild! :)" einfo if ! use svn; then # build the external libs and zenoss emake CC=$(tc-getCC) \ ZOPEPASSWORD="$ZOPEPASSWORD" \ PYTHON=$PYTHON \ ZENHOME=$ZENHOME \ DESTDIR=$DESTDIR \ SVNTAG=$SVNTAG || die "make failed" else # build from SVN SVNCMD="svn" SVNURL="http://dev.zenoss.org/svn" SVNTAG="trunk" mkdir -p "${D}/${ZEN_DIR}" cd "${D}/${ZEN_DIR}" if [ -d Products/.svn ] ; then einfo updating Zenoss from SVN svn update Products svn update bin else einfo checking out Zenoss from svn: branch ${SVNTAG} svn co ${SVNURL}/${SVNTAG}/Products Products find Products -name .cvsignore -exec rm -f '{}' \; svn co ${SVNURL}/${SVNTAG}/bin bin fi fi else # build with native deps mkdir -p "${D}/${ZEN_DIR}" #cd $(DESTDIR)$(ZENHOME) ; for i in Products bin ; do einfo installing libzenoss/$i.tar.gz ; tar -xzf libzenoss/$i.tar.gz -C "${D}/${ZEN_DIR}" done fi einfo einfo "Succeeded. :)" einfo } src_install() { # create install directories mkdir -p ${D}/${ZEN_DIR} # create a link to where the installer would install Zenoss mkdir -p ${D}/usr/local/ ln -s "${ZEN_DIR}" ${D}/usr/local/zenoss if use doc; then dodoc ${S}/*.txt dodoc ${S}/docs/* fi } src_postinst() { # create database entries webapp_sqlscript mysql ${FILESDIR}/mysql-setup.sql #create_database # 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 chown zenoss -R ${D}/${ZEN_DIR} # start the zope server start_zope } pkg_postinst() { einfo einfo "Configure sudo" einfo einfo "The daemons zenping zendisc and zensyslog need to be started as root." einfo "If you want to be able to run the zenoss control scripts while" einfo "you are the user you setup to run zenoss you might use sudo." einfo "To do so add the following to your /etc/sudoers." einfo "(fill in the correct username, hostname, and /path/to/zenoss)" einfo einfo "zenoss $(hostname) = NOPASSWD: ${ZEN_DIR}/bin/python,/bin/kill" einfo einfo "If you have env_reset setup in your sudoers file make sure that" einfo "PYTHONPATH and ZENHOME get passed properly by doing the following" einfo einfo "Defaults env_keep += \"PYTHONPATH ZENHOME\"" einfo einfo einfo "If you want zenoss to start at boot time" einfo "remember to execute:" einfo " rc-update add zenoss default" einfo #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). einfo ewarn "There seems to be a problem with clustering and the \"in" ewarn "memory\" table zenoss uses for active events. For now," ewarn "please use a single mysql instance." einfo einfo "By default, the zenoss web server will listen on port 8080." einfo "This can changed by modifying $ZEN_DIR/zope.conf and other" einfo "references to the port number in deamon configs." einfo einfo "Access the Zenoss portal" einfo einfo "Go to url http://hostname:8080/zport/dmd" einfo " username is \"admin\"" einfo " password is the one entered for Zenoss \"admin\" user" einfo } pkg_prerm() { /etc/init.d/zenoss stop }