# Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils webapp depend.apache DESCRIPTION="BackupPC is a high-performance, enterprise-grade backup system" HOMEPAGE="http://backuppc.sourceforge.net/" SRC_URI="mirror://sourceforge/backuppc/BackupPC-${PV}.tar.gz" LICENSE="GPL-2" KEYWORDS="~x86" IUSE="apache nosuidcgi" DEPEND=">=dev-lang/perl-5.6.0" RDEPEND="${DEPEND} app-arch/bzip2 app-arch/par2cmdline virtual/ssh dev-perl/Archive-Zip dev-perl/Compress-Zlib >=dev-perl/File-RsyncP-0.52 >=net-misc/rsync-2.5.5 >=app-arch/tar-1.13.7 samba? (>=net-fs/samba-2.2.0) apache? (net-www/apache)" MY_P="BackupPC-${PV}" S=${WORKDIR}/${MY_P} if use apache; then CGI=true else CGI=false fi pkg_setup() { if ${CGI} && ! use nosuidcgi && ! built_with_use perl perlsuid; then ewarn "You must have perl installed with perlsuid use flag in order to" ewarn "use cgi interface!" die fi webapp_pkg_setup # We want to work as backuppc user if ! use nosuidcgi; then enewgroup backuppc enewuser backuppc -1 /bin/bash /var/lib/backuppc backuppc fi } src_unpack() { unpack BackupPC-${PV}.tar.gz cd BackupPC-${PV} # Adjust the configure script to make BackupPC run as the apache user if use nosuidcgi && ${CGI}; then sed -i -r 's/\$Conf\{BackupPCUser\} \|\| "backuppc",/$Conf\{BackupPCUser\} \|\| "apache",/' configure.pl fi } src_install () { webapp_src_preinst cd ${S} perl configure.pl \ --batch \ --dest-dir ${D} \ --cgi-dir ${MY_CGIBINDIR}/backuppc \ --data-dir /var/lib/backuppc \ --hostname $(hostname) \ --html-dir ${MY_HTDOCSDIR} \ --html-dir-url /backuppc \ --install-dir /usr \ --uid-ignore \ &> /dev/null # Install conf.d and init.d files newinitd ${FILESDIR}/init-script backuppc newconfd init.d/gentoo-backuppc.conf backuppc # If we dont want cgi interface install docs in /usr/share/doc if ! ${CGI};then dodoc doc/*.pod dohtml doc/*.html rm -fr ${D}/usr/doc fi # Install apache configuration for cgi dir if use apache; then if [ -d ${APACHE2_MODULES_CONFDIR} ]; then insinto ${APACHE2_MODULES_CONFDIR} newins ${FILESDIR}/backuppc_apache_module backuppc.conf elif [ -d ${APACHE1_MODULES_CONFDIR} ]; then insinto ${APACHE1_MODULES_CONFDIR} newins ${FILESDIR}/backuppc_apache_module backuppc.conf else die "There is no apache module confdir" fi fi # Take care about permission on cgi file if use nosuidcgi && ${CGI}; then webapp_hook_script ${FILESDIR}/hook elif ! use nosuidcgi && ${CGI}; then webapp_hook_script ${FILESDIR}/hook_suid fi webapp_src_install # Set minimal permission for /var/lib/backuppc/* for i in `find ${D}var/lib/backuppc`; do if ! ${CGI}; then fowners backuppc:backuppc ${i/*image/} elif use nosuidcgi; then fowners apache:apache ${i/*image/} elif ! use nosuidcgi; then fowners backuppc:backuppc ${i/*image/} fi if [ -f $i ]; then fperms 0640 ${i/*image/} fi if [ -d $i ]; then fperms 0750 ${i/*image/} fi done # Set permission for binary files for i in `find ${D}usr/bin/*`; do fperms 0755 ${i/*image/} done dodir etc/backuppc insinto etc/backuppc touch ${D}etc/backuppc/htpasswd fowners apache:apache etc/backuppc/htpasswd fperms 0660 etc/backuppc/htpasswd # If users dont want to use cgi interface - dont even install it... if ! ${CGI}; then rm -fr ${D}usr/share/webapps rm -fr ${D}var/db fi } pkg_postinst() { if ${CGI}; then webapp_pkg_postinst fi # Post install informations if use nosuidcgi && ${CGI}; then echo "" ewarn "WARNING! BackupPC is configured to run as the apache user" ewarn "by default. This is a potential security hazard!" fi if ${CGI}; then echo "" einfo "Dont forget to restart your apache to load appropriate backuppc" einfo "conf!" echo "" einfo "If you want to set a password for cgi interface, you can do it" einfo "by:" einfo "htpasswd2 /etc/backuppc/htpasswd USERNAME" echo "" einfo "You can find CGI interface at:" einfo "http://http://localhost/cgi-bin/backuppc/BackupPC_Admin" fi if ${CGI}; then echo "" einfo "If you had emerge backuppc before, and now change nosuidcgi" einfo "flag, you must execute the following command now:" if use nosuidcgi; then einfo "chown -R apache:apache /var/lib/backuppc" else einfo "chown -R backuppc:backuppc /var/lib/backuppc" fi echo "" fi }