# Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit webapp DESCRIPTION="Groupware server, built on apache, postfix, openldap and cyrus-imapd" # Homepage, not used by Portage directly but handy for developer reference HOMEPAGE="http://kolab.org/" # Point to any required sources; these will be automatically downloaded by # Portage. RPM_FILE="kolab-1.0-1.0.20" SRC_URI="http://www.erfrakon.de/projects/kolab/download/kolab-server-1.0/src/${RPM_FILE}.src.rpm" LICENSE="GPL" # SLOT="0" #KEYWORDS="~amd64" KEYWORDS="~x86" inherit eutils IUSE="" DEPEND="app-arch/rpm2targz net-mail/cyrus-imapd mail-mta/postfix >=net-www/apache-2.0.0 dev-php/mod_php dev-perl/URI dev-perl/perl-ldap dev-perl/Net-Netmask dev-perl/File-NCopy dev-perl/TermReadKey net-nds/openldap net-mail/cyrus-imap-admin net-www/webapp-config " # Run-time dependencies, same as DEPEND if RDEPEND isn't defined: #RDEPEND="" pkg_setup() { # Maybe we should not use a kolab user.. # kolab needs to be able to update the config file => runs as root? enewgroup kolab 95 enewuser kolab 95 /bin/false /var/kolab kolab webapp_pkg_setup einfo "Installing into ${ROOT}${HTTPD_ROOT}." } src_unpack() { cd ${WORKDIR} rpm2targz ${DISTDIR}/${RPM_FILE}.src.rpm || die "Failed to convert rpm 2 targz" tar xzvf ${RPM_FILE}.src.tar.gz || die "Failed untar targz" tar xzvf kolab-1.0.tar.gz || die "Failed untar second targz" epatch ${FILESDIR}/${P}-root_dir.patch || die "Failed to patch config files" cp ${FILESDIR}/${P}-init.d rc.kolab || die "Could not find kolab's init script" cp ${FILESDIR}/41_mod_ssl.default-vhost.conf.template . || die "Could not find kolab's init script" } src_compile() { cd ${WORKDIR} einfo "Replacing user:group settings in httpd.conf.template" sed -i -e 's;@l_nusr@;apache;g' httpd.conf.template || die "sed failed" sed -i -e 's;@l_ngrp@;apache;g' httpd.conf.template || die "sed failed" einfo "Replacing user:group settings in kolab_bootstrap" sed -i -e "s;@@@l_musr@@@;root;g" kolab_bootstrap || die "sed failed" sed -i -e "s;@@@l_rgrp@@@;root;g" kolab_bootstrap || die "sed failed" einfo "Replacing user:group settings in main.cf.template" sed -i -e "s;@@@l_musr@@@;postfix;g" main.cf.template || die "sed failed" sed -i -e "s;@@@l_rgrp@@@;postdrop;g" main.cf.template || die "sed failed" sed -i -e "s;@@@l_nusr@@@;nobody;g" main.cf.template || die "sed failed" einfo "Replacing user:group settings in proftpd.conf.template" sed -i -e 's;@@@l_nusr@@@;proftpd;g' proftpd.conf.template || die "sed failed" ## Setting the ldap user id sed -i -e "s;@@@l_nuid@@@;`grep "ldap" /etc/passwd | sed -e "s:ldap\:x\:\([0-9]*\).*:\1:g"`;g" proftpd.conf.template || die "sed failed" sed -i -e 's;@@@l_ngrp@@@;proftpd;g' proftpd.conf.template || die "sed failed" ## Setting the group id of ldap sed -i -e "s;@@@l_ngid@@@;`grep "ldap" /etc/passwd | sed -e "s:ldap\:x\:\([0-9]*\)\:\([0-9]*\).*:\2:g"`;g" proftpd.conf.template || die "sed failed" } src_install() { webapp_src_preinst cd ${WORKDIR} dodir /etc/kolab fperms 755 /etc/kolab dodir /var/kolab/ dodir /var/kolab/log fperms 750 /var/kolab/log exeinto /etc/init.d/ cp rc.kolab ${D}/etc/init.d/kolab fperms 755 /etc/init.d/kolab # kolab should update our webapp repository sed -i -e "s;@@@php_vars@@@;${MY_HTDOCSDIR}/admin/include/session_vars.php;g" kolab || die "sed failed" # gets overwritten later #install -c -m 740 kolab_sslcert.sh ${D}/etc/kolab/ insinto /etc/kolab/ for x in *.template *.conf; do doins $x && fperms 640 /etc/kolab/$x || die "Error while installing $x" done dodir /etc/openldap/ dodir /etc/openldap/schema insinto /etc/openldap/schema doins kolab.schema chown ldap:ldap ${D}/etc/openldap/schema/kolab.schema exeinto /etc/kolab/ for x in kolab kolab_bootstrap workaround.sh kolab_sslcert.sh; do doexe $x || die "Error while installing $x" done fperms 0600 /etc/kolab/kolab.conf || die "could not set perms" fperms 0600 /etc/kolab/main.cf.template || die "could not set perms" # install -c -m 640 proftpd.group.template ${D}/etc/kolab/ # install -c -m 640 proftpd.passwd.template ${D}/etc/kolab/ cp -r admin/ ${D}${MY_HTDOCSDIR} # add an empty session vars file touch ${D}${MY_HTDOCSDIR}/admin/include/session_vars.php # Identify any script files that need #! headers adding to run under # a CGI script (such as PHP/CGI) # # for kolab, we *assume* that all .php files that don't end in # .inc.php need to have CGI/BIN support added for x in `find . -name '*.php' -print | grep -v 'inc.php'` ; do webapp_runbycgibin php ${MY_HTDOCSDIR}/$x done webapp_src_install } pkg_postinst() { einfo ewarn "Look at all .template files in /etc/kolab/ these files will replace your system configuration!" ewarn "Try to merge your previous configuration into these template files, before proceeding" ewarn "Kolab will use these template files:" ewarn "/etc/kolab/session_vars.php.template for ${MY_HTDOCSDIR}/admin/include/session_vars.php" ewarn "/etc/kolab/main.cf.template for /etc/postfix/main.cf" ewarn "/etc/kolab/master.cf.template for /etc/postfix/master.cf" ewarn "/etc/kolab/saslauthd.conf.template for /etc/saslauthd.conf" ewarn "/etc/kolab/imapd.conf.template for /etc/imapd.conf" ewarn "/etc/kolab/httpd.conf.template for /etc/apache2/conf/vhosts/kolab_admin.conf" ewarn "/etc/kolab/legacy.conf.template for /etc/apache2/conf/legacy.conf" ewarn "/etc/kolab/41_mod_ssl.default-vhost.conf.template for /etc/apache2/conf/modules.d/41_mod_ssl.default-vhost.conf", ewarn "/etc/kolab/php.ini.template for /etc/apache2/conf/php.ini" ewarn "/etc/kolab/proftpd.conf.template for /etc/proftpd/proftpd.conf" ewarn "/etc/kolab/slapd.conf.template for /etc/openldap/slapd.conf" einfo einfo "For a fresh install please initialize Kolab and run /etc/kolab/kolab_bootstrap -b' as user root." einfo "This will create your ldap database, basic ldap users, self-signed certificates configure the" einfo "host and domain name and create the configuration files of all servers" einfo "If you upgraded from a previous version simply refresh Kolab and run '/etc/kolab/kolab -o -v' as user root." einfo "In every case execute '/etc/init.d/kolab restart' as user root." einfo "After having created your basic configuration you should run webapp-config to install the admin frontend." }