6 bconsole.pl - Interface between brestore and bweb to use bconsole.
8 You can also use Bconsole.pm and install bconsole on your workstation.
12 Copyright (C) 2006 Eric Bollengier
15 This program is free software; you can redistribute it and/or modify
16 it under the terms of the GNU General Public License as published by
17 the Free Software Foundation; either version 2 of the License, or
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
25 You should have received a copy of the GNU General Public License
26 along with this program; if not, write to the Free Software
27 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
37 use POSIX qw/strftime/;
38 use File::Temp qw/tempfile/;
43 my $conf = new Bweb::Config(config_file => '/etc/bweb/config');
46 my $bweb = new Bweb(info => $conf);
47 my $bconsole = new Bconsole(pref => $conf);
48 my $debug = $bweb->{debug};
50 my $opts = $bweb->get_form('timeout');
51 $bconsole->{timeout} = $opts->{timeout} || 40;
53 # on doit utiliser du POST
54 print CGI::header('text/plain');
56 my @action = CGI::param('action') ;
57 my %cmd = ( 'list_job' => '.job',
58 'list_client' => '.client' ,
59 'list_storage' => '.storage',
60 'list_fileset' => '.fileset',
69 my $out = $bconsole->send_cmd($cmd{$a});
73 } elsif ($a eq 'run' and $have_run==0) {
76 my $arg = $bweb->get_form(qw/job client storage fileset
79 my $bootstrap = CGI::param('bootstrap');
81 if (!$bootstrap or !$arg->{job} or !$arg->{client}) {
82 print "ERROR: missing bootstrap or job or client\n";
86 my ($fh, $filename) = tempfile();
87 while (my $l = <$bootstrap>) {
91 chmod(0644, $filename);
93 my $jobid = $bconsole->run(job => $arg->{job},
94 client => $arg->{client},
95 storage => $arg->{storage},
96 fileset => $arg->{fileset},
97 where => $arg->{where},
98 replace => $arg->{replace},
99 priority => $arg->{priority},
100 bootstrap => $filename);
102 print "run=$jobid\n";
105 print STDERR "unknow argument $a\n";