]> Frank Brehm's Git Trees - my-stuff/postfix-maps.git/commitdiff
Default-Config vereinfacht, Reload Postfix integriert
authorFrank Brehm <frank@brehm-online.com>
Fri, 6 Aug 2010 10:05:22 +0000 (10:05 +0000)
committerFrank Brehm <frank@brehm-online.com>
Fri, 6 Aug 2010 10:05:22 +0000 (10:05 +0000)
git-svn-id: http://svn.brehm-online.com/svn/my-stuff/postfix-maps/trunk@112 ec8d2aa5-1599-4edb-8739-2b3a1bc399aa

etc/config.yml
lib/FrBr/Postfix/App.pm

index 67bd65d065300c1b1bdf932942b6c7f85a4c4fa1..36a3c2af572938ac7cc3a1439162a30fe06e98d8 100644 (file)
@@ -40,60 +40,6 @@ maps:
       where:
          enabled: y
       order_by: alias
-   canonical:
-      file: canonical
-      description: 'Canonical Mappings'
-      enabled: 1
-      db_type: hash
-      text_type: map
-      resultset: Canonical
-      columns:
-         - email
-         - destination
-      where:
-         enabled: y
-      order_by: email
-   mydomains:
-      file: mydomains
-      description: 'Alle lokalen (echten) Domänen'
-      enabled: 1
-      db_type: hash
-      text_type: map
-      resultset: Domain
-      columns:
-         - domain
-         - domain
-      where:
-         type: local
-         enabled: y
-      order_by: domain
-   recipient_bcc:
-      file: recipient_bcc
-      description: 'BCC-Zuordnungen zu lokalen Empfängern'
-      enabled: 1
-      db_type: hash
-      text_type: map
-      resultset: RecipientBcc
-      columns:
-         - email
-         - destination
-      where:
-         enabled: y
-      order_by: email
-   relay_domains:
-      file: relay_domains
-      description: 'Alle Relay-Domänen'
-      enabled: 1
-      db_type: hash
-      text_type: map
-      resultset: Domain
-      columns:
-         - domain
-         - domain
-      where:
-         type: relay
-         enabled: y
-      order_by: domain
    relocated:
       file: relocated
       description: 'Alle relocatet Mailadressen'
@@ -107,33 +53,6 @@ maps:
       where:
          enabled: y
       order_by: email
-   sender_bcc:
-      file: sender_bcc
-      description: 'BCC-Zuordnungen zu lokalen Sendern'
-      enabled: 1
-      db_type: hash
-      text_type: map
-      resultset: SenderBcc
-      columns:
-         - email
-         - destination
-      where:
-         enabled: y
-      order_by: email
-   virtual_alias_domains:
-      file: virtual_alias_domains
-      description: 'Virtuelle Alias-Domänen'
-      enabled: 1
-      db_type: hash
-      text_type: map
-      resultset: Domain
-      columns:
-         - domain
-         - domain
-      where:
-         type: valias
-         enabled: y
-      order_by: domain
    virtual_alias_maps:
       file: virtual_alias_maps
       description: 'Virtuelle Alias-Mappings'
@@ -147,31 +66,3 @@ maps:
       where:
          enabled: y
       order_by: email
-   virtual_mailbox_domains:
-      file: virtual_mailbox_domains
-      description: 'Virtuelle Mailbox-Domänen'
-      enabled: 1
-      db_type: hash
-      text_type: map
-      resultset: Domain
-      columns:
-         - domain
-         - domain
-      where:
-         type: vmbox
-         enabled: y
-      order_by: domain
-   virtual_mailbox_maps:
-      file: virtual_mailbox_maps
-      description: 'Virtuelle Mailbox-Mappings'
-      enabled: 1
-      db_type: hash
-      text_type: map
-      resultset: User
-      columns:
-         - email
-         - maildir
-      where:
-         enabled: y
-         postfix: y
-      order_by: email
index 82284f082c6e45620d09369d9e22815905d54569..7c19d69d8d3c5ec81696acc184ca380a1690110c 100644 (file)
@@ -108,24 +108,24 @@ sub _build_workdir {
 
 #-------------------------
 
-=head2 restart_postfix
+=head2 reload_postfix
 
-Soll nach dem Mapping Postfix neu gestartet werden?
+Soll nach dem Mapping Postfix neu geladen werden?
 
 =cut
 
-has 'restart_postfix' => (
+has 'reload_postfix' => (
     is              => 'rw',
     isa             => 'Bool',
     traits          => [ 'NoGetopt' ],
     lazy            => 1,
-    builder         => '_build_restart_postfix',
-    documentation   => 'Soll nach dem Mapping Postfix neu gestartet werden?',
+    builder         => '_build_reload_postfix',
+    documentation   => 'Soll nach dem Mapping Postfix neu geladen werden?',
 );
 
 #------
 
-sub _build_restart_postfix {
+sub _build_reload_postfix {
     return 0;
 }
 
@@ -374,7 +374,7 @@ after 'evaluate_config' => sub {
     }
 
     if ( $self->verbose >= 2 ) {
-        for my $key qw( postfix_dir work_dir postfix_binary postfix_maps restart_postfix valid_maptypes ) {
+        for my $key qw( postfix_dir work_dir postfix_binary postfix_maps reload_postfix valid_maptypes ) {
             my $tmp = $self->$key;
         }
     }
@@ -452,7 +452,7 @@ sub _initialise_maps {
                 }
                 $m->{'db_type'} = $type;
                 $m->{'exec_map'} = $self->valid_maptypes->{$type}{'exec_map'};
-                $m->{'restart_postfix'} = $self->valid_maptypes->{$type}{'restart'};
+                $m->{'reload_postfix'} = $self->valid_maptypes->{$type}{'restart'};
             }
 
             # Texttyp festlegen
@@ -605,6 +605,7 @@ sub run {
         for my $m ( @{ $self->postfix_maps } ) {
             $self->do_mapping($m);
         }
+        $self->do_reload_postfix();
     }
     else {
         $self->info( "Keine Map-Dateien zu erstellen." );
@@ -616,6 +617,44 @@ sub run {
 
 #---------------------------------
 
+=head2 do_reload_postfix( )
+
+Versucht, bei Notwendigkeit Postfix neu zu laden
+
+=cut
+
+sub do_reload_postfix {
+
+    my $self = shift;
+
+    $self->debug( sprintf( "Versuche Reload von Postfix ..." ) ) if $self->verbose >= 2;
+    return unless $self->reload_postfix;
+
+    my $cmd = $self->postfix_binary->{'postfix'};
+    my @Args = ( $cmd, "reload" );
+    my $cmdstr = join( " ", @Args );
+
+    $self->info( "Reload von Postfix" );
+    $self->debug( sprintf( "Reload von Postfix mit dem Kommando: '%s'", $cmdstr ) );
+
+    if ( $> != 0 ) {
+        $self->info( "Nur root darf Postfix reloaden." );
+        return 1;
+    }
+    
+    unless ( $$self->testmode ) {
+        unless ( system(@Args) == 0 ) {
+            $self->error( sprintf( "Fehler beim Ausführen von '%s'.", $cmdstr ) );
+            exit 11;
+        }
+    }
+
+    return 1;
+
+}
+
+#---------------------------------
+
 =head2 do_mapping( $map )
 
 Führt das eigentliche Mapping aus.
@@ -751,7 +790,7 @@ sub do_mapping {
             }
         }
 
-        $self->restart_postfix(1) if $map->{'restart_postfix'};
+        $self->reload_postfix(1) if $map->{'reload_postfix'};
 
     }