Skip to content

Commit 223c561

Browse files
author
Marius Cramer
committed
- merged some functions and removed duplicate code
1 parent 86e6990 commit 223c561

File tree

7 files changed

+140
-632
lines changed

7 files changed

+140
-632
lines changed

install/dist/lib/centos52.lib.php

Lines changed: 4 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -28,150 +28,13 @@
2828
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31-
class installer extends installer_dist {
31+
require_once realpath(dirname(__FILE__)) . '/centos_base.lib.php';
3232

33-
public function configure_mailman($status = 'insert') {
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
44-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/mm_cfg.py.master', 'tpl/mm_cfg.py.master');
45-
$old_file = rf($full_file_name);
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 (isset($value) && $value !== '')
55-
{
56-
$key = rtrim($key);
57-
$old_options[$key] = trim($value);
58-
}
59-
}
60-
}
61-
62-
$config_dir = $conf['mailman']['config_dir'].'/';
63-
$full_file_name = $config_dir.'virtual_to_transport.sh';
64-
65-
//* Backup exiting virtual_to_transport.sh script
66-
if(is_file($full_file_name)) {
67-
copy($full_file_name, $config_dir.'virtual_to_transport.sh~');
68-
}
69-
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-
78-
if(!is_file('/var/lib/mailman/data/transport-mailman')) touch('/var/lib/mailman/data/transport-mailman');
79-
exec('/usr/sbin/postmap /var/lib/mailman/data/transport-mailman');
80-
81-
exec('/usr/lib/mailman/bin/genaliases 2>/dev/null');
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)) {
90-
foreach($domainAll as $domain)
91-
{
92-
if ($domainAll[0]['domain'] == $domain['domain'])
93-
$virtual_domains .= "'".$domain['domain']."'";
94-
else
95-
$virtual_domains .= ", '".$domain['domain']."'";
96-
}
97-
}
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-
110-
public function configure_amavis() {
111-
global $conf;
112-
113-
// amavisd user config file
114-
$configfile = 'fedora_amavisd_conf';
115-
if(!is_dir($conf["amavis"]["config_dir"])) mkdir($conf["amavis"]["config_dir"]);
116-
if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf')) copy($conf["amavis"]["config_dir"].'/amavisd.conf', $conf["amavis"]["config_dir"].'/amavisd.conf~');
117-
if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf~')) exec('chmod 400 '.$conf["amavis"]["config_dir"].'/amavisd.conf~');
118-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "tpl/".$configfile.".master");
119-
$content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
120-
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
121-
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
122-
$content = str_replace('{mysql_server_port}', $conf["mysql"]["port"], $content);
123-
$content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content);
124-
$content = str_replace('{hostname}', $conf['hostname'], $content);
125-
$content = str_replace('/var/spool/amavisd/clamd.sock', '/tmp/clamd.socket', $content);
126-
wf($conf["amavis"]["config_dir"].'/amavisd.conf', $content);
127-
chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0640);
128-
129-
130-
// Adding the amavisd commands to the postfix configuration
131-
$postconf_commands = array (
132-
'content_filter = amavis:[127.0.0.1]:10024',
133-
'receive_override_options = no_address_mappings'
134-
);
135-
136-
// Make a backup copy of the main.cf file
137-
copy($conf["postfix"]["config_dir"].'/main.cf', $conf["postfix"]["config_dir"].'/main.cf~2');
138-
139-
// Executing the postconf commands
140-
foreach($postconf_commands as $cmd) {
141-
$command = "postconf -e '$cmd'";
142-
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
143-
}
144-
145-
// Append the configuration for amavisd to the master.cf file
146-
if(is_file($conf['postfix']['config_dir'].'/master.cf')) copy($conf['postfix']['config_dir'].'/master.cf', $conf['postfix']['config_dir'].'/master.cf~');
147-
$content = rf($conf['postfix']['config_dir'].'/master.cf');
148-
// Only add the content if we had not addded it before
149-
if(!preg_match('/^amavis\s+unix\s+/m', $content)) {
150-
unset($content);
151-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master');
152-
af($conf['postfix']['config_dir'].'/master.cf', $content);
153-
$content = rf($conf['postfix']['config_dir'].'/master.cf');
154-
}
155-
if(!preg_match('/^127.0.0.1:10025\s+/m', $content)) {
156-
unset($content);
157-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master');
158-
af($conf['postfix']['config_dir'].'/master.cf', $content);
159-
$content = rf($conf['postfix']['config_dir'].'/master.cf');
160-
}
161-
if(!preg_match('/^127.0.0.1:10027\s+/m', $content)) {
162-
unset($content);
163-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10027.master', 'tpl/master_cf_amavis10027.master');
164-
af($conf['postfix']['config_dir'].'/master.cf', $content);
165-
}
166-
unset($content);
167-
168-
removeLine('/etc/sysconfig/freshclam', 'FRESHCLAM_DELAY=disabled-warn # REMOVE ME', 1);
169-
replaceLine('/etc/freshclam.conf', 'Example', '# Example', 1);
170-
171-
172-
}
33+
class installer extends installer_centos {
17334

35+
protected $clamav_socket = '/tmp/clamd.socket';
17436

37+
// everything else is inherited from installer_centos class
17538
}
17639

17740
?>

install/dist/lib/centos53.lib.php

Lines changed: 4 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -28,150 +28,13 @@
2828
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2929
*/
3030

31-
class installer extends installer_dist {
31+
require_once realpath(dirname(__FILE__)) . '/centos_base.lib.php';
3232

33-
public function configure_mailman($status = 'insert') {
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
44-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/mm_cfg.py.master', 'tpl/mm_cfg.py.master');
45-
$old_file = rf($full_file_name);
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 (isset($value) && $value !== '')
55-
{
56-
$key = rtrim($key);
57-
$old_options[$key] = trim($value);
58-
}
59-
}
60-
}
61-
62-
$config_dir = $conf['mailman']['config_dir'].'/';
63-
$full_file_name = $config_dir.'virtual_to_transport.sh';
64-
65-
//* Backup exiting virtual_to_transport.sh script
66-
if(is_file($full_file_name)) {
67-
copy($full_file_name, $config_dir.'virtual_to_transport.sh~');
68-
}
69-
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-
78-
if(!is_file('/var/lib/mailman/data/transport-mailman')) touch('/var/lib/mailman/data/transport-mailman');
79-
exec('/usr/sbin/postmap /var/lib/mailman/data/transport-mailman');
80-
81-
exec('/usr/lib/mailman/bin/genaliases 2>/dev/null');
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)) {
90-
foreach($domainAll as $domain)
91-
{
92-
if ($domainAll[0]['domain'] == $domain['domain'])
93-
$virtual_domains .= "'".$domain['domain']."'";
94-
else
95-
$virtual_domains .= ", '".$domain['domain']."'";
96-
}
97-
}
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-
110-
public function configure_amavis() {
111-
global $conf;
112-
113-
// amavisd user config file
114-
$configfile = 'fedora_amavisd_conf';
115-
if(!is_dir($conf["amavis"]["config_dir"])) mkdir($conf["amavis"]["config_dir"]);
116-
if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf')) copy($conf["amavis"]["config_dir"].'/amavisd.conf', $conf["amavis"]["config_dir"].'/amavisd.conf~');
117-
if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf~')) exec('chmod 400 '.$conf["amavis"]["config_dir"].'/amavisd.conf~');
118-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "tpl/".$configfile.".master");
119-
$content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
120-
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
121-
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
122-
$content = str_replace('{mysql_server_port}', $conf["mysql"]["port"], $content);
123-
$content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content);
124-
$content = str_replace('{hostname}', $conf['hostname'], $content);
125-
$content = str_replace('/var/spool/amavisd/clamd.sock', '/var/run/clamav/clamd.sock', $content);
126-
wf($conf["amavis"]["config_dir"].'/amavisd.conf', $content);
127-
chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0640);
128-
129-
130-
// Adding the amavisd commands to the postfix configuration
131-
$postconf_commands = array (
132-
'content_filter = amavis:[127.0.0.1]:10024',
133-
'receive_override_options = no_address_mappings'
134-
);
135-
136-
// Make a backup copy of the main.cf file
137-
copy($conf["postfix"]["config_dir"].'/main.cf', $conf["postfix"]["config_dir"].'/main.cf~2');
138-
139-
// Executing the postconf commands
140-
foreach($postconf_commands as $cmd) {
141-
$command = "postconf -e '$cmd'";
142-
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
143-
}
144-
145-
// Append the configuration for amavisd to the master.cf file
146-
if(is_file($conf['postfix']['config_dir'].'/master.cf')) copy($conf['postfix']['config_dir'].'/master.cf', $conf['postfix']['config_dir'].'/master.cf~');
147-
$content = rf($conf['postfix']['config_dir'].'/master.cf');
148-
// Only add the content if we had not addded it before
149-
if(!preg_match('/^amavis\s+unix\s+/m', $content)) {
150-
unset($content);
151-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master');
152-
af($conf['postfix']['config_dir'].'/master.cf', $content);
153-
$content = rf($conf['postfix']['config_dir'].'/master.cf');
154-
}
155-
if(!preg_match('/^127.0.0.1:10025\s+/m', $content)) {
156-
unset($content);
157-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master');
158-
af($conf['postfix']['config_dir'].'/master.cf', $content);
159-
$content = rf($conf['postfix']['config_dir'].'/master.cf');
160-
}
161-
if(!preg_match('/^127.0.0.1:10027\s+/m', $content)) {
162-
unset($content);
163-
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10027.master', 'tpl/master_cf_amavis10027.master');
164-
af($conf['postfix']['config_dir'].'/master.cf', $content);
165-
}
166-
unset($content);
167-
168-
removeLine('/etc/sysconfig/freshclam', 'FRESHCLAM_DELAY=disabled-warn # REMOVE ME', 1);
169-
replaceLine('/etc/freshclam.conf', 'Example', '# Example', 1);
170-
171-
172-
}
33+
class installer extends installer_centos {
17334

35+
protected $clamav_socket = '/var/run/clamav/clamd.sock';
17436

37+
// everything else is inherited from installer_centos class
17538
}
17639

17740
?>

0 commit comments

Comments
 (0)