]> git.sur5r.net Git - bacula/bacula/commitdiff
ebl add bconsole.pl to remove Bconsole.pm/Expect from brestore.pl
authorEric Bollengier <eric@eb.homelinux.org>
Sat, 18 Nov 2006 20:37:58 +0000 (20:37 +0000)
committerEric Bollengier <eric@eb.homelinux.org>
Sat, 18 Nov 2006 20:37:58 +0000 (20:37 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3654 91ce42f0-d328-0410-95d8-f526ca767f89

gui/bweb/INSTALL
gui/bweb/cgi/bconsole.pl [new file with mode: 0755]

index 6033a41f62f3f98a7384fbec7c9044735f50d35d..11a97141e9526c3dce924f43279de704764da4f5 100644 (file)
@@ -45,6 +45,10 @@ Bweb works well with 1.39 release.
  WARNING : Your www-data user must be able to execute bconsole and able to read bconsole.conf !
            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
diff --git a/gui/bweb/cgi/bconsole.pl b/gui/bweb/cgi/bconsole.pl
new file mode 100755 (executable)
index 0000000..923ba01
--- /dev/null
@@ -0,0 +1,109 @@
+#!/usr/bin/perl -w
+use strict;
+
+=head1 NAME
+
+    bconsole.pl - Interface between brestore and bweb to use bconsole.
+
+    You can also use Bconsole.pm and install bconsole on your workstation.
+
+=head1 LICENSE
+
+    Copyright (C) 2006 Eric Bollengier
+        All rights reserved.
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    any later version.
+
+    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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+=head1 VERSION
+
+    $Id$
+
+=cut
+
+use Data::Dumper;
+use CGI;
+use POSIX qw/strftime/;
+use File::Temp qw/tempfile/;
+
+use Bweb;
+use Bconsole;
+
+my $conf = new Bweb::Config(config_file => '/etc/bweb/config');
+$conf->load();
+
+my $bweb = new Bweb(info => $conf);
+my $bconsole = new Bconsole(pref => $conf);
+my $debug = $bweb->{debug};
+
+my $opts = $bweb->get_form('timeout');
+$bconsole->{timeout} = $opts->{timeout} || 40;
+
+# on doit utiliser du POST
+print CGI::header('text/plain');
+
+my @action = CGI::param('action') ;
+my %cmd = ( 'list_job'      => '.job', 
+           'list_client'   => '.client' ,
+           'list_storage'  => '.storage',
+           'list_fileset'  => '.fileset',
+          );
+
+
+my $have_run=0;
+for my $a (@action)
+{
+    if (defined $cmd{$a})
+    {
+       my $out = $bconsole->send_cmd($cmd{$a});
+       $out =~ s/\r\n/;/g ;
+       print "$a=$out\n";
+
+    } elsif ($a eq 'run' and $have_run==0) {
+       $have_run=1;
+
+       my $arg = $bweb->get_form(qw/job client storage fileset 
+                                    replace priority/);
+
+       my $bootstrap = CGI::param('bootstrap');
+       
+       if (!$bootstrap or !$arg->{job} or !$arg->{client}) {
+           print "ERROR: missing bootstrap or job or client\n";
+           exit 1;
+       }
+
+       my ($fh, $filename) = tempfile();
+       while (my $l = <$bootstrap>) {
+           $fh->print($l);
+       }
+       close($fh);
+       chmod(0644, $filename);
+       
+       my $jobid = $bconsole->run(job       => $arg->{job},
+                                  client    => $arg->{client},
+                                  storage   => $arg->{storage},
+                                  fileset   => $arg->{fileset},
+                                  where     => $arg->{where},
+                                  replace   => $arg->{replace},
+                                  priority  => $arg->{priority},
+                                  bootstrap => $filename);
+
+       print "run=$jobid\n";
+
+    } else {
+       print STDERR "unknow argument $a\n";
+    }
+}
+
+exit 0;