# 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 samba 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} pkg_setup() { if use apache && ! use nosuidcgi && ! built_with_use perl perlsuid; then ewarn "You must have perl installed with perlsuid use flag in order to" ewarn "use the 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 ${A} # Adjust the configure script to make BackupPC run as the apache user cd ${S} if use nosuidcgi && use apache; 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}/${PN}.rc backuppc newconfd ${FILESDIR}/${PN}.conf backuppc # If we dont want cgi interface install docs in /usr/share/doc if ! use apache; 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 && use apache; 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 ! use apache; 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 ! use apache; then rm -fr ${D}/usr/share/webapps rm -fr ${D}/var/db fi } pkg_postinst() { if use apache; then webapp_pkg_postinst fi # Post install informations if use nosuidcgi && use apache; then echo "" ewarn "WARNING! BackupPC is configured to run as the apache user" ewarn "by default. This is a potential security hazard!" fi if use apache; 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" 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 }