Advertisement
Guest User

Untitled

a guest
Apr 18th, 2017
595
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.45 KB | None | 0 0
  1. # i-MSCP Listener::Postfix::Tuning listener file
  2. # Copyright (C) 2015-2017 Laurent Declercq <l.declercq@nuxwin.com>
  3. #
  4. # This library is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU Lesser General Public
  6. # License as published by the Free Software Foundation; either
  7. # version 2.1 of the License, or (at your option) any later version.
  8. #
  9. # This library is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. # Lesser General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU Lesser General Public
  15. # License along with this library; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
  17.  
  18. #
  19. ## Tune up Postfix configuration files (main.cf and master.cf).
  20. #
  21.  
  22. package Listener::Postfix::Tuning;
  23.  
  24. use strict;
  25. use warnings;
  26. use iMSCP::Debug;
  27. use iMSCP::EventManager;
  28. use Servers::mta;
  29.  
  30. #
  31. ## Configuration variables
  32. #
  33.  
  34. ## Postfix main.cf (see http://www.postfix.org/postconf.5.html)
  35. # Hash where each pair of key/value correspond to a postfix parameter
  36. # Please replace the entries below by your own entries
  37. my %mainCfParameters = (
  38.     'inet_protocols'     => 'ipv4, ipv6',
  39.     'smtp_bind_address6' => '2001:240:587:0:250:56ff:fe89:1'
  40. );
  41.  
  42. ## Postfix master.cf (see http://www.postfix.org/master.5.html)
  43. # Array where each entry correspond to a postfix service. Entries are added at bottom.
  44. # Please replace the entries below by your own entries
  45. my @masterCfParameters = ();
  46.  
  47. #
  48. ## Please, don't edit anything below this line unless you known what you're doing
  49. #
  50.  
  51. my $em = iMSCP::EventManager->getInstance();
  52. $em->register(
  53.     'afterMtaBuildConf',
  54.     sub {
  55.         my %params = ();
  56.         while(my ($param, $value) = each( %mainCfParameters )) {
  57.             $params{$param} = {
  58.                 'action' => 'replace',
  59.                 'values' => [ split /,\s+/, $value ]
  60.             };
  61.         }
  62.  
  63.         if (%params) {
  64.             my $rs = Servers::mta->factory()->postconf( %params );
  65.             return $rs if $rs;
  66.         }
  67.  
  68.         0;
  69.     }
  70. );
  71. $em->register(
  72.     'afterMtaBuildMasterCfFile',
  73.     sub {
  74.         my $cfgTpl = shift;
  75.  
  76.         return 0 unless @masterCfParameters;
  77.  
  78.         $$cfgTpl .= join( "\n", @masterCfParameters )."\n";
  79.         0;
  80.     }
  81. );
  82.  
  83. 1;
  84. __END__
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement