Skip to content

Commit f28f40f

Browse files
committed
Fixed amavisd socket path.
1 parent b9fcb36 commit f28f40f

File tree

2 files changed

+52
-2
lines changed

2 files changed

+52
-2
lines changed

install/dist/lib/centos52.lib.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,56 @@
3030

3131
class installer extends installer_dist {
3232

33+
public function configure_amavis() {
34+
global $conf;
35+
36+
// amavisd user config file
37+
$configfile = 'fedora_amavisd_conf';
38+
if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf')) copy($conf["amavis"]["config_dir"].'/amavisd.conf',$conf["courier"]["config_dir"].'/amavisd.conf~');
39+
if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf~')) exec('chmod 400 '.$conf["amavis"]["config_dir"].'/amavisd.conf~');
40+
$content = rf("tpl/".$configfile.".master");
41+
$content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
42+
$content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
43+
$content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
44+
$content = str_replace('{mysql_server_port}',$conf["mysql"]["port"],$content);
45+
$content = str_replace('{mysql_server_ip}',$conf['mysql']['ip'],$content);
46+
$content = str_replace('{hostname}',$conf['hostname'],$content);
47+
$content = str_replace('/var/spool/amavisd/clamd.sock','/tmp/clamd.socket',$content);
48+
wf($conf["amavis"]["config_dir"].'/amavisd.conf',$content);
49+
50+
51+
// Adding the amavisd commands to the postfix configuration
52+
$postconf_commands = array (
53+
'content_filter = amavis:[127.0.0.1]:10024',
54+
'receive_override_options = no_address_mappings'
55+
);
56+
57+
// Make a backup copy of the main.cf file
58+
copy($conf["postfix"]["config_dir"].'/main.cf',$conf["postfix"]["config_dir"].'/main.cf~2');
59+
60+
// Executing the postconf commands
61+
foreach($postconf_commands as $cmd) {
62+
$command = "postconf -e '$cmd'";
63+
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
64+
}
65+
66+
// Append the configuration for amavisd to the master.cf file
67+
if(is_file($conf["postfix"]["config_dir"].'/master.cf')) copy($conf["postfix"]["config_dir"].'/master.cf',$conf["postfix"]["config_dir"].'/master.cf~');
68+
$content = rf($conf["postfix"]["config_dir"].'/master.cf');
69+
// Only add the content if we had not addded it before
70+
if(!stristr($content,"127.0.0.1:10025")) {
71+
unset($content);
72+
$content = rf("tpl/master_cf_amavis.master");
73+
af($conf["postfix"]["config_dir"].'/master.cf',$content);
74+
}
75+
unset($content);
76+
77+
removeLine('/etc/sysconfig/freshclam','FRESHCLAM_DELAY=disabled-warn # REMOVE ME',1);
78+
replaceLine('/etc/freshclam.conf','Example','# Example',1);
79+
80+
81+
}
82+
3383

3484
}
3585

install/lib/install.lib.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ function is_group($group){
508508
return false;
509509
}
510510

511-
function replaceLine($filename,$search_pattern,$new_line,$strict = 0) {
511+
function replaceLine($filename,$search_pattern,$new_line,$strict = 0,$append = 1) {
512512
if($lines = @file($filename)) {
513513
$out = '';
514514
$found = 0;
@@ -533,7 +533,7 @@ function replaceLine($filename,$search_pattern,$new_line,$strict = 0) {
533533
//* add \n if the last line does not end with \n or \r
534534
if(substr($out,-1) != "\n" && substr($out,-1) != "\r") $out .= "\n";
535535
//* add the new line at the end of the file
536-
$out .= $new_line."\n";
536+
if($append == 1) $out .= $new_line."\n";
537537
}
538538
file_put_contents($filename,$out);
539539
}

0 commit comments

Comments
 (0)