equal
deleted
inserted
replaced
19 sub check_perms; |
19 sub check_perms; |
20 sub config_names; |
20 sub config_names; |
21 sub get_devices; |
21 sub get_devices; |
22 |
22 |
23 sub amchecks; |
23 sub amchecks; |
24 sub amlists; |
24 sub compare_lists; |
25 |
25 |
26 sub main; |
26 sub main; |
27 |
27 |
28 my $NAME = 'AMANDA-CLIENT'; |
28 my $NAME = 'AMANDA-CLIENT'; |
29 |
29 |
79 my @confs = sort +unique eval { config_names $CFDIR } |
79 my @confs = sort +unique eval { config_names $CFDIR } |
80 or unknown $@; |
80 or unknown $@; |
81 |
81 |
82 eval { amchecks @confs } or critical $@; |
82 eval { amchecks @confs } or critical $@; |
83 |
83 |
84 my @dles = eval { amlists confs => \@confs, ignore => \@opt_ignore } or critical $@; |
84 my @dles = eval { compare_lists confs => \@confs, ignore => \@opt_ignore } or critical $@; |
85 ok 'config: ' . join(', ', @confs), @dles; |
85 ok 'config: ' . join(', ', @confs), @dles; |
86 |
86 |
87 # never reached |
87 # never reached |
88 return 0; |
88 return 0; |
89 } |
89 } |
213 my $conf = shift; |
213 my $conf = shift; |
214 chomp((undef, my @dles) = qx(amdump_client --config '$conf' list)); |
214 chomp((undef, my @dles) = qx(amdump_client --config '$conf' list)); |
215 return map { [$_, (stat $_)[1] == 2 ? (stat $_)[0] : -1] } @dles; |
215 return map { [$_, (stat $_)[1] == 2 ? (stat $_)[0] : -1] } @dles; |
216 } |
216 } |
217 |
217 |
218 sub amlists { |
218 sub compare_lists { |
219 my %arg = @_; |
219 my %arg = @_; |
220 my @confs = @{$arg{confs}} or croak 'missing list of confs'; |
220 my @confs = @{$arg{confs}} or croak 'missing list of confs'; |
221 my @ignore = @{$arg{ignore}}; |
221 my @ignore = @{$arg{ignore}}; |
222 |
222 |
|
223 warning "ignored filesystem(s) @$_ does not exist, update the config please!\n" |
|
224 if @ignore and @$_ = grep { not -e } unique map { /^.*?:(.*)/ } @ignore; |
|
225 |
223 my @candidates = get_devices; |
226 my @candidates = get_devices; |
224 |
|
225 my %missing; |
227 my %missing; |
226 |
228 |
227 foreach my $conf (@confs) { |
229 foreach my $conf (@confs) { |
228 my @dles = _amlist $conf; |
230 my @dles = _amlist $conf; |
229 foreach my $candidate (@candidates) { |
231 foreach my $candidate (@candidates) { |
237 } |
239 } |
238 } |
240 } |
239 die map { "$_ missing: " . join(', ' => @{ $missing{$_} }) . "\n" } |
241 die map { "$_ missing: " . join(', ' => @{ $missing{$_} }) . "\n" } |
240 keys %missing |
242 keys %missing |
241 if %missing; |
243 if %missing; |
|
244 |
242 return map { $_->[0] } @candidates; |
245 return map { $_->[0] } @candidates; |
243 } |
246 } |
244 |
247 |
245 sub ok { say "$NAME OK\n", join "\n" => @_; exit 0 } |
248 sub ok { say "$NAME OK\n", join "\n" => @_; exit 0 } |
246 sub warning { print "$NAME WARNING\n", join "\n" => @_; exit 1 } |
249 sub warning { print "$NAME WARNING\n", join "\n" => @_; exit 1 } |