commit | author | age
|
663619
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
436ed8
|
4 |
Copyright (c) 2007, Till Brehm, projektfarm Gmbh |
663619
|
5 |
All rights reserved. |
T |
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 extends installer_dist { |
|
32 |
|
526b99
|
33 |
public function configure_mailman($status = 'insert') { |
T |
34 |
global $conf; |
|
35 |
|
|
36 |
$config_dir = $conf['mailman']['config_dir'].'/'; |
|
37 |
$full_file_name = $config_dir.'mm_cfg.py'; |
|
38 |
//* Backup exiting file |
|
39 |
if(is_file($full_file_name)) { |
|
40 |
copy($full_file_name, $config_dir.'mm_cfg.py~'); |
|
41 |
} |
|
42 |
|
|
43 |
// load files |
615a0a
|
44 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/mm_cfg.py.master', 'tpl/mm_cfg.py.master'); |
526b99
|
45 |
$old_file = rf($full_file_name); |
T |
46 |
|
|
47 |
$old_options = array(); |
|
48 |
$lines = explode("\n", $old_file); |
|
49 |
foreach ($lines as $line) |
|
50 |
{ |
|
51 |
if (trim($line) != '' && substr($line, 0, 1) != '#') |
|
52 |
{ |
|
53 |
@list($key, $value) = @explode("=", $line); |
|
54 |
if (!empty($value)) |
|
55 |
{ |
|
56 |
$key = rtrim($key); |
|
57 |
$old_options[$key] = trim($value); |
|
58 |
} |
|
59 |
} |
|
60 |
} |
7fe908
|
61 |
|
526b99
|
62 |
$config_dir = $conf['mailman']['config_dir'].'/'; |
T |
63 |
$full_file_name = $config_dir.'virtual_to_transport.sh'; |
7fe908
|
64 |
|
526b99
|
65 |
//* Backup exiting virtual_to_transport.sh script |
T |
66 |
if(is_file($full_file_name)) { |
|
67 |
copy($full_file_name, $config_dir.'virtual_to_transport.sh~'); |
|
68 |
} |
7fe908
|
69 |
|
MC |
70 |
if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh')) { |
|
71 |
copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/mailman-virtual_to_transport.sh', $full_file_name); |
|
72 |
} else { |
|
73 |
copy('tpl/mailman-virtual_to_transport.sh', $full_file_name); |
|
74 |
} |
|
75 |
chgrp($full_file_name, 'mailman'); |
|
76 |
chmod($full_file_name, 0750); |
|
77 |
|
526b99
|
78 |
if(!is_file('/var/lib/mailman/data/transport-mailman')) touch('/var/lib/mailman/data/transport-mailman'); |
T |
79 |
exec('/usr/sbin/postmap /var/lib/mailman/data/transport-mailman'); |
7fe908
|
80 |
|
526b99
|
81 |
exec('/usr/lib/mailman/bin/genaliases 2>/dev/null'); |
T |
82 |
|
|
83 |
$virtual_domains = ''; |
|
84 |
if($status == 'update') |
|
85 |
{ |
|
86 |
// create virtual_domains list |
|
87 |
$domainAll = $this->db->queryAllRecords("SELECT domain FROM mail_mailinglist GROUP BY domain"); |
|
88 |
|
|
89 |
if(is_array($domainAll)) { |
7fe908
|
90 |
foreach($domainAll as $domain) |
MC |
91 |
{ |
|
92 |
if ($domainAll[0]['domain'] == $domain['domain']) |
|
93 |
$virtual_domains .= "'".$domain['domain']."'"; |
|
94 |
else |
|
95 |
$virtual_domains .= ", '".$domain['domain']."'"; |
|
96 |
} |
526b99
|
97 |
} |
T |
98 |
} |
|
99 |
else |
|
100 |
$virtual_domains = "' '"; |
|
101 |
|
|
102 |
$content = str_replace('{hostname}', $conf['hostname'], $content); |
|
103 |
if(!isset($old_options['DEFAULT_SERVER_LANGUAGE'])) $old_options['DEFAULT_SERVER_LANGUAGE'] = ''; |
|
104 |
$content = str_replace('{default_language}', $old_options['DEFAULT_SERVER_LANGUAGE'], $content); |
|
105 |
$content = str_replace('{virtual_domains}', $virtual_domains, $content); |
|
106 |
|
|
107 |
wf($full_file_name, $content); |
|
108 |
} |
|
109 |
|
f28f40
|
110 |
public function configure_amavis() { |
T |
111 |
global $conf; |
7fe908
|
112 |
|
f28f40
|
113 |
// amavisd user config file |
T |
114 |
$configfile = 'fedora_amavisd_conf'; |
7fe908
|
115 |
if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf')) copy($conf["amavis"]["config_dir"].'/amavisd.conf', $conf["amavis"]["config_dir"].'/amavisd.conf~'); |
f28f40
|
116 |
if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf~')) exec('chmod 400 '.$conf["amavis"]["config_dir"].'/amavisd.conf~'); |
615a0a
|
117 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "tpl/".$configfile.".master"); |
7fe908
|
118 |
$content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content); |
MC |
119 |
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content); |
|
120 |
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content); |
|
121 |
$content = str_replace('{mysql_server_port}', $conf["mysql"]["port"], $content); |
|
122 |
$content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content); |
|
123 |
$content = str_replace('{hostname}', $conf['hostname'], $content); |
|
124 |
$content = str_replace('/var/spool/amavisd/clamd.sock', '/tmp/clamd.socket', $content); |
|
125 |
wf($conf["amavis"]["config_dir"].'/amavisd.conf', $content); |
553854
|
126 |
chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0640); |
7fe908
|
127 |
|
MC |
128 |
|
f28f40
|
129 |
// Adding the amavisd commands to the postfix configuration |
T |
130 |
$postconf_commands = array ( |
|
131 |
'content_filter = amavis:[127.0.0.1]:10024', |
|
132 |
'receive_override_options = no_address_mappings' |
|
133 |
); |
7fe908
|
134 |
|
f28f40
|
135 |
// Make a backup copy of the main.cf file |
7fe908
|
136 |
copy($conf["postfix"]["config_dir"].'/main.cf', $conf["postfix"]["config_dir"].'/main.cf~2'); |
MC |
137 |
|
f28f40
|
138 |
// Executing the postconf commands |
T |
139 |
foreach($postconf_commands as $cmd) { |
|
140 |
$command = "postconf -e '$cmd'"; |
|
141 |
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
142 |
} |
7fe908
|
143 |
|
f28f40
|
144 |
// Append the configuration for amavisd to the master.cf file |
7fe908
|
145 |
if(is_file($conf["postfix"]["config_dir"].'/master.cf')) copy($conf["postfix"]["config_dir"].'/master.cf', $conf["postfix"]["config_dir"].'/master.cf~'); |
f28f40
|
146 |
$content = rf($conf["postfix"]["config_dir"].'/master.cf'); |
T |
147 |
// Only add the content if we had not addded it before |
7fe908
|
148 |
if(!stristr($content, "127.0.0.1:10025")) { |
f28f40
|
149 |
unset($content); |
615a0a
|
150 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', "tpl/master_cf_amavis.master"); |
7fe908
|
151 |
af($conf["postfix"]["config_dir"].'/master.cf', $content); |
f28f40
|
152 |
} |
T |
153 |
unset($content); |
7fe908
|
154 |
|
MC |
155 |
removeLine('/etc/sysconfig/freshclam', 'FRESHCLAM_DELAY=disabled-warn # REMOVE ME', 1); |
|
156 |
replaceLine('/etc/freshclam.conf', 'Example', '# Example', 1); |
|
157 |
|
|
158 |
|
f28f40
|
159 |
} |
T |
160 |
|
663619
|
161 |
|
T |
162 |
} |
|
163 |
|
7fe908
|
164 |
?> |