Marius Burkard
2016-07-01 49441bdd0f3ff75d5092d5b832b97ea722a66363
commit | author | age
223c56 1 <?php
MC 2
3 /*
4 Copyright (c) 2007, Till Brehm, projektfarm Gmbh
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without modification,
8 are permitted provided that the following conditions are met:
9
10     * Redistributions of source code must retain the above copyright notice,
11       this list of conditions and the following disclaimer.
12     * Redistributions in binary form must reproduce the above copyright notice,
13       this list of conditions and the following disclaimer in the documentation
14       and/or other materials provided with the distribution.
15     * Neither the name of ISPConfig nor the names of its contributors
16       may be used to endorse or promote products derived from this software without
17       specific prior written permission.
18
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26 OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 class installer_centos extends installer_dist {
32     
33     protected $clamav_socket = '/tmp/clamd.socket';
34     
35     public function configure_amavis() {
f496e9 36         global $conf, $dist;
223c56 37
MC 38         // amavisd user config file
39         $configfile = 'fedora_amavisd_conf';
40         if(!is_dir($conf["amavis"]["config_dir"])) mkdir($conf["amavis"]["config_dir"]);
41         if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf')) copy($conf["amavis"]["config_dir"].'/amavisd.conf', $conf["amavis"]["config_dir"].'/amavisd.conf~');
42         if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf~')) exec('chmod 400 '.$conf["amavis"]["config_dir"].'/amavisd.conf~');
43         $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "tpl/".$configfile.".master");
44         $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
45         $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
46         $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
47         $content = str_replace('{mysql_server_port}', $conf["mysql"]["port"], $content);
48         $content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content);
49         $content = str_replace('{hostname}', $conf['hostname'], $content);
50         $content = str_replace('/var/spool/amavisd/clamd.sock', $this->clamav_socket, $content);
51         wf($conf["amavis"]["config_dir"].'/amavisd.conf', $content);
52         chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0640);
f496e9 53         
TB 54         // for CentOS 7.2 only
55         if($dist['confid'] == 'centos72') {
56             chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0750);
57             chgrp($conf['amavis']['config_dir'].'/amavisd.conf', 'amavis');
58         }
223c56 59
MC 60
61         // Adding the amavisd commands to the postfix configuration
62         $postconf_commands = array (
63             'content_filter = amavis:[127.0.0.1]:10024',
64             'receive_override_options = no_address_mappings'
65         );
66
67         // Make a backup copy of the main.cf file
68         copy($conf["postfix"]["config_dir"].'/main.cf', $conf["postfix"]["config_dir"].'/main.cf~2');
69
70         // Executing the postconf commands
71         foreach($postconf_commands as $cmd) {
72             $command = "postconf -e '$cmd'";
73             caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
74         }
75
bd5d26 76         $config_dir = $conf['postfix']['config_dir'];
FS 77
78         // Adding amavis-services to the master.cf file if the service does not already exists
9c6782 79         $add_amavis = !$this->get_postfix_service('amavis','unix');
FS 80         $add_amavis_10025 = !$this->get_postfix_service('127.0.0.1:10025','inet');
81         $add_amavis_10027 = !$this->get_postfix_service('127.0.0.1:10027','inet');
bd5d26 82
FS 83         if ($add_amavis || $add_amavis_10025 || $add_amavis_10027) {
84             //* backup master.cf
85             if(is_file($config_dir.'/master.cf')) copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
86             // adjust amavis-config
87             if($add_amavis) {
88                 $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master');
89                 af($config_dir.'/master.cf', $content);
90                 unset($content);
91             }
92             if ($add_amavis_10025) {
93                 $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master');
94                 af($config_dir.'/master.cf', $content);
95                 unset($content);
96             }
97             if ($add_amavis_10027) {
98                 $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10027.master', 'tpl/master_cf_amavis10027.master');
99                 af($config_dir.'/master.cf', $content);
100                 unset($content);
101             }
223c56 102         }
MC 103
104         removeLine('/etc/sysconfig/freshclam', 'FRESHCLAM_DELAY=disabled-warn   # REMOVE ME', 1);
105         replaceLine('/etc/freshclam.conf', 'Example', '# Example', 1);
106
107
108     }
109
110
111 }
112
113 ?>