=head1 COPYRIGHT
- Copyright (C) 2006 Marc Cousin and Eric Bollengier
+ Bacula® - The Network Backup Solution
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
-
- Base 64 functions from Karl Hakimian <hakimian@aha.com>
- Integrally copied from recover.pl from bacula source distribution.
+ Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
+
+ Brestore authors are Marc Cousin and Eric Bollengier.
+ The main author of Bacula is Kern Sibbald, with contributions from
+ many others, a complete list can be found in the file AUTHORS.
+
+ This program is Free Software; you can redistribute it and/or
+ modify it under the terms of version two of the GNU General Public
+ License as published by the Free Software Foundation plus additions
+ that are listed in the file LICENSE.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA.
+
+ Bacula® is a registered trademark of John Walker.
+ The licensor of Bacula is the Free Software Foundation Europe
+ (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zurich,
+ Switzerland, email:ftf@fsfeurope.org.
+
+ Base 64 functions from Karl Hakimian <hakimian@aha.com>
+ Integrally copied from recover.pl from bacula source distribution.
=cut
-use File::Spec; # portable path manipulations
use Gtk2; # auto-initialize Gtk2
use Gtk2::GladeXML;
use Gtk2::SimpleList; # easy wrapper for list views
}
1;
+################################################################
+package BwebConsole;
+use LWP::UserAgent;
+use HTTP::Request::Common;
+
+sub new
+{
+ my ($class, %arg) = @_;
+
+ my $self = bless {
+ pref => $arg{pref}, # Pref object
+ timeout => $arg{timeout} || 20,
+ debug => $arg{debug} || 0,
+ 'list_job' => '',
+ 'list_client' => '',
+ 'list_fileset' => '',
+ 'list_storage' => '',
+ 'run' => '',
+ };
+
+ return $self;
+}
+
+sub prepare
+{
+ my ($self, @what) = @_;
+ my $ua = LWP::UserAgent->new();
+ $ua->agent("Brestore ");
+ my $req = POST($self->{pref}->{bconsole},
+ Content_Type => 'form-data',
+ Content => [ map { (action => $_) } @what ]);
+ #$req->authorization_basic('eric', 'test');
+
+ my $res = $ua->request($req);
+
+ if ($res->is_success) {
+ foreach my $l (split(/\n/, $res->content)) {
+ my ($k, $c) = split(/=/,$l,2);
+ $self->{$k} = $c;
+ }
+ } else {
+ $self->{error} = "Can't connect to bweb : " . $res->status_line;
+ new DlgWarn($self->{error});
+ }
+}
+
+sub run
+{
+ my ($self, %arg) = @_;
+
+ my $ua = LWP::UserAgent->new();
+ $ua->agent("Brestore ");
+ my $req = POST($self->{pref}->{bconsole},
+ Content_Type => 'form-data',
+ Content => [ job => $arg{job},
+ client => $arg{client},
+ storage => $arg{storage} || '',
+ fileset => $arg{fileset} || '',
+ where => $arg{where},
+ replace => $arg{replace},
+ priority=> $arg{prio} || '',
+ action => 'run',
+ timeout => 10,
+ bootstrap => [$arg{bootstrap}],
+ ]);
+ #$req->authorization_basic('eric', 'test');
+
+ my $res = $ua->request($req);
+
+ if ($res->is_success) {
+ foreach my $l (split(/\n/, $res->content)) {
+ my ($k, $c) = split(/=/,$l,2);
+ $self->{$k} = $c;
+ }
+ }
+
+ if ($self->{run}) {
+ unlink($arg{bootstrap});
+ new DlgWarn("Can't connect to bweb : " . $res->status_line);
+ }
+
+ return $self->{run};
+}
+
+sub list_job
+{
+ my ($self) = @_;
+ return sort split(/;/, $self->{'list_job'});
+}
+
+sub list_fileset
+{
+ my ($self) = @_;
+ return sort split(/;/, $self->{'list_fileset'});
+}
+
+sub list_storage
+{
+ my ($self) = @_;
+ return sort split(/;/, $self->{'list_storage'});
+}
+sub list_client
+{
+ my ($self) = @_;
+ return sort split(/;/, $self->{'list_client'});
+}
+
+1;
+
################################################################
package DlgLaunch;
-use Bconsole;
+#use Bconsole;
# %arg = (bsr_file => '/path/to/bsr', # on director
# volumes => [ '00001', '00004']
# pref => ref Pref
# );
+sub get_bconsole
+{
+ my ($pref) = (@_);
+
+ if ($pref->{bconsole} =~ /^http/) {
+ return new BwebConsole(pref => $pref);
+ } else {
+ if (eval { require Bconsole; }) {
+ return new Bconsole(pref => $pref);
+ } else {
+ new DlgWarn("Can't use bconsole, verify your setup");
+ return undef;
+ }
+ }
+}
+
sub new
{
my ($class, %arg) = @_;
bconsole => undef, # Bconsole ref
};
+ my $console = $self->{bconsole} = get_bconsole($arg{pref});
+ unless ($console) {
+ return undef;
+ }
+
# we load launch widget of $glade_file
my $glade = $self->{glade} = Gtk2::GladeXML->new($glade_file,
"dlg_launch");
# fill volume view
push @{ $volview->{data} }, @{$infos} ;
-
- my $console = $self->{bconsole} = new Bconsole(pref => $arg{pref});
+
+ $console->prepare(qw/list_client list_job list_fileset list_storage/);
# fill client combobox (with director defined clients
my @clients = $console->list_client() ; # get from bconsole
return -1;
}
- system("$self->{mozilla} -remote 'Ping()'");
- if ($? != 0) {
- new DlgWarn("Warning, you must have a running $self->{mozilla} to $msg");
- return 0;
- }
+ if ($^O eq 'MSWin32') {
+ system("start /B $self->{mozilla} \"$self->{bweb}$url\"");
- my $cmd = "$self->{mozilla} -remote 'OpenURL($self->{bweb}$url,new-tab)'" ;
- print "$cmd\n";
- system($cmd);
+ } elsif (!fork()) {
+ system("$self->{mozilla} -remote 'Ping()'");
+ my $cmd = "$self->{mozilla} '$self->{bweb}$url'";
+ if ($? == 0) {
+ $cmd = "$self->{mozilla} -remote 'OpenURL($self->{bweb}$url,new-tab)'" ;
+ }
+ exec($cmd);
+ exit 1;
+ }
return ($? == 0);
}
sub on_go_button_clicked
{
my $self = shift;
+ unless (scalar(@{$self->{restore_list}->{data}})) {
+ new DlgWarn("No file to restore");
+ return 0;
+ }
my $bsr = $self->create_filelist();
my ($fh, $filename) = tempfile();
$fh->print($bsr);
{
$self->ch_dir('');
}
- my @dirs = File::Spec->splitdir ($self->{cwd});
+ my @dirs = split(/\//, $self->{cwd});
pop @dirs;
- $self->ch_dir(File::Spec->catdir(@dirs));
+ $self->ch_dir(join('/', @dirs));
}
# Change the current working directory
{
my ($dbh, $filename, $jobid)=@_;
- my @dirs = File::Spec->splitdir ($filename);
+ my @dirs = split(/\//, $filename);
$filename=pop(@dirs);
- my $dirname = File::Spec->catdir(@dirs) . '/';
+ my $dirname = join('/', @dirs) . '/';
my $query;
}
}
+# gtk have lots of warning on stderr
+if ($^O eq 'MSWin32')
+{
+ close(STDERR);
+ open(STDERR, ">stderr.log");
+}
+
Gtk2->init();
if ( -f $glade_file) {