# Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils webapp ssl-cert toolchain-funcs java-pkg DESCRIPTION="A Collaboration and Integration Server Environment" HOMEPAGE="http://www.open-xchange.org/" SRC_URI="http://mirror.open-xchange.org/download/${P}-${PR/r/}.tar.bz2 http://www.mikefetherston.ca/OX/Crystal_OX_Theme.tgz" LICENSE="GPL-2" KEYWORDS="~x86" RESTRICT="primaryuri" DBMS="mysql postgres" # see pkg_setup() IUSE="ssl doc webdav ${DBMS}" S="${WORKDIR}/${PN}-${PV}-${PR/r/}" DEPEND=">=virtual/jdk-1.4 >=dev-java/java-config-1.2 dev-java/sun-javamail-bin sys-apps/findutils app-admin/sudo sys-apps/sed net-www/webapp-config dev-java/jdom www-servers/tomcat dev-perl/XML-NamespaceSupport dev-perl/XML-SAX-Base dev-perl/Authen-SASL dev-perl/Convert-ASN1 dev-perl/perl-ldap ssl? ( dev-libs/openssl dev-perl/IO-Socket-SSL) mysql? ( dev-java/jdbc-mysql >=dev-db/mysql-4.1) postgres? (>=dev-db/postgresql-8 >=dev-java/jdbc3-postgresql-7.4 || >> " for TICKER in 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1; do # Double beep here. echo -ne "$TICKER "; echo -ne "\a" ; sleep 0.1 &>/dev/null ; sleep 0,1 &>/dev/null; echo -ne "\a" ; sleep 1; done; sleep 5 echo " " elif [ ${DBMS_COUNT} -eq 0 ] ; then echo ewarn "You did not select any supported DBMS in your USE flags." ewarn "${PN} needs tohave one database backend for storing data." echo die "No database backend selected" fi if [ -z "${OX_DBNAME}" ] ; then einfo " " ewarn "The environment \$OX_DBNAME was not set, it is used for the correct name of the database. I will take the default" ewarn "value 'open_xchange'. " einfo " " OX_DBNAME="open_xchange" FAIL=1 fi if [ -z "${OX_DBUSER}" ] ; then einfo " " ewarn "The environment \$OX_DBUSER was not set, it is used for the user accessing the database. I will take the default" ewarn "value 'open_xchange'." einfo " " OX_DBUSER="open_xchange" FAIL=1 fi if [ -z "${OX_DBPASS}" ] ; then einfo " " ewarn "The environment \$OX_DBPASS was not set, it used for accessing the database. I will take the default" ewarn "value 'xxx'." einfo " " OX_DBPASS="xxx" FAIL=1 fi if [ -z "${OX_DOMAIN}" ] ; then einfo " " ewarn "The environment \$OX_DOMAIN was not set. I will take the default" ewarn "value 'example.org'." einfo " " OX_DOMAIN="example.org" FAIL=1 fi if [ -z "${OX_ORG}" ] ; then einfo " " ewarn "The environment \$OX_ORG was not set. I will take the default" ewarn "value 'Example Org'." einfo " " OX_ORG="Example Org" FAIL=1 fi if [ -z "${OX_BASEDN}" ] ; then einfo " " ewarn "The environment \$OX_BASEDN was not set. I will take the default" ewarn "value 'dc=example,dc=org'." einfo " " OX_BASEDN="dc=example,dc=org" FAIL=1 fi if [ -z "${OX_ROOTDN}" ] ; then einfo " " ewarn "The environment \$OX_ROOTDN was not set. I will take the default" ewarn "value 'cn=Manager,${OX_BASEDN}'." einfo " " OX_ROOTDN="cn=Manager,${OX_BASEDN}" FAIL=1 fi if [ -z "${OX_ROOTPW}" ] ; then einfo " " ewarn "The environment \$OX_ROOTPW was not set, it is used for accesing the LDAP-Server." ewarn " I will take the default" ewarn "value 'secret'." einfo " " OX_ROOTPW="secret" FAIL=1 fi if [ ${FAIL} -eq 1 ] ; then ewarn "If you dont want to use the default values then hit " ewarn "to cancel and set the environment before emerging open-xchange." einfo " " echo -ne " >>> " for TICKER in 1 2 3 4 5 6 7 8; do # Double beep here. echo -ne "$TICKER " echo -ne "\a" ; sleep 0.1 &>/dev/null ; sleep 0,1 &>/dev/null echo -ne "\a" ; sleep 1 done sleep 5 echo " " fi webapp_pkg_setup } src_unpack() { unpack ${A} ; cd ${S} chmod 777 config/missing sed -i "s|touch @localstatedir@|touch \${DESTDIR}@localstatedir@|g" Makefile.am rm -rf ${S}/autom4te.cache aclocal -I m4/ && autoconf || die "reconfigure failed" libtoolize --copy --force } src_compile() { local myconf local tempvar local tomcatdir tomcatdir=`java-config -g CATALINA_HOME` SERVLETDIR="${tomcatdir}/webapps/servlet" myconf="${myconf} --with-servletdir=${SERVLETDIR}" if use doc ; then myconf="${myconf} --enable-doc" fi if use webdav ; then myconf="${myconf} $(use_enable webdav)" fi if use ssl ; then myconf="${myconf} $(use_enable ssl)" fi if use postgres ; then tempvar="$(java-config --classpath=$(java-config -l | sed -n "s:^\[\(jdbc[^-]*-postgresql[^]]*\).*:\1:p" | head -n 1))" if [[ -f "${tempvar}" && "${tempvar}" != "" ]]; then myconf="${myconf} --with-jdbcjar=$(java-config --classpath=$(java-config -l | sed -n "s:^\[\(jdbc[^-]*-postgresql[^]]*\).*:\1:p" | head -n 1))" else myconf="${myconf} --with-jdbcjar=/usr/share/jdbc3-postgresql/lib/jdbc3-postgresql.jar" fi myconf="${myconf} --with-dbdriver=org.postgresql.Driver" elif use mysql ; then tempvar="$(java-config --classpath=$(java-config -l | sed -n "s:^\[\(jdbc[^-]*-mysql[^]]*\).*:\1:p" | head -n 1))" if [[ -f "${tempvar}" && "${tempvar}" != "" ]]; then myconf="${myconf} --with-jdbcjar=$(java-config --classpath=$(java-config -l | sed -n "s:^\[\(jdbc[^-]*-mysql[^]]*\).*:\1:p" | head -n 1))" else myconf="${myconf} --with-jdbcjar=/usr/share/jdbc-mysql/lib/mysql-connector-java-3.0.11-stable-bin.jar" fi myconf="${myconf} --with-dbdriver=com.mysql.jdbc.Driver" fi if has_version '=www-servers/tomcat-5*'; then einfo "Using Tomcat5" myconf="${myconf} --with-jsdkjar=/opt/tomcat5/common/lib/servlet-api.jar" else tempvar="`for foo in $(java-config --classpath=$(java-config -l | sed -n "s:^\[\(servletapi-2\.[3456789][^]]*\)\].*:\1:p" | head -n 1)|sed "s/:/ /");do if ( echo ${foo} | grep -iq "servlet-api.jar$" ) ; then echo ${foo} ; break ; fi ; done`" if [[ -f "${tempvar}" && "${tempvar}" != "" ]]; then myconf="${myconf} --with-jsdkjar=${tempvar}" else myconf="${myconf} --with-jsdkjar=/usr/share/servletapi-2.3/lib/servlet-api.jar" fi fi # Servlet API if [ ! -z "${OX_DBNAME}" ] ; then myconf="${myconf} --with-dbname=${OX_DBNAME}" fi if [ ! -z "${OX_DBUSER}" ] ; then myconf="${myconf} --with-dbuser=${OX_DBUSER}" fi if [ ! -z "${OX_DBPASS}" ] ; then myconf="${myconf} --with-dbpass=${OX_DBPASS}" fi if [ ! -z "${OX_DOMAIN}" ] ; then myconf="${myconf} --with-domain=${OX_DOMAIN}" fi if [ ! -z "${OX_ORG}" ] ; then myconf="${myconf} --with-organization=${OX_ORG}" fi if [ ! -z "${OX_BASEDN}" ] ; then myconf="${myconf} --with-basedn=${OX_BASEDN}" fi if [ ! -z "${OX_ROOTDN}" ] ; then myconf="${myconf} --with-rootdn=${OX_ROOTDN}" fi if [ ! -z "${OX_ROOTPW}" ] ; then myconf="${myconf} --with-rootpw=${OX_ROOTPW}" fi myconf="${myconf} --with-mailjar=/usr/share/sun-javamail-bin/lib/mail.jar" myconf="${myconf} --with-activationjar=/usr/share/sun-jaf-bin/lib/activation.jar" myconf="${myconf} --with-jdomjar=$(java-config --classpath=$(java-config -l | sed -n "s:^\[\(jdom[^]]*\).*:\1:p" | head -n 1))" myconf="${myconf} --with-xercesjar=/usr/share/xerces-2/lib/xercesImpl.jar" myconf="${myconf} --with-jni-dir=$(java-config -O)/include" myconf="${myconf} --with-runuid=tomcat" myconf="${myconf} --with-rungid=tomcat" myconf="${myconf} --with-tomcatuser=tomcat" myconf="${myconf} --with-htdocsdir=${MY_HTDOCSDIR}" myconf="${myconf} --with-cgibindir=${MY_CGIBINDIR}" myconf="${myconf} --prefix=/usr" myconf="${myconf} --sysconfdir=/etc/open-xchange" myconf="${myconf} --datadir=/usr/share/open-xchange" myconf="${myconf} --includedir=/usr/include/open-xchange" myconf="${myconf} --infodir=/usr/share/info" myconf="${myconf} --mandir=/usr/share/man" myconf="${myconf} --libdir=/usr/lib/open-xchange" myconf="${myconf} --localstatedir=/var/open-xchange" econf ${myconf} || die "bad ./configure" dosed "s|oxservletdir =|oxservletdir = ${SERVLETDIR}|g" Makefile # replace the string "jikes" with "modern". We dont want to see all jikes warnings sed -i "s|jikes|modern|g" build.xml make || die "make failed" # correct ispell-handling of german dictionary sed -i "s|-ddeutsch|-dgerman|g" conf/webmail/spellcheck.cfg # create user mailadmin, needed for mailsupport enewuser mailadmin -1 -1 /dev/null users _UID=`getent passwd mailadmin | awk -F : '{print $3}'` # get the default guid of the group 'users' OX_STDGID=`getent group users | awk -F : '{print $3}'` # replace the SuSE group id 500 of users with the gentoo group id of the group 'users' for the mailadmin in ldif + uid sed -i "s|500|${OX_STDGID}|g" system/setup/init_ldap.ldif sed -i "s|501|${_UID}|g" system/setup/init_ldap.ldif # replace the SuSE standard group id 500 with the gentoo group id of the group 'users' sed -i "s|500|${OX_STDGID}|g" conf/admintools.conf OX_STDGID=`expr ${OX_STDGID} + 1` sed -i "s|501|${OX_STDGID}|g" conf/admintools.conf # use sudo instead of su for the startup script and # correct var-log for foo in groupware sessiond webmail do sed -i "s:^\([\t ]*\)\(su \$USER.*$\):\1#\2:gI;s:^\([\t ]*\)#\(sudo -u \$USER.*\)$:\1\2:gI" system/etc/init.d/${foo} sed -i "s|open-xchange/log|log/open-xchange|g" system/etc/init.d/${foo} done sed -i "s|open-xchange/log|log/open-xchange|g" conf/groupware/system.properties if use ssl; then # change login.pm-script if ssl should be used sed -i "s|connection_mode = 3;|connection_mode = 2;|g" src/misc/login/login.pm fi } src_install() { webapp_src_preinst dodoc AUTHORS ChangeLog INSTALL NEWS README # Install this big thing cd ${S} make DESTDIR=${D} install || die "Failed on make install" # remove obsolete log-files they should be saved in /var/log/open-xchange rm ${D}/var/open-xchange/log/groupware.log rm ${D}/var/open-xchange/log/jserv.log rm ${D}/var/open-xchange/log/sessiond.log rm ${D}/var/open-xchange/log/webmail.log rmdir ${D}/var/open-xchange/log # remove unneeded init-script - not used by gentoo rm ${D}/etc/open-xchange/init.d/openexchange if use ssl; then dodir /etc/open-xchange/groupware/sslcerts/oxCA dodir /etc/open-xchange/groupware/sslcerts/oxCERTS fi # copy jar # java-pkg_dojar ${D}usr/lib/open-xchange/comfiretools.jar # java-pkg_dojar ${D}usr/lib/open-xchange/intranet.jar # java-pkg_dojar ${D}usr/lib/open-xchange/nas.jar # java-pkg_dojar ${D}usr/lib/open-xchange/sessiond.jar # java-pkg_dojar ${D}usr/lib/open-xchange/webmail.jar webapp_serverowned # Init script newinitd "${FILESDIR}/open-xchange" open-xchange || \ die "newinitd failed" # Change default icon theme insinto ${MY_HTDOCSDIR}/cfintranet/images/top/EN/ insopts -m0644 doins ${WORKDIR}/*.png insinto ${MY_HTDOCSDIR}/cfintranet/images/top/DE/ doins ${WORKDIR}/*.png # create log-dir dodir /var/log/open-xchange insinto ${SERVLETDIR} doins lib/* # Install webapp webapp_src_install } pkg_postinst() { webapp_pkg_postinst chgrp -R apache /var/open-xchange/* einfo " " einfo " " einfo " ===========================================================" einfo " " einfo " You have successfully installed Open-Xchange" einfo " " einfo " ===========================================================" einfo " " einfo " o FILE LOCATIONS" einfo " 1. Configuration: /etc/open-xchange" einfo " 2. HTML Files: /usr/share/open-xchange" einfo " " einfo " o STARTING and STOPPING the Open-Xchange" einfo " /etc/init.d/openexchange start" einfo " /etc/init.d/openexchange stop" einfo " /etc/init.d/openexchange restart" einfo " " einfo "Execute the following command" einfo "ebuild /var/db/pkg/www-apps/${PF}/${PF}.ebuild config" einfo "to setup the initial open-xchange environment." einfo " " if use ssl; then einfo "Open-Xchange has been compiled with SSL-support." einfo "This means communication between OX-components is encrypted too." einfo "" if [[! -f /etc/open-xchange/groupware/sslcerts/oxCERTS/groupwarekey.pem || ! -f /etc/open-xchange/groupware/sslcerts/oxCERTS/groupwarecert.pem || ! -f /etc/open-xchange/groupware/sslcerts/oxCERTS/sessiondkey.pem || ! -f /etc/open-xchange/groupware/sslcerts/oxCERTS/sessiondcert.pem || ! -f /etc/open-xchange/groupware/sslcerts/oxCA/cacert.pem]]; then ewarn "No or not all keys and certificates found" ewarn "You have to create key: '/etc/open-xchange/groupware/sslcerts/oxCERTS/groupwarekey.pem'" ewarn "You have to create certificate: '/etc/open-xchange/groupware/sslcerts/oxCERTS/groupwarecert.pem'" ewarn "You have to create key: '/etc/open-xchange/groupware/sslcerts/oxCERTS/sessiondkey.pem'" ewarn "You have to create certificate: '/etc/open-xchange/groupware/sslcerts/oxCERTS/sessiondcert.pem'" ewarn "You have to create CA-certificate: '/etc/open-xchange/groupware/sslcerts/oxCA/cacert.pem'" ewarn "If you are redirected to login-screen after login, you should generate Certificate-files and -keys" ewarn "" ewarn "or disable support by editing '/etc/open-xchange/groupware/system.properties'" ewarn "and change line 'ENABLETLS:yes' to 'ENABLETLS:no'" ewarn "this must be also done for '/etc/open-xchange/webmail/system.properties'." fi fi } pkg_config() { dosym /etc/openldap/ldap.conf /etc/open-xchange/groupware/ldap.conf dosym /etc/openldap/ldap.conf /etc/open-xchange/webmail/ldap.conf dosym /usr/share/open-xchange/openxchange.schema /etc/openldap/schema correctfilespool # ewarn "Postgres-Database is setup" # ewarn "to cancel." # einfo " " # echo -ne " >>> " # for TICKER in 1 2 3 4 5 6 7 8; do # # Double beep here. # echo -ne "$TICKER " # echo -ne "\a" ; sleep 0.1 &>/dev/null ; sleep 0,1 &>/dev/null # echo -ne "\a" ; sleep 1 # done # sleep 5 # echo " " # su postgres -c "createuser -- }