1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit depend.apache eutils user systemd
11 DESCRIPTION="High-performance backups to a server's disk"
12 HOMEPAGE="http://backuppc.sourceforge.net/"
13 SRC_URI="mirror://sourceforge/${PN}/${MY_P}.tar.gz"
16 KEYWORDS="~amd64 ~x86"
20 # The CGI modules are handled in $RDEPEND.
21 APACHE_MODULES="apache2_modules_alias," # RedirectMatch
22 APACHE_MODULES+="apache2_modules_authn_core," # AuthType
23 APACHE_MODULES+="apache2_modules_authz_core," # Require
24 APACHE_MODULES+="apache2_modules_authz_host," # Require host
25 APACHE_MODULES+="apache2_modules_authz_user" # Require valid-user
28 app-admin/apache-tools
31 # Older versions of mod_perl think they're compatibile with apache-2.4,
32 # so we require the new one explicitly.
34 virtual/perl-IO-Compress
42 >=www-apache/mod_perl-2.0.9
44 || ( >=www-servers/apache-2.4[${APACHE_MODULES},apache2_modules_cgi]
45 >=www-servers/apache-2.4[${APACHE_MODULES},apache2_modules_cgid]
46 >=www-servers/apache-2.4[${APACHE_MODULES},apache2_modules_fcgid] )
49 rss? ( dev-perl/XML-RSS )
50 samba? ( net-fs/samba )"
56 S="${WORKDIR}/${MY_P}"
58 CGIDIR="/usr/lib/backuppc/htdocs"
59 CONFDIR="/etc/BackupPC"
60 DATADIR="/var/lib/backuppc"
61 DOCDIR="/usr/share/doc/${PF}"
62 LOGDIR="/var/log/BackupPC"
66 enewuser backuppc -1 /bin/bash /var/lib/backuppc backuppc
70 epatch "${FILESDIR}/3.3.0/01-fix-configure.pl.patch"
71 epatch "${FILESDIR}/3.3.0/02-fix-config.pl-formatting.patch"
72 epatch "${FILESDIR}/3.3.0/03-reasonable-config.pl-defaults.patch"
74 epatch "${FILESDIR}/3.2.0/04-add-docdir-marker.patch"
75 epatch "${FILESDIR}/3.2.0/05-nicelevel.patch"
77 # Fix docs location using the marker that we've patched in.
78 sed -i "s+__DOCDIR__+${DOCDIR}+" "lib/BackupPC/CGI/View.pm" \
79 || die "failed to sed the documentation location"
86 myconf="--bin-path smbclient=$(type -p smbclient)"
87 myconf="${myconf} --bin-path nmblookup=$(type -p nmblookup)"
90 /usr/bin/env perl ./configure.pl \
92 --bin-path perl=$(type -p perl) \
93 --bin-path tar=$(type -p tar) \
94 --bin-path rsync=$(type -p rsync) \
95 --bin-path ping=$(type -p ping) \
96 --bin-path df=$(type -p df) \
97 --bin-path ssh=$(type -p ssh) \
98 --bin-path sendmail=$(type -p sendmail) \
99 --bin-path hostname=$(type -p hostname) \
100 --bin-path gzip=$(type -p gzip) \
101 --bin-path bzip2=$(type -p bzip2) \
102 --config-dir "${CONFDIR}" \
104 --data-dir "${DATADIR}" \
105 --hostname 127.0.0.1 \
107 --dest-dir "${D%/}" \
108 --html-dir "${CGIDIR}"/image \
109 --html-dir-url /image \
110 --cgi-dir "${CGIDIR}" \
112 ${myconf} || die "failed the configure.pl script"
114 ebegin "Installing documentation"
119 --center="BackupPC manual" \
120 "${S}"/doc/BackupPC.pod backuppc.8 \
121 || die "failed to generate man page"
125 # Place the documentation in the correct location
126 dodoc "${D}/usr/doc/BackupPC.html"
127 dodoc "${D}/usr/doc/BackupPC.pod"
128 rm -rf "${D}/usr/doc" || die
133 dodir "${CONFDIR}/pc"
136 keepdir "${CONFDIR}/pc"
137 keepdir "${DATADIR}"/{trash,pool,pc,cpool}
140 ebegin "Setting up init.d/conf.d/systemd scripts"
141 newinitd "${S}"/init.d/gentoo-backuppc backuppc
142 newconfd "${S}"/init.d/gentoo-backuppc.conf backuppc
143 systemd_dounit "${FILESDIR}/${PN}.service"
145 insinto "${APACHE_MODULES_CONFDIR}"
146 doins "${FILESDIR}"/99_backuppc.conf
148 # Make sure that the ownership is correct
149 chown -R backuppc:backuppc "${D}${CONFDIR}" || die
150 chown -R backuppc:backuppc "${D}${DATADIR}" || die
151 chown -R backuppc:backuppc "${D}${LOGDIR}" || die
155 elog "Installation finished, you may now start using BackupPC."
157 elog "- Read the documentation in /usr/share/doc/${PF}/BackupPC.html"
158 elog " Please pay special attention to the security section."
160 elog "- You can launch backuppc by running:"
162 elog " # /etc/init.d/backuppc start"
164 elog "- To enable the GUI, first edit ${ROOT}etc/conf.d/apache2 and add,"
166 elog " \"-D BACKUPPC -D PERL -D MPM_ITK\""
168 elog " to the APACHE2_OPTS line."
170 elog " Then you must edit ${ROOT}etc/apache2/modules.d/00_mpm_itk.conf"
171 elog " and adjust the values of LimitUIDRange/LimitGIDRange to include"
172 elog " the UID and GID of the backuppc user."
174 elog " Finally, start apache:"
176 elog " # /etc/init.d/apache2 start"
178 elog " The web interface should now be running on,"
180 elog " http://127.0.0.1:8080/"
183 # Generate a new password if there's no auth file
184 if [[ ! -f "${CONFDIR}/users.htpasswd" ]]; then
186 adminpass=$( makepasswd --chars=12 )
187 htpasswd -bc "${CONFDIR}/users.htpasswd" $adminuser $adminpass
190 elog "- Created admin user $adminuser with password $adminpass"
191 elog " To add new users, run: "
193 elog " # htpasswd ${CONFDIR}/users.htpasswd newUser"