Marius Burkard
2016-04-20 4569cae57f127afd093794310ccd290d2d9fdf36
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() {
36         global $conf;
37
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);
53
54
55         // Adding the amavisd commands to the postfix configuration
56         $postconf_commands = array (
57             'content_filter = amavis:[127.0.0.1]:10024',
58             'receive_override_options = no_address_mappings'
59         );
60
61         // Make a backup copy of the main.cf file
62         copy($conf["postfix"]["config_dir"].'/main.cf', $conf["postfix"]["config_dir"].'/main.cf~2');
63
64         // Executing the postconf commands
65         foreach($postconf_commands as $cmd) {
66             $command = "postconf -e '$cmd'";
67             caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
68         }
69
bd5d26 70         $config_dir = $conf['postfix']['config_dir'];
FS 71
72         // Adding amavis-services to the master.cf file if the service does not already exists
9c6782 73         $add_amavis = !$this->get_postfix_service('amavis','unix');
FS 74         $add_amavis_10025 = !$this->get_postfix_service('127.0.0.1:10025','inet');
75         $add_amavis_10027 = !$this->get_postfix_service('127.0.0.1:10027','inet');
bd5d26 76
FS 77         if ($add_amavis || $add_amavis_10025 || $add_amavis_10027) {
78             //* backup master.cf
79             if(is_file($config_dir.'/master.cf')) copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
80             // adjust amavis-config
81             if($add_amavis) {
82                 $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master');
83                 af($config_dir.'/master.cf', $content);
84                 unset($content);
85             }
86             if ($add_amavis_10025) {
87                 $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master');
88                 af($config_dir.'/master.cf', $content);
89                 unset($content);
90             }
91             if ($add_amavis_10027) {
92                 $content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10027.master', 'tpl/master_cf_amavis10027.master');
93                 af($config_dir.'/master.cf', $content);
94                 unset($content);
95             }
223c56 96         }
MC 97
98         removeLine('/etc/sysconfig/freshclam', 'FRESHCLAM_DELAY=disabled-warn   # REMOVE ME', 1);
99         replaceLine('/etc/freshclam.conf', 'Example', '# Example', 1);
100
101
102     }
103
104
105 }
106
107 ?>