################################################################
#               INSTALL NOTES                                  #
################################################################

Bweb works well with 1.39 release or later.

1) install perl lib
2) copy your files
3) intialise your configuration file
4) do some sql stuff (for postgresql users)
5) use the -n option on bconsole so that it works with Expect
6) get bacula log more useful
7) bweb limitation
8) using sudo with autochanger
9) using bfileview.pl
10) accessing to bweb

################ FILE COPY #####################################
 # you must get bweb cvs files
 cvs -d:pserver:anonymous@bacula.cvs.sourceforge.net:/cvsroot/bacula login 
 cvs -z3 -d:pserver:anonymous@bacula.cvs.sourceforge.net:/cvsroot/bacula co -P gui
 cd gui

 # or get them from the released tar files or from the apt or rpms.

 # first, copy the bweb perl library into your PERL5 INC path
 install -m 644 -o root -g root  bweb/lib/*.pm /usr/share/perl5

 # copy the bweb perl program to your cgi location
 mkdir -m 755 /usr/lib/cgi-bin/bweb
 install -m 755 -o root -g root  bweb/cgi/*.pl /usr/lib/cgi-bin/bweb

 # get a config file
 mkdir -m 755 /etc/bacula
 chown root:bacula /etc/bacula
 echo '$VAR1 = { template_dir => "/usr/share/bweb/tpl" };' > /etc/bacula/bweb.conf
 chown www-data /etc/bacula/bweb.conf

 # copy the bweb template file
 mkdir -p /usr/share/bweb/tpl
 install -m 644 -o root -g root  bweb/tpl/*.tpl /usr/share/bweb/tpl

 # copy the bweb graphics elements (bweb elements must reside in /bweb)
 mkdir /var/www/bweb
 install -m 644 -o root -g root  bweb/html/*.{js,png,css,gif,ico} /var/www/bweb

 # done !

 WARNING : Your www-data user must be able to execute bconsole and able 
           to read the bconsole.conf file!
           You can create an bconsole group for that.

################ USE FRENCH VERSION ############################

Simply use lang/fr/tpl/*.tpl files instead of tpl/*.tpl

################ INSTALL PERL LIBRARY ##########################

 - perl modules
    - DBI (with mysql or postgresql support DBD::Pg and DBD::mysql)
    - Gd::Graph
    - Gd
    - HTML::Template
    - CGI
    - Expect
    - Time::ParseDate

 You can install perl modules with CPAN
 perl -e shell -MCPAN
  > install Expect

 Or use your distribution
 apt-get install libgd-graph-perl libhtml-template-perl libexpect-perl
 apt-get install libdbd-mysql-perl libdbd-pg-perl libdbi-perl libtime-modules-perl

################ APACHE CONFIGURATION ##########################

It could be a good idea to protect your bweb installation.

Put this in your httpd.conf, and add user with htpasswd

<Directory /usr/lib/cgi-bin/bweb>
        Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
        AuthType Basic
        AuthName MyPrivateFile
        AuthUserFile /etc/apache/htpasswd
        AllowOverride None
        Require valid-user
</Directory>


################ CONFIGURATION #################################

/etc/bacula/bweb.conf looks like : (you can edit it inside bweb)
$VAR1 = bless( {
  'graph_font' => '/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf',
  'name' => undef,
  'config_file' => '/etc/bacula/bweb.conf',
  'bconsole' => '/usr/sbin/bconsole -n -c /etc/bacula/bconsole.conf',
  'ach_list' => {
     'S1_L80' => bless( {
         'info' => {
                     'drive' => 0,
                     'io' => 0,
                     'slot' => 0
                   },
         'name' => 'S1_L80',
         'bweb' => undef,
         'device' => '/dev/changer',
         'drive' => [],
         'debug' => 0,
         'label' => {},
         'precmd' => 'sudo',
         'io' => [],
         'mtxcmd' => '/usr/sbin/mtx',
         'drive_name' => [
                           'S1_L80_SDLT0',
                           'S1_L80_SDLT1'
                         ],
         'slot' => []
       }, 'Bweb::Autochanger' )
   },
  'password' => 'xxx',
  'template_dir' => '/usr/share/bweb/tpl',
  'dbi' => 'DBI:mysql:database=bacula',
  'error' => '',
  'debug' => 0,
  'user' => 'bacula',
  'email_media' => 'eric@localhost'
}, 'Bweb::Config' );


################ BRESTORE ######################################

If you want to use brestore with bweb, you must associate a mime type
text/brestore with your brestore.pl.

################ POSTGRESQL NOTES ##############################

If you want to use PostgreSQL instead of MySQL, you must add
a function to the PostgreSQL Bacula database to get Bweb to work.

psql -u bacula bacula < script/bweb-postgresql.sql

################ BCONSOLE NOTES ################################

You must use bconsole without conio/readline support. For that, use
the bconsole -n option.

################ BACULA LOG ####################################

To use Bweb log engine you MUST use catalog message type.

Messages {
  Name = Standard

  operator = root@localhost = mount
  console = all, !skipped, !saved
  append = "/tmp/bacula/var/bacula/working/log" = all, !skipped

  catalog = all, !skipped, !saved
}


################ BWEB LIMITATION ###############################

To get bweb working, you must follow these rules
 - Media, Storage and Pool must have [A-Za-z_0-9\.-]+ (no space)
 - AutoChanger name must be same as Device and Location name in bacula

################ SUDO CONFIGURATION ############################

If you use sudo, put this on you /etc/sudoers

www-data ALL = (root) NOPASSWD: /usr/sbin/mtx -f /dev/changer transfer *
www-data ALL = (root) NOPASSWD: /usr/sbin/mtx -f /dev/changer status
www-data ALL = (root) NOPASSWD: /usr/sbin/mtx -f /dev/changer load *
www-data ALL = (root) NOPASSWD: /usr/sbin/mtx -f /dev/changer unload *

################ BFILEVIEW SETUP ###############################

At this time, bfileview works only with PostgreSQL.

Alias /bweb/fv /var/spool/bweb
<Directory "/var/spool/bweb">
    Options None
    AllowOverride AuthConfig
    Order allow,deny
    Allow from all
</Directory>

mkdir /var/spool/bweb
chmod 700 /var/spool/bweb
chown www-data /var/spool/bweb

You have to remove "<!-- Remove this to activate bfileview" and "-->" from
tpl/display_job_zoom.tpl.

You must use brestore.pl -b to initialise the database, and
you can use bfileview.pl mode=batch jobid=xxx where=/ to compute tree size.

At this time, it's a good idea to schedule brestore.pl -b after your 
BackupCatalog job.

Job {
  Name = "BackupCatalog"
  ...
  # This creates an ASCII copy of the catalog
  RunBeforeJob = "/opt/bacula/etc/make_catalog_backup bacula bacula Pei0ahm9"
  # This deletes the copy of the catalog
  RunAfterJob  = "/opt/bacula/etc/delete_catalog_backup"
  RunAfterJob  = "/usr/local/bin/brestore.pl -b"
}

To upgrade from an old installation, you can use :
ALTER TABLE brestore_pathvisibility ADD Size int8;
ALTER TABLE brestore_pathvisibility ADD Files int4;

################ ACCESSING TO BWEB ###############################

Now, you are able to launch firefox/mozilla and go on
http://your-server/bweb

Enjoy !
