1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 inherit eutils systemd webapp user
11 DESCRIPTION="A high-performance system for backing up computers to a server's disk"
12 HOMEPAGE="http://backuppc.sourceforge.net/"
13 SRC_URI="mirror://sourceforge/${PN}/${MY_P}.tar.gz"
21 app-admin/apache-tools
24 virtual/perl-IO-Compress
27 >=app-arch/tar-1.13.20
35 >=dev-perl/File-RsyncP-0.68
36 rss? ( dev-perl/XML-RSS )
37 samba? ( net-fs/samba )"
39 WEBAPP_MANUAL_SLOT="yes"
44 CONFDIR="/etc/BackupPC"
45 DATADIR="/var/lib/backuppc"
46 LOGDIR="/var/log/BackupPC"
51 enewuser backuppc -1 /bin/bash /var/lib/backuppc backuppc
55 epatch "${FILESDIR}/3.3.0/01-fix-configure.pl.patch"
56 epatch "${FILESDIR}/3.3.0/02-fix-config.pl-formatting.patch"
57 epatch "${FILESDIR}/3.3.0/03-reasonable-config.pl-defaults.patch"
59 # Fix the documentation location in the CGI interface
60 epatch "${FILESDIR}/3.2.0/04-add-docdir-marker.patch"
61 sed -i "s+__DOCDIR__+/usr/share/doc/${PF}+" "lib/BackupPC/CGI/View.pm"
63 epatch "${FILESDIR}/3.2.0/05-nicelevel.patch"
64 sed -i -e 's/--chuid ${USER}//' "${S}"/init.d/src/gentoo-backuppc || die "Failed to fix the init script"
77 myconf="--bin-path smbclient=$(type -p smbclient)"
78 myconf="${myconf} --bin-path nmblookup=$(type -p nmblookup)"
81 /usr/bin/env perl ./configure.pl \
83 --bin-path perl=$(type -p perl) \
84 --bin-path tar=$(type -p tar) \
85 --bin-path rsync=$(type -p rsync) \
86 --bin-path ping=$(type -p ping) \
87 --bin-path df=$(type -p df) \
88 --bin-path ssh=$(type -p ssh) \
89 --bin-path sendmail=$(type -p sendmail) \
90 --bin-path hostname=$(type -p hostname) \
91 --bin-path gzip=$(type -p gzip) \
92 --bin-path bzip2=$(type -p bzip2) \
93 --config-dir ${CONFDIR} \
95 --data-dir ${DATADIR} \
96 --hostname $(hostname) \
99 --html-dir ${MY_HTDOCSDIR}/image \
100 --html-dir-url /image \
101 --cgi-dir ${MY_HTDOCSDIR} \
103 ${myconf} || die "failed the configure.pl script"
105 ebegin "Installing documentation"
110 --center="BackupPC manual" \
111 "${S}"/doc/BackupPC.pod backuppc.8 || die "failed to generate man page"
115 # Place the documentation in the correct location
116 dodoc "${D}/usr/doc/BackupPC.html"
117 dodoc "${D}/usr/doc/BackupPC.pod"
118 rm -rf "${D}/usr/doc"
126 keepdir ${CONFDIR}/pc
127 keepdir ${DATADIR}/{trash,pool,pc,cpool}
130 ebegin "Setting up init.d/conf.d/systemd scripts"
131 newinitd "${S}"/init.d/gentoo-backuppc backuppc
132 newconfd "${S}"/init.d/gentoo-backuppc.conf backuppc
133 systemd_dounit "${FILESDIR}/${PN}.service"
136 ebegin "Setting up an apache instance for backuppc"
138 cp "${FILESDIR}/apache2-backuppc."{conf,init} "${WORKDIR}/"
139 cp "${FILESDIR}/httpd.conf" "${WORKDIR}/httpd.conf"
140 sed -i -e "s+HTDOCSDIR+${MY_HTDOCSDIR}+g" "${WORKDIR}/httpd.conf"
141 sed -i -e "s+AUTHFILE+${CONFDIR}/users.htpasswd+g" "${WORKDIR}/httpd.conf"
143 moduledir="/usr/lib/apache2/modules"
145 # Check if the Apache ServerRoot is real.
146 # This is sometimes broken on older amd64 systems.
147 # In this case we just patch our config file appropriately.
148 if [[ ! -d "/usr/lib/apache2" ]]; then
149 if [[ -d "/usr/lib64/apache2" ]]; then
150 sed -i -e "s+/usr/lib/apache2+/usr/lib64/apache2+g" "${WORKDIR}/httpd.conf"
151 sed -i -e "s+/usr/lib/apache2+/usr/lib64/apache2+g" "${WORKDIR}/apache2-backuppc.conf"
152 moduledir="/usr/lib64/apache2/modules"
156 # Check if we're using mod_cgid instead of mod_cgi
157 # This happens if you install apache with USE="threads"
158 if [[ -f "${moduledir}/mod_cgid.so" ]]; then
159 sed -i -e "s+mod_cgi+mod_cgid+g" "${WORKDIR}/httpd.conf"
160 sed -i -e "s+cgi_module+cgid_module+g" "${WORKDIR}/httpd.conf"
163 # Install conf.d/init.d files for apache2-backuppc
164 if [ -e /etc/init.d/apache2 ]; then
165 newconfd "${WORKDIR}/apache2-backuppc.conf" apache2-backuppc
166 newinitd /etc/init.d/apache2 apache2-backuppc
168 newconfd "${WORKDIR}/apache2-backuppc.conf" apache2-backuppc
169 newinitd "${WORKDIR}/apache2-backuppc.init" apache2-backuppc
174 doins "${WORKDIR}/httpd.conf"
178 webapp_src_install || die "webapp_src_install"
180 # Make sure that the ownership is correct
181 chown -R backuppc:backuppc "${D}${CONFDIR}"
182 chown -R backuppc:backuppc "${D}${DATADIR}"
183 chown -R backuppc:backuppc "${D}${LOGDIR}"
187 # This is disabled since BackupPC doesn't need it
188 # webapp_pkg_postinst
190 elog "Installation finished, now may now start using BackupPC."
192 elog "- Read the documentation in /usr/share/doc/${PF}/BackupPC.html"
193 elog " Please pay special attention to the security section."
195 elog "- You can launch backuppc and it's apache web interface by running:"
196 elog " # /etc/init.d/backuppc start"
197 elog " # /etc/init.d/apache2-backuppc start"
199 if [[ ! -e /etc/runlevels/default/backuppc ]]; then
201 elog "- You also might want to add these scripts to your default runlevel:"
202 elog " # rc-update add backuppc default"
203 elog " # rc-update add apache2-backuppc default"
206 # Generate a new password if there's no auth file
207 if [[ ! -f "${CONFDIR}/users.htpasswd" ]]; then
209 adminpass=$( makepasswd --chars=12 )
210 htpasswd -bc "${CONFDIR}/users.htpasswd" $adminuser $adminpass
213 elog "- Created admin user $adminuser with password $adminpass"
214 elog " To add new users, run: "
215 elog " # htpasswd ${CONFDIR}/users.htpasswd newUser"
218 if [[ -d "/etc/backuppc" ]]; then
220 ewarn "Detected old config directory in /etc/backuppc"
221 ewarn "Please migrate relevant config files to ${CONFDIR} before starting backuppc"