1 # Copyright 2004 D. Scott Barninger
2 # Copyright (C) 2000-2015 Kern Sibbald
3 # License: BSD 2-Clause; see file LICENSE-FOSS
6 # Modified from bacula-1.34.5.ebuild for 1.36.0 release
7 # 24 Oct 2004 D. Scott Barninger <barninger at fairfieldcomputers dot com>
9 # added cdrom rescue for 1.36.1
10 # init script now comes from source package not ${FILES} dir
11 # 26 Nov 2004 D. Scott Barninger <barninger at fairfieldcomputers dot com>
13 # fix symlink creation in rescue package in post script
14 # remove mask on x86 keyword
15 # fix post script so it doesn't talk about server config for client-only build
16 # bug #181 - unable to reproduce on 2.4 kernel system so add FEATURES="-sandbox"
17 # 04 Dec 2004 D. Scott Barninger <barninger at fairfieldcomputers dot com>
19 # more on bug #181 - another user has reported a sandbox violation trying to
20 # write to /dev/sg0 - still can't reproduce this behavior
21 # add an 'addpredict /dev/sg0'
22 # 08 Dec 2004 D. Scott Barninger <barninger at fairfieldcomputers dot com>
24 # resolve bug #181 - problem is caused by configure calling cdrecord to scan
25 # the scsi bus. patch configure to remove this. add logrotate script.
26 # 06 Feb 2005 D. Scott Barninger <barninger at fairfieldcomputers dot com>
28 # fix documentation bug
29 # 07 Feb 2005 D. Scott Barninger <barninger at fairfieldcomputers dot com>
31 # new USE keywords bacula-clientonly bacula-split
32 # add new logwatch scripts
33 # 06 Mar 2005 D. Scott Barninger <barninger at fairfieldcomputers dot com>
36 # 17 Apr 2005 D. Scott Barninger <barninger at fairfieldcomputers dot com>
38 DESCRIPTION="featureful client/server network backup suite"
39 HOMEPAGE="http://www.bacula.org/"
40 SRC_URI="mirror://sourceforge/bacula/${P}.tar.gz"
42 LICENSE="BSD 2-Clause"
44 KEYWORDS="x86 ~ppc ~sparc ~amd64"
45 IUSE="readline tcpd gnome mysql sqlite X static postgres wxwindows bacula-clientonly bacula-split"
49 # there is a local sqlite use flag. use it -OR- mysql, not both.
50 # mysql is the recommended choice ...
51 # may need sys-libs/libtermcap-compat but try without first
52 DEPEND=">=sys-libs/zlib-1.1.4
53 readline? ( >=sys-libs/readline-4.1 )
54 tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
55 gnome? ( gnome-base/libgnome )
56 gnome? ( app-admin/gnomesu )
58 sqlite? ( =dev-db/sqlite-2* )
59 mysql? ( >=dev-db/mysql-3.23 )
60 postgres? ( >=dev-db/postgresql-7.4.0 )
64 wxwindows? ( >=x11-libs/wxGTK-2.4.2 )
77 # this resolves bug #181
78 epatch ${FILESDIR}/1.36.2-cdrecord-configure.patch
85 `use_enable tcpd tcp-wrappers`
88 # define this to skip building the other daemons ...
89 if use bacula-clientonly
91 myconf="${myconf} --enable-client-only"
94 # select database support
95 if ! use bacula-clientonly
97 # mysql is the recomended choice ...
100 myconf="${myconf} --with-mysql=/usr"
103 myconf="${myconf} --with-postgresql=/usr"
106 myconf="${myconf} --with-sqlite=/usr"
107 elif use sqlite && use mysql
109 myconf="${myconf/--with-sqlite/}"
115 myconf="${myconf} --enable-wx-console"
120 myconf="${myconf} --enable-readline"
125 myconf="${myconf} --enable-tray-monitor"
129 --enable-smartalloc \
131 --mandir=/usr/share/man \
132 --with-pid-dir=/var/run \
133 --sysconfdir=/etc/bacula \
134 --infodir=/usr/share/info \
135 --with-subsys-dir=/var/lock/subsys \
136 --with-working-dir=/var/bacula \
137 --with-scriptdir=/etc/bacula \
138 --with-dir-user=root \
139 --with-dir-group=bacula \
140 --with-sd-user=root \
141 --with-sd-group=bacula \
142 --with-fd-user=root \
143 --with-fd-group=bacula \
144 --host=${CHOST} ${myconf} || die "bad ./configure"
146 emake || die "compile problem"
148 # for the rescue package regardless of use static
150 make static-bacula-fd
163 make static-bacula-dir
166 cd ${S}/src/gnome-console
167 make static-gnome-console
171 cd ${S}/src/wx-console
172 make static-wx-console
175 make static-bacula-sd
180 make DESTDIR=${D} install || die
185 cp static-bacula-fd ${D}/usr/sbin/bacula-fd
187 cp static-console ${D}/usr/sbin/console
189 cp static-bacula-dir ${D}/usr/sbin/bacula-dir
192 cd ${S}/src/gnome-console
193 cp static-gnome-console ${D}/usr/sbin/gnome-console
197 cd ${S}/src/wx-console
198 cp static-wx-console ${D}/usr/sbin/wx-console
201 cp static-bacula-sd ${D}/usr/sbin/bacula-sd
207 mkdir -p ${D}/usr/share/pixmaps
208 mkdir -p ${D}/usr/share/applications
209 cp ${S}/scripts/bacula.png ${D}/usr/share/pixmaps/bacula.png
210 cp ${S}/scripts/bacula.desktop.gnome2.xsu ${D}/usr/share/applications/bacula.desktop
211 cp ${S}/src/tray-monitor/generic.xpm ${D}/usr/share/pixmaps/bacula-tray-monitor.xpm
212 cp ${S}/scripts/bacula-tray-monitor.desktop \
213 ${D}/usr/share/applications/bacula-tray-monitor.desktop
214 chmod 755 ${D}/usr/sbin/bacula-tray-monitor
215 chmod 644 ${D}/etc/bacula/tray-monitor.conf
218 if ! use bacula-clientonly
220 # the database update scripts
221 mkdir -p ${D}/etc/bacula/updatedb
222 cp ${S}/updatedb/* ${D}/etc/bacula/updatedb/
223 chmod 754 ${D}/etc/bacula/updatedb/*
225 # the logrotate configuration
226 mkdir -p ${D}/etc/logrotate.d
227 cp ${S}/scripts/logrotate ${D}/etc/logrotate.d/bacula
228 chmod 644 ${D}/etc/logrotate.d/bacula
230 # the logwatch scripts
231 mkdir -p ${D}/etc/log.d/conf/logfiles
232 mkdir -p ${D}/etc/log.d/conf/services
233 mkdir -p ${D}/etc/log.d/scripts/services
234 cp ${S}/scripts/logwatch/bacula ${D}/etc/log.d/scripts/services/bacula
235 cp ${S}/scripts/logwatch/logfile.bacula.conf ${D}/etc/log.d/conf/logfiles/bacula.conf
236 cp ${S}/scripts/logwatch/services.bacula.conf ${D}/etc/log.d/conf/services/bacula.conf
237 chmod 755 ${D}/etc/log.d/scripts/services/bacula
238 chmod 644 ${D}/etc/log.d/conf/logfiles/bacula.conf
239 chmod 644 ${D}/etc/log.d/conf/services/bacula.conf
243 # the cdrom rescue package
244 mkdir -p ${D}/etc/bacula/rescue/cdrom
245 cp -R ${S}/rescue/linux/cdrom/* ${D}/etc/bacula/rescue/cdrom/
246 mkdir ${D}/etc/bacula/rescue/cdrom/bin
247 cp ${S}/src/filed/static-bacula-fd ${D}/etc/bacula/rescue/cdrom/bin/bacula-fd
248 chmod 754 ${D}/etc/bacula/rescue/cdrom/bin/bacula-fd
251 for a in ${S}/{ChangeLog,README,ReleaseNotes,kernstodo,LICENSE,doc/latex/bacula.pdf}
256 dohtml -r ${S}/doc/latex/bacula
258 # clean up permissions left broken by install
259 chmod o-r ${D}/etc/bacula/query.sql
261 # remove the working dir so we can add it postinst with group
262 rmdir ${D}/var/bacula
266 if use bacula-clientonly
268 newexe ${S}/platforms/gentoo/bacula-fd bacula-fd
272 newexe ${S}/platforms/gentoo/bacula-fd bacula-fd
273 newexe ${S}/platforms/gentoo/bacula-sd bacula-sd
274 newexe ${S}/platforms/gentoo/bacula-dir bacula-dir
276 newexe ${S}/platforms/gentoo/bacula-init bacula
282 # create the daemon group
283 HAVE_BACULA=`cat /etc/group | grep bacula 2>/dev/null`
284 if [ -z $HAVE_BACULA ]; then
287 einfo "The group bacula has been created. Any users you add to"
288 einfo "this group have access to files created by the daemons."
291 # the working directory
292 install -m0750 -o root -g bacula -d ${ROOT}/var/bacula
294 # link installed bacula-fd.conf into rescue directory
295 #ln -s /etc/bacula/bacula-fd.conf /etc/bacula/rescue/cdrom/bacula-fd.conf
296 # no longer necessary after 1.36.2
299 einfo "The CDRom rescue disk package has been installed into the"
300 einfo "/etc/bacula/rescue/cdrom/ directory. Please examine the manual"
301 einfo "for information on creating a rescue CD. CDR device detection"
302 einfo "during build has been disabled to prevent sandbox violations."
303 einfo "You need to examine /etc/bacula/rescue/cdrom/Makefile and adjust"
304 einfo "the device information for your CD recorder."
307 if ! use bacula-clientonly; then
309 einfo "Please note either/or nature of database USE flags for"
310 einfo "Bacula. If mysql is set, it will be used, else postgres"
311 einfo "else finally SQLite. If you wish to have multiple DBs on"
312 einfo "one system, you may wish to unset auxillary DBs for this"
318 # test for an existing database
319 # note: this ASSUMES no password has been set for bacula database
320 DB_VER=`mysql 2>/dev/null bacula -e 'select * from Version;'|tail -n 1`
321 if [ -z "$DB_VER" ]; then
322 einfo "This appears to be a new install and you plan to use mysql"
323 einfo "for your catalog database. You should now create it by doing"
324 einfo "these commands:"
325 einfo " sh /etc/bacula/grant_mysql_privileges"
326 einfo " sh /etc/bacula/create_mysql_database"
327 einfo " sh /etc/bacula/make_mysql_tables"
328 elif [ "$DB_VER" -lt "8" ]; then
329 elinfo "This release requires an upgrade to your bacula database"
330 einfo "as the database format has changed. Please read the"
331 einfo "manual chapter for how to upgrade your database!!!"
333 einfo "Backup your database with the command:"
334 einfo " mysqldump -f --opt bacula | bzip2 > /var/bacula/bacula_backup.sql.bz"
336 einfo "Then update your database using the scripts found in"
337 einfo "/etc/bacula/updatedb/ from your current version $DB_VER to"
338 einfo "version 8. Note that scripts must be run in order from your"
339 einfo "version to the current version."
345 # test for an existing database
346 # note: this ASSUMES no password has been set for bacula database
347 DB_VER=`echo 'select * from Version;' | psql bacula 2>/dev/null | tail -3 | head -1`
348 if [ -z "$DB_VER" ]; then
349 einfo "This appears to be a new install and you plan to use postgresql"
350 einfo "for your catalog database. You should now create it by doing"
351 einfo "these commands:"
352 einfo " sh /etc/bacula/create_postgresql_database"
353 einfo " sh /etc/bacula/make_postgresql_tables"
354 einfo " sh /etc/bacula/grant_postgresql_privileges"
355 elif [ "$DB_VER" -lt "8" ]; then
356 elinfo "This release requires an upgrade to your bacula database"
357 einfo "as the database format has changed. Please read the"
358 einfo "manual chapter for how to upgrade your database!!!"
360 einfo "Backup your database with the command:"
361 einfo " pg_dump bacula | bzip2 > /var/bacula/bacula_backup.sql.bz2"
363 einfo "Then update your database using the scripts found in"
364 einfo "/etc/bacula/updatedb/ from your current version $DB_VER to"
365 einfo "version 8. Note that scripts must be run in order from your"
366 einfo "version to the current version."
372 # test for an existing database
373 # note: this ASSUMES no password has been set for bacula database
374 DB_VER=`echo "select * from Version;" | sqlite 2>/dev/null /var/bacula/bacula.db | tail -n 1`
375 if [ -z "$DB_VER" ]; then
376 einfo "This appears to be a new install and you plan to use sqlite"
377 einfo "for your catalog database. You should now create it by doing"
378 einfo "these commands:"
379 einfo " sh /etc/bacula/grant_sqlite_privileges"
380 einfo " sh /etc/bacula/create_sqlite_database"
381 einfo " sh /etc/bacula/make_sqlite_tables"
382 elif [ "$DB_VER" -lt "8" ]; then
383 elinfo "This release requires an upgrade to your bacula database"
384 einfo "as the database format has changed. Please read the"
385 einfo "manual chapter for how to upgrade your database!!!"
387 einfo "Backup your database with the command:"
388 einfo " echo .dump | sqlite /var/bacula/bacula.db | bzip2 > \\"
389 einfo " /var/bacula/bacula_backup.sql.bz2"
391 einfo "Then update your database using the scripts found in"
392 einfo "/etc/bacula/updatedb/ from your current version $DB_VER to"
393 einfo "version 8. Note that scripts must be run in order from your"
394 einfo "version to the current version."
400 einfo "Review your configuration files in /etc/bacula and"
401 einfo "start the daemons:"
402 if use bacula-clientonly; then
403 einfo " /etc/init.d/bacula-fd start"
405 if use bacula-split; then
406 einfo " /etc/init.d/bacula-sd start"
407 einfo " /etc/init.d/bacula-dir start"
408 einfo " /etc/init.d/bacula-fd start"
409 einfo " or /etc/bacula/bacula will start all three."
411 einfo " /etc/init.d/bacula start"
415 einfo "You may also wish to:"
416 if use bacula-clientonly; then
417 einfo " rc-update add bacula-fd default"
419 if use bacula-split; then
420 einfo " rc-update add bacula-sd default"
421 einfo " rc-update add bacula-dir default"
422 einfo " rc-update add bacula-fd default"
424 einfo " rc-update add bacula default"