1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit depend.apache eutils user
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 APACHE_MODULES="apache2_modules_alias,"
21 APACHE_MODULES+="apache2_modules_unixd,"
22 APACHE_MODULES+="apache2_modules_authz_user"
25 app-admin/apache-tools
28 virtual/perl-IO-Compress
31 >=app-arch/tar-1.13.20
38 || ( >=www-servers/apache-2.4[${APACHE_MODULES},apache2_modules_cgi]
39 >=www-servers/apache-2.4[${APACHE_MODULES},apache2_modules_cgid]
40 >=www-servers/apache-2.4[${APACHE_MODULES},apache2_modules_fcgid] )
42 >=dev-perl/File-RsyncP-0.68
43 rss? ( dev-perl/XML-RSS )
44 samba? ( net-fs/samba )"
50 S="${WORKDIR}/${MY_P}"
52 CGIDIR="/usr/lib/backuppc/htdocs"
53 CONFDIR="/etc/BackupPC"
54 DATADIR="/var/lib/backuppc"
55 DOCDIR="/usr/share/doc/${PF}"
56 LOGDIR="/var/log/BackupPC"
60 enewuser backuppc -1 /bin/bash /var/lib/backuppc backuppc
64 epatch "${FILESDIR}/3.3.0/01-fix-configure.pl.patch"
65 epatch "${FILESDIR}/3.3.0/02-fix-config.pl-formatting.patch"
66 epatch "${FILESDIR}/3.3.0/03-reasonable-config.pl-defaults.patch"
68 epatch "${FILESDIR}/3.2.0/04-add-docdir-marker.patch"
69 epatch "${FILESDIR}/3.2.0/05-nicelevel.patch"
71 # Fix docs location using the marker that we've patched in.
72 sed -i "s+__DOCDIR__+${DOCDIR}+" "lib/BackupPC/CGI/View.pm" \
73 || die "failed to sed the documentation location"
80 myconf="--bin-path smbclient=$(type -p smbclient)"
81 myconf="${myconf} --bin-path nmblookup=$(type -p nmblookup)"
84 /usr/bin/env perl ./configure.pl \
86 --bin-path perl=$(type -p perl) \
87 --bin-path tar=$(type -p tar) \
88 --bin-path rsync=$(type -p rsync) \
89 --bin-path ping=$(type -p ping) \
90 --bin-path df=$(type -p df) \
91 --bin-path ssh=$(type -p ssh) \
92 --bin-path sendmail=$(type -p sendmail) \
93 --bin-path hostname=$(type -p hostname) \
94 --bin-path gzip=$(type -p gzip) \
95 --bin-path bzip2=$(type -p bzip2) \
96 --config-dir "${CONFDIR}" \
98 --data-dir "${DATADIR}" \
99 --hostname 127.0.0.1 \
101 --dest-dir "${D%/}" \
102 --html-dir "${CGIDIR}"/image \
103 --html-dir-url /image \
104 --cgi-dir "${CGIDIR}" \
106 ${myconf} || die "failed the configure.pl script"
108 ebegin "Installing documentation"
113 --center="BackupPC manual" \
114 "${S}"/doc/BackupPC.pod backuppc.8 \
115 || die "failed to generate man page"
119 # Place the documentation in the correct location
120 dodoc "${D}/usr/doc/BackupPC.html"
121 dodoc "${D}/usr/doc/BackupPC.pod"
122 rm -rf "${D}/usr/doc" || die
127 dodir "${CONFDIR}/pc"
130 keepdir "${CONFDIR}/pc"
131 keepdir "${DATADIR}"/{trash,pool,pc,cpool}
134 ebegin "Setting up init.d/conf.d/systemd scripts"
135 newinitd "${S}"/init.d/gentoo-backuppc backuppc
136 newconfd "${S}"/init.d/gentoo-backuppc.conf backuppc
138 insinto "${APACHE_MODULES_CONFDIR}"
139 doins "${FILESDIR}"/99_backuppc.conf
141 # Make sure that the ownership is correct
142 chown -R backuppc:backuppc "${D}${CONFDIR}" || die
143 chown -R backuppc:backuppc "${D}${DATADIR}" || die
144 chown -R backuppc:backuppc "${D}${LOGDIR}" || die
148 elog "Installation finished, you may now start using BackupPC."
150 elog "- Read the documentation in /usr/share/doc/${PF}/BackupPC.html"
151 elog " Please pay special attention to the security section."
153 elog "- You can launch backuppc by running:"
155 elog " # /etc/init.d/backuppc start"
157 elog "- To enable the GUI, first edit ${ROOT}etc/conf.d/apache2 and add,"
159 elog " \"-D BACKUPPC -D PERL -D MPM_ITK\""
161 elog " to the APACHE2_OPTS line."
163 elog " Then you must edit ${ROOT}etc/apache2/modules.d/00_mpm_itk.conf"
164 elog " and adjust the values of LimitUIDRange/LimitGIDRange to include"
165 elog " the UID and GID of the backuppc user."
167 elog " Finally, start apache:"
169 elog " # /etc/init.d/apache2 start"
171 elog " The web interface should now be running on,"
173 elog " http://127.0.0.1:8080/"
176 # Generate a new password if there's no auth file
177 if [[ ! -f "${CONFDIR}/users.htpasswd" ]]; then
179 adminpass=$( makepasswd --chars=12 )
180 htpasswd -bc "${CONFDIR}/users.htpasswd" $adminuser $adminpass
183 elog "- Created admin user $adminuser with password $adminpass"
184 elog " To add new users, run: "
186 elog " # htpasswd ${CONFDIR}/users.htpasswd newUser"