From: Eric Bollengier Date: Sat, 18 Nov 2006 20:37:58 +0000 (+0000) Subject: ebl add bconsole.pl to remove Bconsole.pm/Expect from brestore.pl X-Git-Tag: Release-2.0.0~263 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0e7db9b9943cd63ee01afa02dd0d74acdf0bf7e5;p=bacula%2Fbacula ebl add bconsole.pl to remove Bconsole.pm/Expect from brestore.pl git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3654 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/gui/bweb/INSTALL b/gui/bweb/INSTALL index 6033a41f62..11a97141e9 100644 --- a/gui/bweb/INSTALL +++ b/gui/bweb/INSTALL @@ -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 index 0000000000..923ba014eb --- /dev/null +++ b/gui/bweb/cgi/bconsole.pl @@ -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;