4 if ($command eq "privilege") {
7 elsif ($command eq "support") {
10 elsif ($command eq "selfcheck") {
13 elsif ($command eq "estimate") {
16 elsif ($command eq "estimate-parse") {
17 wrapper_estimate_parse();
19 elsif ($command eq "backup") {
22 elsif ($command eq "backup-parse") {
23 wrapper_backup_parse();
25 elsif ($command eq "index-from-output") {
26 wrapper_index_from_output();
28 elsif ($command eq "index-from-image") {
29 wrapper_index_from_image();
31 elsif ($command eq "restore") {
34 elsif ($command eq "print-command") {
35 wrapper_print_command();
38 printf STDERR "Unknown command `$command'.\n";
43 sub wrapper_privilege() {
44 if(defined(&command_support)) {
48 my($subcommand) = $ARGV[1];
49 if ($subcommand eq "support") {
50 wrapper_print_privilege($subcommand);
52 elsif ($subcommand eq "selfcheck") {
53 wrapper_print_privilege($subcommand);
55 elsif ($subcommand eq "estimate") {
56 wrapper_print_privilege($subcommand);
58 elsif ($subcommand eq "estimate-parse") {
59 wrapper_print_privilege($subcommand);
61 elsif ($subcommand eq "backup") {
62 wrapper_print_privilege($subcommand);
64 elsif ($subcommand eq "backup-parse") {
65 wrapper_print_privilege($subcommand);
67 elsif ($subcommand eq "index-from-output") {
68 wrapper_print_privilege($subcommand);
70 elsif ($subcommand eq "index-from-image") {
71 wrapper_print_privilege($subcommand);
73 elsif ($subcommand eq "restore") {
74 wrapper_print_privilege($subcommand);
76 elsif ($subcommand eq "print-command") {
77 wrapper_print_privilege($subcommand);
80 printf STDERR "Unknown command `$subcommand'.\n";
83 if(defined($user_default) && defined($group_default)) {
84 print "USER $user_default\n";
85 print "GROUP $group_default\n";
92 sub wrapper_print_privilege {
95 my($var_user) = "user_$command";
96 my($var_group) = "group_$command";
97 if(defined($$var_user) && defined($$var_group)) {
98 print "USER $$var_user\n";
99 print "GROUP $$var_group\n";
102 elsif(defined($$var_user) && !defined($$var_group)) {
103 print STDERR "\$$var_user defined but \$$var_group not defined\n";
106 elsif(!defined($$var_user) && defined($$var_group)) {
107 print STDERR "\$$var_group defined but \$$var_user not defined\n";
112 sub wrapper_support() {
113 if(defined(&command_support)) {
117 my($subcommand) = $ARGV[1];
118 if ($subcommand eq "level-incrementals") {
119 if (defined($level_incrementals)) {
120 print "$level_incrementals\n";
127 elsif ($subcommand eq "index") {
128 my($index_generation);
129 foreach $index_generation (@index_generation) {
130 if( $index_generation eq "direct" ||
131 $index_generation eq "parse" ||
132 $index_generation eq "output" ||
133 $index_generation eq "image") {
134 print "$index_generation\n";
137 print "unknow indexing method '$index_generation'\n";
142 elsif ($subcommand eq "parse-estimate") {
144 foreach $parse_estimate (@parse_estimate) {
145 if( $parse_estimate eq "direct" ||
146 $parse_estimate eq "parse" ) {
147 print "$parse_estimate\n";
150 print "unknow parse-estimate method '$parse_estimate'\n";
155 elsif ($subcommand eq "parse-backup") {
156 print "direct\n" if (defined($parse_backup_direct));
157 print "parse\n" if (defined($parse_backup_parse));
159 foreach $parse_backup (@parse_backup) {
160 if( $parse_backup eq "direct" ||
161 $parse_backup eq "parse" ) {
162 print "$parse_backup\n";
165 print "unknow parse-backup method '$parse_backup'\n";
175 sub wrapper_selfcheck() {
176 if(defined(&command_selfcheck)) {
184 sub wrapper_estimate() {
185 my($estimate_type) = $ARGV[1];
187 my($estimate_type_is_ok) = 0;
189 foreach $backups_type (@backup_type) {
190 $estimate_type_is_ok = 1 if($estimate_type eq $backups_type);
192 if($estimate_type_is_ok == 0) {
193 print "estimate type `$estimate_type' not supported.\n";
196 $option = 3 if ($estimate_type eq "full");
197 $option = 4 if ($estimate_type eq "level");
198 $option = 4 if ($estimate_type eq "diff");
199 parse_options($option);
200 if($option_estimate_direct + $option_estimate_parse > 1) {
201 print "Can't define both `estimate-direct' and `estimate-parse'.\n";
204 elsif($option_estimate_direct + $option_estimate_parse == 0) {
205 print "You must have the option `estimate-direct' or `estimate-parse'.\n";
208 if($estimate_type eq "full") {
209 command_estimate_full($ARGV[2]);
211 elsif($estimate_type eq "level") {
212 command_estimate_level($ARGV[2], $ARGV[3]);
214 elsif($estimate_type eq "diff") {
215 command_estimate_diff($ARGV[2], $ARGV[3]);
219 sub wrapper_estimate_parse() {
220 if(defined(&command_estimate_parse)) {
221 command_estimate_parse();
224 printf STDERR "`estimate-parse' is not supported.\n";
229 sub wrapper_backup() {
230 my($backup_type) = $ARGV[1];
232 my($backup_type_is_ok) = 0;
234 foreach $backups_type (@backup_type) {
235 $backup_type_is_ok = 1 if($backup_type eq $backups_type);
237 if($backup_type_is_ok == 0) {
238 print "backup type `$backup_type' not supported.\n";
241 $option = 3 if ($backup_type eq "full");
242 $option = 4 if ($backup_type eq "level");
243 $option = 4 if ($backup_type eq "diff");
244 parse_options($option);
245 if($option_backup_direct + $option_backup_parse > 1) {
246 print "Can't define both `backup-direct' and `backup-parse'.\n";
249 elsif($option_backup_direct + $option_backup_parse == 0) {
250 print "You must have the option `backup-direct' or `backup-parse'.\n";
253 if($backup_type eq "full") {
254 command_backup_full($ARGV[2]);
256 elsif($backup_type eq "level") {
257 command_backup_level($ARGV[2], $ARGV[3]);
259 elsif($backup_type eq "diff") {
260 command_backup_diff($ARGV[2], $ARGV[3]);
264 sub wrapper_backup_parse() {
265 if(defined(&command_backup_parse)) {
266 command_backup_parse();
269 printf STDERR "`backup-parse' is not supported.\n";
274 sub wrapper_index_from_output() {
275 if(defined(&command_index_from_output)) {
276 command_index_from_output();
279 printf STDERR "`index-from-output' is not supported.\n";
284 sub wrapper_index_from_image() {
285 if(defined(&command_index_from_image)) {
286 command_index_from_image();
289 printf STDERR "command `index-from-image' is not supported.\n";
294 sub wrapper_restore() {
295 if(defined(&command_restore)) {
299 printf STDERR "`restore' is not supported.\n";
304 sub wrapper_print_command() {
305 if(defined(&command_print_command)) {
306 command_print_command();
309 printf STDERR "`print-command' is not supported.\n";
315 sub parse_options() {
317 my($options, @options, $option, $name, $option_name, $value);
319 while($no_option <= $#ARGV) {
320 $options = $ARGV[${no_option}];
321 @options = split (/;/,$options);
322 foreach $option (@options) {
323 if( $option =~ /=/ ) {
324 ($name,$value) = split(/=/,$option);
330 $option_name = "option_$name";
331 $option_name =~ s/\-/\_/g;
332 $$option_name = $value;
339 my($filename, $mode) = @_;
345 print "OK $filename exists\n";
348 print "ERROR [can not find $filename]\n";
351 elsif($mode eq "x") {
353 print "OK $filename executable\n";
356 print "ERROR [can not execute $filename]\n";
359 elsif($mode eq "r") {
361 print "OK $filename readable\n";
364 print "ERROR [can not read $filename]\n";
367 elsif($mode eq "w") {
369 print "OK $filename writable\n";
372 print "ERROR [can not write $filename]\n";
376 print "ERROR [check_file: unknow mode $mode]\n";