1 # Copyright 2004 D. Scott Barninger
2 # Distributed under the terms of the GNU General Public License v2
4 # Modified from bacula-1.34.5.ebuild for 1.36.0 release
5 # 24 Oct 2004 D. Scott Barninger <barninger at fairfieldcomputers dot com>
7 # added cdrom rescue for 1.36.1
8 # init script now comes from source package not ${FILES} dir
9 # 26 Nov 2004 D. Scott Barninger <barninger at fairfieldcomputers dot com>
11 # fix symlink creation in rescue package in post script
12 # remove mask on x86 keyword
13 # fix post script so it doesn't talk about server config for client-only build
14 # bug #181 - unable to reproduce on 2.4 kernel system so add FEATURES="-sandbox"
15 # 04 Dec 2004 D. Scott Barninger <barninger at fairfieldcomputers dot com>
17 # more on bug #181 - another user has reported a sandbox violation trying to
18 # write to /dev/sg0 - still can't reproduce this behavior
19 # add an 'addpredict /dev/sg0'
20 # 08 Dec 2004 D. Scott Barninger <barninger at fairfieldcomputers dot com>
22 # resolve bug #181 - problem is caused by configure calling cdrecord to scan
23 # the scsi bus. patch configure to remove this. add logrotate script.
24 # 06 Feb 2005 D. Scott Barninger <barninger at fairfieldcomputers dot com>
26 # fix documentation bug
27 # 07 Feb 2005 D. Scott Barninger <barninger at fairfieldcomputers dot com>
29 # new USE keywords bacula-clientonly bacula-split
30 # add new logwatch scripts
31 # 06 Mar 2005 D. Scott Barninger <barninger at fairfieldcomputers dot com>
34 # 17 Apr 2005 D. Scott Barninger <barninger at fairfieldcomputers dot com>
36 DESCRIPTION="featureful client/server network backup suite"
37 HOMEPAGE="http://www.bacula.org/"
38 SRC_URI="mirror://sourceforge/bacula/${P}.tar.gz"
42 KEYWORDS="x86 ~ppc ~sparc ~amd64"
43 IUSE="readline tcpd gnome mysql sqlite X static postgres wxwindows bacula-clientonly bacula-split"
47 # there is a local sqlite use flag. use it -OR- mysql, not both.
48 # mysql is the recommended choice ...
49 # may need sys-libs/libtermcap-compat but try without first
50 DEPEND=">=sys-libs/zlib-1.1.4
51 readline? ( >=sys-libs/readline-4.1 )
52 tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
53 gnome? ( gnome-base/libgnome )
54 gnome? ( app-admin/gnomesu )
56 sqlite? ( =dev-db/sqlite-2* )
57 mysql? ( >=dev-db/mysql-3.23 )
58 postgres? ( >=dev-db/postgresql-7.4.0 )
62 wxwindows? ( >=x11-libs/wxGTK-2.4.2 )
75 # this resolves bug #181
76 epatch ${FILESDIR}/1.36.2-cdrecord-configure.patch
83 `use_enable tcpd tcp-wrappers`
86 # define this to skip building the other daemons ...
87 if use bacula-clientonly
89 myconf="${myconf} --enable-client-only"
92 # select database support
93 if ! use bacula-clientonly
95 # mysql is the recomended choice ...
98 myconf="${myconf} --with-mysql=/usr"
101 myconf="${myconf} --with-postgresql=/usr"
104 myconf="${myconf} --with-sqlite=/usr"
105 elif use sqlite && use mysql
107 myconf="${myconf/--with-sqlite/}"
113 myconf="${myconf} --enable-wx-console"
118 myconf="${myconf} --enable-readline"
123 myconf="${myconf} --enable-tray-monitor"
127 --enable-smartalloc \
129 --mandir=/usr/share/man \
130 --with-pid-dir=/var/run \
131 --sysconfdir=/etc/bacula \
132 --infodir=/usr/share/info \
133 --with-subsys-dir=/var/lock/subsys \
134 --with-working-dir=/var/bacula \
135 --with-scriptdir=/etc/bacula \
136 --with-dir-user=root \
137 --with-dir-group=bacula \
138 --with-sd-user=root \
139 --with-sd-group=bacula \
140 --with-fd-user=root \
141 --with-fd-group=bacula \
142 --host=${CHOST} ${myconf} || die "bad ./configure"
144 emake || die "compile problem"
146 # for the rescue package regardless of use static
148 make static-bacula-fd
161 make static-bacula-dir
164 cd ${S}/src/gnome-console
165 make static-gnome-console
169 cd ${S}/src/wx-console
170 make static-wx-console
173 make static-bacula-sd
178 make DESTDIR=${D} install || die
183 cp static-bacula-fd ${D}/usr/sbin/bacula-fd
185 cp static-console ${D}/usr/sbin/console
187 cp static-bacula-dir ${D}/usr/sbin/bacula-dir
190 cd ${S}/src/gnome-console
191 cp static-gnome-console ${D}/usr/sbin/gnome-console
195 cd ${S}/src/wx-console
196 cp static-wx-console ${D}/usr/sbin/wx-console
199 cp static-bacula-sd ${D}/usr/sbin/bacula-sd
205 mkdir -p ${D}/usr/share/pixmaps
206 mkdir -p ${D}/usr/share/applications
207 cp ${S}/scripts/bacula.png ${D}/usr/share/pixmaps/bacula.png
208 cp ${S}/scripts/bacula.desktop.gnome2.xsu ${D}/usr/share/applications/bacula.desktop
209 cp ${S}/src/tray-monitor/generic.xpm ${D}/usr/share/pixmaps/bacula-tray-monitor.xpm
210 cp ${S}/scripts/bacula-tray-monitor.desktop \
211 ${D}/usr/share/applications/bacula-tray-monitor.desktop
212 chmod 755 ${D}/usr/sbin/bacula-tray-monitor
213 chmod 644 ${D}/etc/bacula/tray-monitor.conf
216 if ! use bacula-clientonly
218 # the database update scripts
219 mkdir -p ${D}/etc/bacula/updatedb
220 cp ${S}/updatedb/* ${D}/etc/bacula/updatedb/
221 chmod 754 ${D}/etc/bacula/updatedb/*
223 # the logrotate configuration
224 mkdir -p ${D}/etc/logrotate.d
225 cp ${S}/scripts/logrotate ${D}/etc/logrotate.d/bacula
226 chmod 644 ${D}/etc/logrotate.d/bacula
228 # the logwatch scripts
229 mkdir -p ${D}/etc/log.d/conf/logfiles
230 mkdir -p ${D}/etc/log.d/conf/services
231 mkdir -p ${D}/etc/log.d/scripts/services
232 cp ${S}/scripts/logwatch/bacula ${D}/etc/log.d/scripts/services/bacula
233 cp ${S}/scripts/logwatch/logfile.bacula.conf ${D}/etc/log.d/conf/logfiles/bacula.conf
234 cp ${S}/scripts/logwatch/services.bacula.conf ${D}/etc/log.d/conf/services/bacula.conf
235 chmod 755 ${D}/etc/log.d/scripts/services/bacula
236 chmod 644 ${D}/etc/log.d/conf/logfiles/bacula.conf
237 chmod 644 ${D}/etc/log.d/conf/services/bacula.conf
241 # the cdrom rescue package
242 mkdir -p ${D}/etc/bacula/rescue/cdrom
243 cp -R ${S}/rescue/linux/cdrom/* ${D}/etc/bacula/rescue/cdrom/
244 mkdir ${D}/etc/bacula/rescue/cdrom/bin
245 cp ${S}/src/filed/static-bacula-fd ${D}/etc/bacula/rescue/cdrom/bin/bacula-fd
246 chmod 754 ${D}/etc/bacula/rescue/cdrom/bin/bacula-fd
249 for a in ${S}/{ChangeLog,README,ReleaseNotes,kernstodo,LICENSE,doc/latex/bacula.pdf}
254 dohtml -r ${S}/doc/latex/bacula
256 # clean up permissions left broken by install
257 chmod o-r ${D}/etc/bacula/query.sql
259 # remove the working dir so we can add it postinst with group
260 rmdir ${D}/var/bacula
264 if use bacula-clientonly
266 newexe ${S}/platforms/gentoo/bacula-fd bacula-fd
270 newexe ${S}/platforms/gentoo/bacula-fd bacula-fd
271 newexe ${S}/platforms/gentoo/bacula-sd bacula-sd
272 newexe ${S}/platforms/gentoo/bacula-dir bacula-dir
274 newexe ${S}/platforms/gentoo/bacula-init bacula
280 # create the daemon group
281 HAVE_BACULA=`cat /etc/group | grep bacula 2>/dev/null`
282 if [ -z $HAVE_BACULA ]; then
285 einfo "The group bacula has been created. Any users you add to"
286 einfo "this group have access to files created by the daemons."
289 # the working directory
290 install -m0750 -o root -g bacula -d ${ROOT}/var/bacula
292 # link installed bacula-fd.conf into rescue directory
293 #ln -s /etc/bacula/bacula-fd.conf /etc/bacula/rescue/cdrom/bacula-fd.conf
294 # no longer necessary after 1.36.2
297 einfo "The CDRom rescue disk package has been installed into the"
298 einfo "/etc/bacula/rescue/cdrom/ directory. Please examine the manual"
299 einfo "for information on creating a rescue CD. CDR device detection"
300 einfo "during build has been disabled to prevent sandbox violations."
301 einfo "You need to examine /etc/bacula/rescue/cdrom/Makefile and adjust"
302 einfo "the device information for your CD recorder."
305 if ! use bacula-clientonly; then
307 einfo "Please note either/or nature of database USE flags for"
308 einfo "Bacula. If mysql is set, it will be used, else postgres"
309 einfo "else finally SQLite. If you wish to have multiple DBs on"
310 einfo "one system, you may wish to unset auxillary DBs for this"
316 # test for an existing database
317 # note: this ASSUMES no password has been set for bacula database
318 DB_VER=`mysql 2>/dev/null bacula -e 'select * from Version;'|tail -n 1`
319 if [ -z "$DB_VER" ]; then
320 einfo "This appears to be a new install and you plan to use mysql"
321 einfo "for your catalog database. You should now create it by doing"
322 einfo "these commands:"
323 einfo " sh /etc/bacula/grant_mysql_privileges"
324 einfo " sh /etc/bacula/create_mysql_database"
325 einfo " sh /etc/bacula/make_mysql_tables"
326 elif [ "$DB_VER" -lt "8" ]; then
327 elinfo "This release requires an upgrade to your bacula database"
328 einfo "as the database format has changed. Please read the"
329 einfo "manual chapter for how to upgrade your database!!!"
331 einfo "Backup your database with the command:"
332 einfo " mysqldump -f --opt bacula | bzip2 > /var/bacula/bacula_backup.sql.bz"
334 einfo "Then update your database using the scripts found in"
335 einfo "/etc/bacula/updatedb/ from your current version $DB_VER to"
336 einfo "version 8. Note that scripts must be run in order from your"
337 einfo "version to the current version."
343 # test for an existing database
344 # note: this ASSUMES no password has been set for bacula database
345 DB_VER=`echo 'select * from Version;' | psql bacula 2>/dev/null | tail -3 | head -1`
346 if [ -z "$DB_VER" ]; then
347 einfo "This appears to be a new install and you plan to use postgresql"
348 einfo "for your catalog database. You should now create it by doing"
349 einfo "these commands:"
350 einfo " sh /etc/bacula/create_postgresql_database"
351 einfo " sh /etc/bacula/make_postgresql_tables"
352 einfo " sh /etc/bacula/grant_postgresql_privileges"
353 elif [ "$DB_VER" -lt "8" ]; then
354 elinfo "This release requires an upgrade to your bacula database"
355 einfo "as the database format has changed. Please read the"
356 einfo "manual chapter for how to upgrade your database!!!"
358 einfo "Backup your database with the command:"
359 einfo " pg_dump bacula | bzip2 > /var/bacula/bacula_backup.sql.bz2"
361 einfo "Then update your database using the scripts found in"
362 einfo "/etc/bacula/updatedb/ from your current version $DB_VER to"
363 einfo "version 8. Note that scripts must be run in order from your"
364 einfo "version to the current version."
370 # test for an existing database
371 # note: this ASSUMES no password has been set for bacula database
372 DB_VER=`echo "select * from Version;" | sqlite 2>/dev/null /var/bacula/bacula.db | tail -n 1`
373 if [ -z "$DB_VER" ]; then
374 einfo "This appears to be a new install and you plan to use sqlite"
375 einfo "for your catalog database. You should now create it by doing"
376 einfo "these commands:"
377 einfo " sh /etc/bacula/grant_sqlite_privileges"
378 einfo " sh /etc/bacula/create_sqlite_database"
379 einfo " sh /etc/bacula/make_sqlite_tables"
380 elif [ "$DB_VER" -lt "8" ]; then
381 elinfo "This release requires an upgrade to your bacula database"
382 einfo "as the database format has changed. Please read the"
383 einfo "manual chapter for how to upgrade your database!!!"
385 einfo "Backup your database with the command:"
386 einfo " echo .dump | sqlite /var/bacula/bacula.db | bzip2 > \\"
387 einfo " /var/bacula/bacula_backup.sql.bz2"
389 einfo "Then update your database using the scripts found in"
390 einfo "/etc/bacula/updatedb/ from your current version $DB_VER to"
391 einfo "version 8. Note that scripts must be run in order from your"
392 einfo "version to the current version."
398 einfo "Review your configuration files in /etc/bacula and"
399 einfo "start the daemons:"
400 if use bacula-clientonly; then
401 einfo " /etc/init.d/bacula-fd start"
403 if use bacula-split; then
404 einfo " /etc/init.d/bacula-sd start"
405 einfo " /etc/init.d/bacula-dir start"
406 einfo " /etc/init.d/bacula-fd start"
407 einfo " or /etc/bacula/bacula will start all three."
409 einfo " /etc/init.d/bacula start"
413 einfo "You may also wish to:"
414 if use bacula-clientonly; then
415 einfo " rc-update add bacula-fd default"
417 if use bacula-split; then
418 einfo " rc-update add bacula-sd default"
419 einfo " rc-update add bacula-dir default"
420 einfo " rc-update add bacula-fd default"
422 einfo " rc-update add bacula default"