|
30 | 30 |
|
31 | 31 | class installer extends installer_dist { |
32 | 32 |
|
| 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 | + |
33 | 83 |
|
34 | 84 | } |
35 | 85 |
|
|
0 commit comments