2 # Copyright (c) 2008-2012 Zmanda, Inc. All Rights Reserved.
4 # This program is free software; you can redistribute it and/or modify it
5 # under the terms of the GNU General Public License version 2 as published
6 # by the Free Software Foundation.
8 # This program is distributed in the hope that it will be useful, but
9 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # You should have received a copy of the GNU General Public License along
14 # with this program; if not, write to the Free Software Foundation, Inc.,
15 # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300
18 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
20 package Amanda::Extract;
26 use Amanda::Debug qw( :logging );
31 Amanda::Extract - perl utilities to run scripts and applications
37 my (@bsu, @err)= Amanda::Extract::BSU(application => $application,
42 my (@bsu, @err)= Amanda::Extract::Run($application_name, \@g_options,
54 push @command, $Amanda::Paths::APPLICATION_DIR . '/' . $params{'application'};
55 push @command, "support";
56 push @command, "--config", $params{'config'} if $params{'config'};
57 push @command, "--host" , $params{'host'} if $params{'host'};
58 push @command, "--disk" , $params{'disk'} if $params{'disk'};
59 push @command, "--device", $params{'device'} if $params{'device'};
60 debug("Running: " . join(' ', @command));
64 my $err = Symbol::gensym;
65 my $pid = open3($in, $out, $err, @command);
68 while (my $line = <$out>) {
70 debug("support: $line");
71 my ($name, $value) = split ' ', $line;
75 if ($name eq 'config' ||
78 $name eq 'index-line' ||
79 $name eq 'index-xml' ||
80 $name eq 'message-line' ||
81 $name eq 'message-xml' ||
83 $name eq 'include-file' ||
84 $name eq 'include-list' ||
85 $name eq 'include-list-glob' ||
86 $name eq 'include-optional' ||
87 $name eq 'exclude-file' ||
88 $name eq 'exclude-list' ||
89 $name eq 'exclude-list-glob' ||
90 $name eq 'exclude-optional' ||
91 $name eq 'collection' ||
92 $name eq 'caclsize' ||
93 $name eq 'client-estimate' ||
94 $name eq 'multi-estimate' ||
95 $name eq 'amfeatures') {
96 $bsu{$name} = ($value eq "YES");
97 } elsif ($name eq 'max-level') {
99 } elsif ($name eq 'recover-mode') {
100 $bsu{'smb-recover-mode'} = $value eq 'SMB';
101 } elsif ($name eq 'recover-path') {
102 $bsu{'recover-path-cwd'} = $value eq 'CWD';
103 $bsu{'recover-path-remote'} = $value eq 'REMOTE';
104 } elsif ($name eq 'data-path') {
105 if ($value eq 'AMANDA') {
106 $bsu{'data-path-amanda'} = 1;
107 } elsif ($value eq 'DIRECTTCP') {
108 $bsu{'data-path-directtcp'} = 1;
114 while (my $line = <$err>) {
122 my $child_exit_status = $? >> 8;
124 if ($child_exit_status != 0) {
125 push @err, "exited with status $child_exit_status";
127 return (\%bsu, \@err);