=cut
has 'valid_maptypes' => (
- is => 'ro',
+ is => 'rw',
isa => 'HashRef',
traits => [ 'NoGetopt' ],
lazy => 1,
'static' => { restart => 0, do_map => 0, exec_map => 0, },
'tcp' => { restart => 0, do_map => 0, exec_map => 0, },
'unix' => { restart => 0, do_map => 0, exec_map => 0, },
+ 'nis' => { restart => 0, do_map => 0, exec_map => 0, },
};
}
=cut
has 'postfix_binary' => (
- is => 'ro',
+ is => 'rw',
isa => 'HashRef',
traits => [ 'NoGetopt' ],
lazy => 1,
my $self = shift;
#return if $self->configuration_evaluated;
- $self->debug( "Werte Backup-Konfigurationsdinge aus ..." );
- return unless $self->config and keys %{ $self->config };
- my @ConfigKeys = qw( postfix_dir work_dir );
+ if ( $self->config and keys %{ $self->config } ) {
- for my $key ( keys %{ $self->config } ) {
+ $self->debug( "Werte Konfigurationsdinge aus ..." );
+ my @ConfigKeys = qw( postfix_dir work_dir );
+
+ for my $key ( keys %{ $self->config } ) {
+
+ my $val = $self->config->{$key};
- my $val = $self->config->{$key};
-
- for my $p ( @ConfigKeys ) {
- my $f = $p;
- my $r = $p;
- $r =~ s/_/\[_-\]\?/g;
- $r = "^$r\$";
- $self->debug( sprintf( "Regex 1: '%s'", $r ) ) if $self->verbose >= 4;
- unless ( $self->used_cmd_params->{$f} ) {
- if ( $key =~ /$r/i ) {
- $self->debug( sprintf( "Gefunden: \$self->config->{%s} -> '%s'", $key, ( defined $val ? $val : '<undef>' ) ) ) if $self->verbose >= 2;
- $self->$f($val);
+ for my $p ( @ConfigKeys ) {
+ my $f = $p;
+ my $r = $p;
+ $r =~ s/_/\[_-\]\?/g;
+ $r = "^$r\$";
+ $self->debug( sprintf( "Regex 1: '%s'", $r ) ) if $self->verbose >= 4;
+ unless ( $self->used_cmd_params->{$f} ) {
+ if ( $key =~ /$r/i ) {
+ $self->debug( sprintf( "Gefunden: \$self->config->{%s} -> '%s'", $key, ( defined $val ? $val : '<undef>' ) ) ) if $self->verbose >= 2;
+ $self->$f($val);
+ }
}
}
- }
- if ( $key =~ /^schema[-_]?class$/i and not $self->config->{'schema_class'} ) {
- $self->config->{'schema_class'} = $val;
+ if ( $key =~ /^schema[-_]?class$/i and not $self->config->{'schema_class'} ) {
+ $self->config->{'schema_class'} = $val;
+ }
+
}
}
$self->debug( sprintf( "Setze Arbeitsverzeichnis auf '%s' ...", $d ) ) if $self->verbose >= 2;
}
+ $self->_initialise_binaries();
+ $self->_initialise_maptypes();
$self->_initialise_maps();
};
#---------------------------------------------------------------------------
+=head2 _initialise_maptypes( )
+
+Überprüft, welche Maptypen Postfix auf der aktuellen Maschine überhaupt unterstützt
+
+=cut
+
+sub _initialise_maptypes {
+
+ my $self = shift;
+
+ my $valid_maptypes = $self->valid_maptypes;
+ my $postconf = $self->postfix_binary->{'postconf'};
+ my $cmd = $postconf . " -m";
+
+ $self->debug( "Überprüfe Lookup-Tabellenarten von Postfix ..." );
+ $self->debug( sprintf( "Mit dem Kommando: '%s'", $cmd ) );
+
+ my $out = `$cmd`;
+ if ( $? ) {
+ $self->error( sprintf( "Fehler beim Aufruf von '%s'.", $cmd ) );
+ exit 13;
+ }
+
+ my @Types = split /\s*\n+\s*/, $out;
+ $self->debug( "Gefundene Tabellenarten: ", \@Types ) if $self->verbose >= 3;
+
+ for my $type ( keys %$valid_maptypes ) {
+ $valid_maptypes->{$type}{'ok'} = undef;
+ }
+
+ for my $type ( @Types ) {
+ my $t = lc($type);
+ if ( $valid_maptypes->{$t} ) {
+ $valid_maptypes->{$t}{'ok'} = 1;
+ }
+ else {
+ $self->warn( sprintf( "Unbekannte Lookup-Tabellenart '%s' gefunden.", $t ) );
+ }
+ }
+
+ for my $type ( keys %$valid_maptypes ) {
+ if ( $valid_maptypes->{$type}{'ok'} ) {
+ $self->debug( sprintf( "Tabellenart '%s' gefunden.", $type ) ) if $self->verbose >= 3;
+ delete $valid_maptypes->{$type}{'ok'};
+ }
+ else {
+ $self->debug( sprintf( "Tabellenart '%s' NICHT gefunden.", $type ) );
+ delete $valid_maptypes->{$type};
+ }
+ }
+
+ return 1;
+
+}
+
+#---------------------------------------------------------------------------
+
+=head2 _initialise_binaries( )
+
+Holt eventuelle Angaben zu den Postfix-Binaries aus der Konfiguration
+und überprüft deren Vorhandensein.
+
+=cut
+
+sub _initialise_binaries {
+
+ my $self = shift;
+
+ my $binary = $self->postfix_binary;
+
+ if ( $self->config and keys %{ $self->config } ) {
+
+ $self->debug( "Werte Konfigurationsdinge aus ..." );
+
+ for my $key ( keys %{ $self->config } ) {
+
+ if ( $key =~ /^binary$/i ) {
+
+ my $hash = $self->config->{$key};
+ if ( $hash and ref($hash) and ref($hash) eq 'HASH' ) {
+ for my $bin ( keys %$hash ) {
+ my $name = lc($bin);
+ my $executable = $hash->{$name};
+ if ( $executable and $binary->{$name} ) {
+ $self->debug( sprintf( "Weise '%s' die Datei '%s' zu.", $name, $executable ) ) if $self->verbose >= 2;
+ $binary->{$name} = $executable;
+ }
+ }
+ }
+
+ }
+
+ }
+
+ }
+
+ my $bins_valid = 1;
+
+ for my $bin ( keys %$binary ) {
+
+ my $executable = $binary->{$bin};
+ $self->debug( sprintf( "Checke Vorhandensein von '%s' ...", $executable ) ) if $self->verbose >= 2;
+
+ unless ( -x $executable ) {
+ $self->error( sprintf( "Datei '%s' ist entweder nicht da oder nicht ausführbar.", $executable ) );
+ $bins_valid = undef;
+ }
+
+ }
+
+ exit 12 unless $bins_valid;
+
+}
+
+#---------------------------------------------------------------------------
+
sub _initialise_maps {
my $self = shift;