1+ <?php
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 extends installer_dist {
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 ' ,'/var/run/clamav/clamd.sock ' ,$ 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+
83+
84+ }
85+
86+ ?>
0 commit comments