commit | author | age
|
0711af
|
1 |
<?php |
T |
2 |
|
|
3 |
/* |
436ed8
|
4 |
Copyright (c) 2007, Till Brehm, projektfarm Gmbh |
0711af
|
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 |
|
344393
|
31 |
class installer_dist extends installer_base { |
223c56
|
32 |
protected $mailman_group = 'mailman'; |
MC |
33 |
|
|
34 |
public function __construct() { |
|
35 |
//** check apache modules */ |
|
36 |
$mods = getapachemodules(); |
|
37 |
if(in_array('authz_compat', $mods, true)) { |
|
38 |
swriteln($inst->lng(' WARNING! You are using mod_authz_compat.')); |
|
39 |
swriteln($inst->lng(' Please make sure that your apache config uses the new auth syntax:')); |
|
40 |
swriteln($inst->lng(' <Directory />')); |
|
41 |
swriteln($inst->lng(' Options None')); |
|
42 |
swriteln($inst->lng(' AllowOverride None')); |
|
43 |
swriteln($inst->lng(' Require all denied')); |
|
44 |
swriteln($inst->lng(' </Directory>'."\n")); |
|
45 |
|
|
46 |
swriteln($inst->lng(' If it uses the old syntax (deny from all) ISPConfig would fail to work.')); |
526b99
|
47 |
} |
T |
48 |
} |
b1a6a5
|
49 |
|
0711af
|
50 |
function configure_postfix($options = '') |
b1a6a5
|
51 |
{ |
b51c22
|
52 |
global $conf,$autoinstall; |
0711af
|
53 |
$cf = $conf['postfix']; |
T |
54 |
$config_dir = $cf['config_dir']; |
b1a6a5
|
55 |
|
0711af
|
56 |
if(!is_dir($config_dir)){ |
b1a6a5
|
57 |
$this->error("The postfix configuration directory '$config_dir' does not exist."); |
MC |
58 |
} |
|
59 |
|
0711af
|
60 |
//* mysql-virtual_domains.cf |
b1a6a5
|
61 |
$this->process_postfix_config('mysql-virtual_domains.cf'); |
0711af
|
62 |
|
T |
63 |
//* mysql-virtual_forwardings.cf |
b1a6a5
|
64 |
$this->process_postfix_config('mysql-virtual_forwardings.cf'); |
0711af
|
65 |
|
T |
66 |
//* mysql-virtual_mailboxes.cf |
b1a6a5
|
67 |
$this->process_postfix_config('mysql-virtual_mailboxes.cf'); |
0711af
|
68 |
|
T |
69 |
//* mysql-virtual_email2email.cf |
b1a6a5
|
70 |
$this->process_postfix_config('mysql-virtual_email2email.cf'); |
0711af
|
71 |
|
T |
72 |
//* mysql-virtual_transports.cf |
b1a6a5
|
73 |
$this->process_postfix_config('mysql-virtual_transports.cf'); |
0711af
|
74 |
|
T |
75 |
//* mysql-virtual_recipient.cf |
b1a6a5
|
76 |
$this->process_postfix_config('mysql-virtual_recipient.cf'); |
0711af
|
77 |
|
T |
78 |
//* mysql-virtual_sender.cf |
b1a6a5
|
79 |
$this->process_postfix_config('mysql-virtual_sender.cf'); |
0711af
|
80 |
|
03b633
|
81 |
//* mysql-virtual_sender_login_maps.cf |
D |
82 |
$this->process_postfix_config('mysql-virtual_sender_login_maps.cf'); |
|
83 |
|
0711af
|
84 |
//* mysql-virtual_client.cf |
b1a6a5
|
85 |
$this->process_postfix_config('mysql-virtual_client.cf'); |
MC |
86 |
|
0711af
|
87 |
//* mysql-virtual_relaydomains.cf |
b1a6a5
|
88 |
$this->process_postfix_config('mysql-virtual_relaydomains.cf'); |
MC |
89 |
|
429dcf
|
90 |
//* mysql-virtual_relayrecipientmaps.cf |
b1a6a5
|
91 |
$this->process_postfix_config('mysql-virtual_relayrecipientmaps.cf'); |
2b3dfa
|
92 |
|
TB |
93 |
//* mysql-virtual_outgoing_bcc.cf |
|
94 |
$this->process_postfix_config('mysql-virtual_outgoing_bcc.cf'); |
0711af
|
95 |
|
75722e
|
96 |
//* mysql-virtual_policy_greylist.cf |
D |
97 |
$this->process_postfix_config('mysql-virtual_policy_greylist.cf'); |
|
98 |
|
b1a6a5
|
99 |
//* postfix-dkim |
MC |
100 |
$full_file_name=$config_dir.'/tag_as_originating.re'; |
|
101 |
if(is_file($full_file_name)) { |
|
102 |
copy($full_file_name, $config_dir.$configfile.'~'); |
|
103 |
} |
|
104 |
wf($full_file_name, '/^/ FILTER amavis:[127.0.0.1]:10026'); |
ec5716
|
105 |
|
b1a6a5
|
106 |
$full_file_name=$config_dir.'/tag_as_foreign.re'; |
MC |
107 |
if(is_file($full_file_name)) { |
|
108 |
copy($full_file_name, $config_dir.$configfile.'~'); |
|
109 |
} |
|
110 |
wf($full_file_name, '/^/ FILTER amavis:[127.0.0.1]:10024'); |
ec5716
|
111 |
|
0711af
|
112 |
//* Changing mode and group of the new created config files. |
T |
113 |
caselog('chmod o= '.$config_dir.'/mysql-virtual_*.cf* &> /dev/null', |
b1a6a5
|
114 |
__FILE__, __LINE__, 'chmod on mysql-virtual_*.cf*', 'chmod on mysql-virtual_*.cf* failed'); |
MC |
115 |
caselog('chgrp '.$cf['group'].' '.$config_dir.'/mysql-virtual_*.cf* &> /dev/null', |
|
116 |
__FILE__, __LINE__, 'chgrp on mysql-virtual_*.cf*', 'chgrp on mysql-virtual_*.cf* failed'); |
|
117 |
|
0711af
|
118 |
//* Creating virtual mail user and group |
T |
119 |
$command = 'groupadd -g '.$cf['vmail_groupid'].' '.$cf['vmail_groupname']; |
392450
|
120 |
if(!is_group($cf['vmail_groupname'])) caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
0711af
|
121 |
|
T |
122 |
$command = 'useradd -g '.$cf['vmail_groupname'].' -u '.$cf['vmail_userid'].' '.$cf['vmail_username'].' -d '.$cf['vmail_mailbox_base'].' -m'; |
7b47c0
|
123 |
if(!is_user($cf['vmail_username'])) caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
T |
124 |
|
|
125 |
//* These postconf commands will be executed on installation and update |
2af58c
|
126 |
$server_ini_rec = $this->db->queryOneRecord("SELECT config FROM server WHERE server_id = ?", $conf['server_id']); |
7b47c0
|
127 |
$server_ini_array = ini_to_array(stripslashes($server_ini_rec['config'])); |
T |
128 |
unset($server_ini_rec); |
|
129 |
|
|
130 |
//* If there are RBL's defined, format the list and add them to smtp_recipient_restrictions to prevent removeal after an update |
|
131 |
$rbl_list = ''; |
|
132 |
if (@isset($server_ini_array['mail']['realtime_blackhole_list']) && $server_ini_array['mail']['realtime_blackhole_list'] != '') { |
b1a6a5
|
133 |
$rbl_hosts = explode(",", str_replace(" ", "", $server_ini_array['mail']['realtime_blackhole_list'])); |
7b47c0
|
134 |
foreach ($rbl_hosts as $key => $value) { |
T |
135 |
$rbl_list .= ", reject_rbl_client ". $value; |
|
136 |
} |
|
137 |
} |
|
138 |
unset($rbl_hosts); |
75722e
|
139 |
|
D |
140 |
//* If Postgrey is installed, configure it |
|
141 |
$greylisting = ''; |
|
142 |
if($conf['postgrey']['installed'] == true) { |
20f478
|
143 |
$greylisting = ', check_recipient_access mysql:/etc/postfix/mysql-virtual_policy_greylist.cf'; |
75722e
|
144 |
} |
D |
145 |
|
20f478
|
146 |
$reject_sender_login_mismatch = ''; |
D |
147 |
if(isset($server_ini_array['mail']['reject_sender_login_mismatch']) && ($server_ini_array['mail']['reject_sender_login_mismatch'] == 'y')) { |
|
148 |
$reject_sender_login_mismatch = ', reject_authenticated_sender_login_mismatch'; |
|
149 |
} |
|
150 |
unset($server_ini_array); |
|
151 |
|
b1a6a5
|
152 |
$postconf_placeholders = array('{config_dir}' => $config_dir, |
MC |
153 |
'{vmail_mailbox_base}' => $cf['vmail_mailbox_base'], |
|
154 |
'{vmail_userid}' => $cf['vmail_userid'], |
|
155 |
'{vmail_groupid}' => $cf['vmail_groupid'], |
75722e
|
156 |
'{rbl_list}' => $rbl_list, |
D |
157 |
'{greylisting}' => $greylisting, |
20f478
|
158 |
'{reject_slm}' => $reject_sender_login_mismatch, |
75722e
|
159 |
); |
20f478
|
160 |
|
b1a6a5
|
161 |
$postconf_tpl = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_postfix.conf.master', 'tpl/fedora_postfix.conf.master'); |
MC |
162 |
$postconf_tpl = strtr($postconf_tpl, $postconf_placeholders); |
|
163 |
$postconf_commands = array_filter(explode("\n", $postconf_tpl)); // read and remove empty lines |
|
164 |
|
b67344
|
165 |
//* These postconf commands will be executed on installation only |
T |
166 |
if($this->is_update == false) { |
b1a6a5
|
167 |
$postconf_commands = array_merge($postconf_commands, array( |
MC |
168 |
'myhostname = '.$conf['hostname'], |
|
169 |
'mydestination = '.$conf['hostname'].', localhost, localhost.localdomain', |
|
170 |
'mynetworks = 127.0.0.0/8 [::1]/128' |
|
171 |
)); |
b67344
|
172 |
} |
b1a6a5
|
173 |
|
0711af
|
174 |
//* Create the header and body check files |
T |
175 |
touch($config_dir.'/header_checks'); |
|
176 |
touch($config_dir.'/mime_header_checks'); |
|
177 |
touch($config_dir.'/nested_header_checks'); |
|
178 |
touch($config_dir.'/body_checks'); |
b1a6a5
|
179 |
|
3f478f
|
180 |
//* Create the mailman files |
T |
181 |
if(!is_dir('/var/lib/mailman/data')) exec('mkdir -p /var/lib/mailman/data'); |
|
182 |
//if(!is_file('/var/lib/mailman/data/aliases')) touch('/var/lib/mailman/data/aliases'); |
|
183 |
if(is_file('/var/lib/mailman/data/aliases')) unlink('/var/lib/mailman/data/aliases'); |
b1a6a5
|
184 |
if(!is_link('/var/lib/mailman/data/aliases')) symlink('/etc/mailman/aliases', '/var/lib/mailman/data/aliases'); |
2b3dfa
|
185 |
if(!is_file('/etc/mailman/aliases')) touch('/etc/mailman/aliases'); |
3f478f
|
186 |
exec('postalias /var/lib/mailman/data/aliases'); |
79bd20
|
187 |
if(!is_file('/etc/mailman/virtual-mailman')) touch('/etc/mailman/virtual-mailman'); |
TB |
188 |
exec('postmap /etc/mailman/virtual-mailman'); |
3f478f
|
189 |
if(!is_file('/var/lib/mailman/data/transport-mailman')) touch('/var/lib/mailman/data/transport-mailman'); |
T |
190 |
exec('/usr/sbin/postmap /var/lib/mailman/data/transport-mailman'); |
b1a6a5
|
191 |
|
616ad0
|
192 |
//* Create auxillary postfix conf files |
FS |
193 |
$configfile = 'helo_access'; |
|
194 |
if(is_file($config_dir.'/'.$configfile)) { |
|
195 |
copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~'); |
|
196 |
chmod($config_dir.'/'.$configfile.'~', 0400); |
|
197 |
} |
|
198 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', 'tpl/'.$configfile.'.master'); |
|
199 |
$content = strtr($content, $postconf_placeholders); |
|
200 |
# todo: look up this server's ip addrs and loop through each |
|
201 |
# todo: look up domains hosted on this server and loop through each |
|
202 |
wf($config_dir.'/'.$configfile, $content); |
|
203 |
|
|
204 |
$configfile = 'blacklist_helo'; |
|
205 |
if(is_file($config_dir.'/'.$configfile)) { |
|
206 |
copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~'); |
|
207 |
chmod($config_dir.'/'.$configfile.'~', 0400); |
|
208 |
} |
|
209 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', 'tpl/'.$configfile.'.master'); |
|
210 |
$content = strtr($content, $postconf_placeholders); |
|
211 |
wf($config_dir.'/'.$configfile, $content); |
|
212 |
|
0711af
|
213 |
//* Make a backup copy of the main.cf file |
T |
214 |
copy($config_dir.'/main.cf', $config_dir.'/main.cf~'); |
b1a6a5
|
215 |
|
0711af
|
216 |
//* Executing the postconf commands |
T |
217 |
foreach($postconf_commands as $cmd) { |
|
218 |
$command = "postconf -e '$cmd'"; |
|
219 |
caselog($command." &> /dev/null", __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command); |
|
220 |
} |
b1a6a5
|
221 |
|
MC |
222 |
if(!stristr($options, 'dont-create-certs')) { |
0711af
|
223 |
//* Create the SSL certificate |
b04e82
|
224 |
if(AUTOINSTALL){ |
TB |
225 |
$command = 'cd '.$config_dir.'; ' |
c43c29
|
226 |
."openssl req -new -subj '/C=".escapeshellcmd($autoinstall['ssl_cert_country'])."/ST=".escapeshellcmd($autoinstall['ssl_cert_state'])."/L=".escapeshellcmd($autoinstall['ssl_cert_locality'])."/O=".escapeshellcmd($autoinstall['ssl_cert_organisation'])."/OU=".escapeshellcmd($autoinstall['ssl_cert_organisation_unit'])."/CN=".escapeshellcmd($autoinstall['ssl_cert_common_name'])."' -outform PEM -out smtpd.cert -newkey rsa:4096 -nodes -keyout smtpd.key -keyform PEM -days 3650 -x509"; |
b04e82
|
227 |
} else { |
TB |
228 |
$command = 'cd '.$config_dir.'; ' |
c43c29
|
229 |
.'openssl req -new -outform PEM -out smtpd.cert -newkey rsa:4096 -nodes -keyout smtpd.key -keyform PEM -days 3650 -x509'; |
TB |
230 |
} |
0711af
|
231 |
exec($command); |
b1a6a5
|
232 |
|
01423f
|
233 |
$command = 'chmod o= '.$config_dir.'/smtpd.key'; |
0711af
|
234 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command); |
T |
235 |
} |
b1a6a5
|
236 |
|
0711af
|
237 |
//** We have to change the permissions of the courier authdaemon directory to make it accessible for maildrop. |
T |
238 |
$command = 'chmod 755 /var/spool/authdaemon'; |
|
239 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command); |
b1a6a5
|
240 |
|
0711af
|
241 |
//* Changing maildrop lines in posfix master.cf |
T |
242 |
if(is_file($config_dir.'/master.cf')){ |
b1a6a5
|
243 |
copy($config_dir.'/master.cf', $config_dir.'/master.cf~'); |
MC |
244 |
} |
0711af
|
245 |
if(is_file($config_dir.'/master.cf~')){ |
b1a6a5
|
246 |
exec('chmod 400 '.$config_dir.'/master.cf~'); |
MC |
247 |
} |
0711af
|
248 |
$configfile = $config_dir.'/master.cf'; |
T |
249 |
$content = rf($configfile); |
2c8f94
|
250 |
// if postfix package is from fedora or centios main repo |
b1a6a5
|
251 |
$content = str_replace('# flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}', |
MC |
252 |
' flags=DRhu user='.$cf['vmail_username'].' argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}', |
|
253 |
$content); |
|
254 |
|
2c8f94
|
255 |
// If postfix package is from centos plus repo |
b1a6a5
|
256 |
$content = str_replace('# flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}', |
MC |
257 |
' flags=DRhu user='.$cf['vmail_username'].' argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}', |
|
258 |
$content); |
|
259 |
|
|
260 |
$content = str_replace(' flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}', |
|
261 |
' flags=DRhu user='.$cf['vmail_username'].' argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}', |
|
262 |
$content); |
|
263 |
|
|
264 |
|
|
265 |
$content = str_replace('#maildrop unix - n n - - pipe', |
|
266 |
'maildrop unix - n n - - pipe', |
|
267 |
$content); |
|
268 |
|
0711af
|
269 |
wf($configfile, $content); |
b1a6a5
|
270 |
|
0711af
|
271 |
//* Writing the Maildrop mailfilter file |
T |
272 |
$configfile = 'mailfilter'; |
|
273 |
if(is_file($cf['vmail_mailbox_base'].'/.'.$configfile)){ |
b1a6a5
|
274 |
copy($cf['vmail_mailbox_base'].'/.'.$configfile, $cf['vmail_mailbox_base'].'/.'.$configfile.'~'); |
MC |
275 |
} |
615a0a
|
276 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "tpl/$configfile.master"); |
0711af
|
277 |
$content = str_replace('{dist_postfix_vmail_mailbox_base}', $cf['vmail_mailbox_base'], $content); |
T |
278 |
wf($cf['vmail_mailbox_base'].'/.'.$configfile, $content); |
b1a6a5
|
279 |
|
0711af
|
280 |
//* Create the directory for the custom mailfilters |
T |
281 |
$command = 'mkdir '.$cf['vmail_mailbox_base'].'/mailfilters'; |
|
282 |
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
b1a6a5
|
283 |
|
0711af
|
284 |
//* Chmod and chown the .mailfilter file |
T |
285 |
$command = 'chown -R '.$cf['vmail_username'].':'.$cf['vmail_groupname'].' '.$cf['vmail_mailbox_base'].'/.mailfilter'; |
|
286 |
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
b1a6a5
|
287 |
|
0711af
|
288 |
$command = 'chmod -R 600 '.$cf['vmail_mailbox_base'].'/.mailfilter'; |
T |
289 |
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
b1a6a5
|
290 |
|
0711af
|
291 |
} |
b1a6a5
|
292 |
|
0711af
|
293 |
public function configure_saslauthd() { |
T |
294 |
global $conf; |
b1a6a5
|
295 |
|
0711af
|
296 |
$configfile = 'tpl/fedora_saslauthd_smtpd_conf.master'; |
615a0a
|
297 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_saslauthd_smtpd_conf.master', $configfile); |
b1a6a5
|
298 |
wf('/usr/lib/sasl2/smtpd.conf', $content); |
MC |
299 |
if(is_dir('/usr/lib64')) wf('/usr/lib64/sasl/smtpd.conf', $content); |
|
300 |
if(is_dir('/usr/lib64')) wf('/usr/lib64/sasl2/smtpd.conf', $content); |
|
301 |
|
0711af
|
302 |
} |
b1a6a5
|
303 |
|
0711af
|
304 |
public function configure_pam() |
b1a6a5
|
305 |
{ |
0711af
|
306 |
global $conf; |
T |
307 |
$pam = $conf['pam']; |
|
308 |
//* configure pam for SMTP authentication agains the ispconfig database |
|
309 |
$configfile = 'pamd_smtp'; |
|
310 |
if(is_file("$pam/smtp")) copy("$pam/smtp", "$pam/smtp~"); |
|
311 |
if(is_file("$pam/smtp~")) exec("chmod 400 $pam/smtp~"); |
|
312 |
|
615a0a
|
313 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "tpl/$configfile.master"); |
0711af
|
314 |
$content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content); |
T |
315 |
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content); |
|
316 |
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content); |
|
317 |
$content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content); |
|
318 |
wf("$pam/smtp", $content); |
03bff7
|
319 |
// On some OSes smtp is world readable which allows for reading database information. Removing world readable rights should have no effect. |
T |
320 |
if(is_file("$pam/smtp")) exec("chmod o= $pam/smtp"); |
0711af
|
321 |
} |
b1a6a5
|
322 |
|
0711af
|
323 |
public function configure_courier() |
b1a6a5
|
324 |
{ |
0711af
|
325 |
global $conf; |
T |
326 |
$config_dir = $conf['courier']['config_dir']; |
|
327 |
//* authmysqlrc |
|
328 |
$configfile = 'authmysqlrc'; |
|
329 |
if(is_file("$config_dir/$configfile")){ |
b1a6a5
|
330 |
copy("$config_dir/$configfile", "$config_dir/$configfile~"); |
MC |
331 |
} |
0711af
|
332 |
exec("chmod 400 $config_dir/$configfile~"); |
615a0a
|
333 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "tpl/$configfile.master"); |
b1a6a5
|
334 |
$content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content); |
MC |
335 |
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content); |
|
336 |
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content); |
|
337 |
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content); |
82e9b9
|
338 |
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content); |
0711af
|
339 |
wf("$config_dir/$configfile", $content); |
b1a6a5
|
340 |
|
0711af
|
341 |
exec("chmod 660 $config_dir/$configfile"); |
T |
342 |
exec("chown root:root $config_dir/$configfile"); |
b1a6a5
|
343 |
|
0711af
|
344 |
//* authdaemonrc |
T |
345 |
$configfile = $conf['courier']['config_dir'].'/authdaemonrc'; |
|
346 |
if(is_file($configfile)){ |
b1a6a5
|
347 |
copy($configfile, $configfile.'~'); |
MC |
348 |
} |
0711af
|
349 |
if(is_file($configfile.'~')){ |
b1a6a5
|
350 |
exec('chmod 400 '.$configfile.'~'); |
MC |
351 |
} |
0711af
|
352 |
$content = rf($configfile); |
T |
353 |
$content = str_replace('authmodulelist=', 'authmodulelist="authmysql"', $content); |
|
354 |
wf($configfile, $content); |
|
355 |
} |
b1a6a5
|
356 |
|
0f2bb1
|
357 |
public function configure_dovecot() |
b1a6a5
|
358 |
{ |
0f2bb1
|
359 |
global $conf; |
b1a6a5
|
360 |
|
a8aad2
|
361 |
$virtual_transport = 'dovecot'; |
8b23f8
|
362 |
|
FS |
363 |
$configure_lmtp = false; |
a8aad2
|
364 |
|
DM |
365 |
// check if virtual_transport must be changed |
|
366 |
if ($this->is_update) { |
2af58c
|
367 |
$tmp = $this->db->queryOneRecord("SELECT * FROM ?? WHERE server_id = ?", $conf["mysql"]["database"] . ".server", $conf['server_id']); |
a8aad2
|
368 |
$ini_array = ini_to_array(stripslashes($tmp['config'])); |
DM |
369 |
// ini_array needs not to be checked, because already done in update.php -> updateDbAndIni() |
|
370 |
|
|
371 |
if(isset($ini_array['mail']['mailbox_virtual_uidgid_maps']) && $ini_array['mail']['mailbox_virtual_uidgid_maps'] == 'y') { |
|
372 |
$virtual_transport = 'lmtp:unix:private/dovecot-lmtp'; |
8b23f8
|
373 |
$configure_lmtp = true; |
a8aad2
|
374 |
} |
DM |
375 |
} |
|
376 |
|
bd5d26
|
377 |
$config_dir = $conf['postfix']['config_dir']; |
9c6782
|
378 |
|
0f2bb1
|
379 |
//* Configure master.cf and add a line for deliver |
9c6782
|
380 |
if(!$this->get_postfix_service('dovecot', 'unix')) { |
bd5d26
|
381 |
//* backup |
FS |
382 |
if(is_file($config_dir.'/master.cf')){ |
|
383 |
copy($config_dir.'/master.cf', $config_dir.'/master.cf~2'); |
|
384 |
} |
|
385 |
if(is_file($config_dir.'/master.cf~')){ |
|
386 |
chmod($config_dir.'/master.cf~2', 0400); |
|
387 |
} |
|
388 |
//* Configure master.cf and add a line for deliver |
|
389 |
$content = rf($conf["postfix"]["config_dir"].'/master.cf'); |
9c6782
|
390 |
$deliver_content = 'dovecot unix - n n - - pipe'."\n".' flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -f ${sender} -d ${user}@${nexthop}'."\n"; |
b1a6a5
|
391 |
af($conf["postfix"]["config_dir"].'/master.cf', $deliver_content); |
bd5d26
|
392 |
unset($content); |
FS |
393 |
unset($deliver_content); |
0f2bb1
|
394 |
} |
b1a6a5
|
395 |
|
0f2bb1
|
396 |
//* Reconfigure postfix to use dovecot authentication |
T |
397 |
// Adding the amavisd commands to the postfix configuration |
|
398 |
$postconf_commands = array ( |
|
399 |
'dovecot_destination_recipient_limit = 1', |
a8aad2
|
400 |
'virtual_transport = '.$virtual_transport, |
0f2bb1
|
401 |
'smtpd_sasl_type = dovecot', |
T |
402 |
'smtpd_sasl_path = private/auth', |
|
403 |
); |
b1a6a5
|
404 |
|
0f2bb1
|
405 |
// Make a backup copy of the main.cf file |
b1a6a5
|
406 |
copy($conf["postfix"]["config_dir"].'/main.cf', $conf["postfix"]["config_dir"].'/main.cf~3'); |
MC |
407 |
|
0f2bb1
|
408 |
// Executing the postconf commands |
T |
409 |
foreach($postconf_commands as $cmd) { |
|
410 |
$command = "postconf -e '$cmd'"; |
|
411 |
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
412 |
} |
bd5d26
|
413 |
|
FS |
414 |
//* Use /etc/dovecot as config dir if exists |
|
415 |
// if(is_dir('/etc/dovecot')) $config_dir = '/etc/dovecot'; |
|
416 |
$config_dir = $conf['dovecot']['config_dir']; |
b1a6a5
|
417 |
|
31e0d1
|
418 |
//* backup dovecot.conf |
0f2bb1
|
419 |
$configfile = 'dovecot.conf'; |
T |
420 |
if(is_file("$config_dir/$configfile")){ |
b1a6a5
|
421 |
copy("$config_dir/$configfile", "$config_dir/$configfile~"); |
MC |
422 |
} |
|
423 |
|
31e0d1
|
424 |
//* Get the dovecot version |
b1a6a5
|
425 |
exec('dovecot --version', $tmp); |
b79f6c
|
426 |
$dovecot_version = $tmp[0]; |
31e0d1
|
427 |
unset($tmp); |
b1a6a5
|
428 |
|
31e0d1
|
429 |
//* Copy dovecot configuration file |
b79f6c
|
430 |
if(version_compare($dovecot_version,2) >= 0) { |
b1a6a5
|
431 |
if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_dovecot2.conf.master')) { |
MC |
432 |
copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_dovecot2.conf.master', $config_dir.'/'.$configfile); |
|
433 |
} else { |
|
434 |
copy('tpl/fedora_dovecot2.conf.master', $config_dir.'/'.$configfile); |
|
435 |
} |
b79f6c
|
436 |
if(version_compare($dovecot_version,2.1) < 0) { |
TB |
437 |
removeLine($config_dir.'/'.$configfile, 'ssl_protocols ='); |
|
438 |
} |
31e0d1
|
439 |
} else { |
b1a6a5
|
440 |
if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_dovecot.conf.master')) { |
MC |
441 |
copy($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_dovecot.conf.master', $config_dir.'/'.$configfile); |
|
442 |
} else { |
|
443 |
copy('tpl/fedora_dovecot.conf.master', $config_dir.'/'.$configfile); |
|
444 |
} |
31e0d1
|
445 |
} |
615a0a
|
446 |
|
8b23f8
|
447 |
//* dovecot-lmtpd |
FS |
448 |
if($configure_lmtp) { |
|
449 |
replaceLine($config_dir.'/'.$configfile, 'protocols = imap pop3', 'protocols = imap pop3 lmtp', 1, 0); |
|
450 |
} |
|
451 |
|
0f2bb1
|
452 |
//* dovecot-sql.conf |
T |
453 |
$configfile = 'dovecot-sql.conf'; |
|
454 |
if(is_file("$config_dir/$configfile")){ |
b1a6a5
|
455 |
copy("$config_dir/$configfile", "$config_dir/$configfile~"); |
0f2bb1
|
456 |
exec("chmod 400 $config_dir/$configfile~"); |
b1a6a5
|
457 |
} |
85f6fb
|
458 |
|
TB |
459 |
if(!@file_exists('/etc/dovecot-sql.conf')) exec('ln -s /etc/dovecot/dovecot-sql.conf /etc/dovecot-sql.conf'); |
b1a6a5
|
460 |
|
615a0a
|
461 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_dovecot-sql.conf.master', "tpl/fedora_dovecot-sql.conf.master"); |
b1a6a5
|
462 |
$content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content); |
MC |
463 |
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content); |
|
464 |
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content); |
|
465 |
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content); |
82e9b9
|
466 |
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content); |
032b86
|
467 |
$content = str_replace('{server_id}', $conf['server_id'], $content); |
94b284
|
468 |
# enable iterate_query for dovecot2 |
812da3
|
469 |
if(version_compare($dovecot_version,2, '>=')) { |
FS |
470 |
$content = str_replace('# iterate_query', 'iterate_query', $content); |
|
471 |
} |
0f2bb1
|
472 |
wf("$config_dir/$configfile", $content); |
b1a6a5
|
473 |
|
0f2bb1
|
474 |
exec("chmod 600 $config_dir/$configfile"); |
T |
475 |
exec("chown root:root $config_dir/$configfile"); |
5e7306
|
476 |
|
TB |
477 |
// Dovecot shall ignore mounts in website directory |
85f6fb
|
478 |
if(is_installed('doveadm')) exec("doveadm mount add '/var/www/*' ignore > /dev/null 2> /dev/null"); |
0f2bb1
|
479 |
|
T |
480 |
} |
b1a6a5
|
481 |
|
0711af
|
482 |
public function configure_amavis() { |
f496e9
|
483 |
global $conf, $dist; |
b1a6a5
|
484 |
|
0711af
|
485 |
// amavisd user config file |
T |
486 |
$configfile = 'fedora_amavisd_conf'; |
b1a6a5
|
487 |
if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf')) copy($conf["amavis"]["config_dir"].'/amavisd.conf', $conf["amavis"]["config_dir"].'/amavisd.conf~'); |
0711af
|
488 |
if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf~')) exec('chmod 400 '.$conf["amavis"]["config_dir"].'/amavisd.conf~'); |
615a0a
|
489 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "tpl/".$configfile.".master"); |
b1a6a5
|
490 |
$content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content); |
MC |
491 |
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content); |
|
492 |
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content); |
|
493 |
$content = str_replace('{mysql_server_port}', $conf["mysql"]["port"], $content); |
|
494 |
$content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content); |
|
495 |
$content = str_replace('{hostname}', $conf['hostname'], $content); |
|
496 |
wf($conf["amavis"]["config_dir"].'/amavisd.conf', $content); |
c83951
|
497 |
chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0640); |
2b3dfa
|
498 |
|
TB |
499 |
// for CentOS 7.2 only |
f496e9
|
500 |
if($dist['confid'] == 'centos72') { |
2b3dfa
|
501 |
chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0750); |
TB |
502 |
chgrp($conf['amavis']['config_dir'].'/amavisd.conf', 'amavis'); |
|
503 |
} |
b1a6a5
|
504 |
|
MC |
505 |
|
0711af
|
506 |
// Adding the amavisd commands to the postfix configuration |
T |
507 |
$postconf_commands = array ( |
|
508 |
'content_filter = amavis:[127.0.0.1]:10024', |
|
509 |
'receive_override_options = no_address_mappings' |
|
510 |
); |
b1a6a5
|
511 |
|
0711af
|
512 |
// Make a backup copy of the main.cf file |
b1a6a5
|
513 |
copy($conf["postfix"]["config_dir"].'/main.cf', $conf["postfix"]["config_dir"].'/main.cf~2'); |
MC |
514 |
|
0711af
|
515 |
// Executing the postconf commands |
T |
516 |
foreach($postconf_commands as $cmd) { |
|
517 |
$command = "postconf -e '$cmd'"; |
|
518 |
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
519 |
} |
b1a6a5
|
520 |
|
bd5d26
|
521 |
$config_dir = $conf['postfix']['config_dir']; |
FS |
522 |
|
|
523 |
// Adding amavis-services to the master.cf file if the service does not already exists |
9c6782
|
524 |
$add_amavis = !$this->get_postfix_service('amavis','unix'); |
FS |
525 |
$add_amavis_10025 = !$this->get_postfix_service('127.0.0.1:10025','inet'); |
|
526 |
$add_amavis_10027 = !$this->get_postfix_service('127.0.0.1:10027','inet'); |
bd5d26
|
527 |
|
FS |
528 |
if ($add_amavis || $add_amavis_10025 || $add_amavis_10027) { |
|
529 |
//* backup master.cf |
|
530 |
if(is_file($config_dir.'/master.cf')) copy($config_dir.'/master.cf', $config_dir.'/master.cf~'); |
|
531 |
// adjust amavis-config |
|
532 |
if($add_amavis) { |
|
533 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis.master', 'tpl/master_cf_amavis.master'); |
|
534 |
af($config_dir.'/master.cf', $content); |
|
535 |
unset($content); |
|
536 |
} |
|
537 |
if ($add_amavis_10025) { |
|
538 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10025.master', 'tpl/master_cf_amavis10025.master'); |
|
539 |
af($config_dir.'/master.cf', $content); |
|
540 |
unset($content); |
|
541 |
} |
|
542 |
if ($add_amavis_10027) { |
|
543 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/master_cf_amavis10027.master', 'tpl/master_cf_amavis10027.master'); |
|
544 |
af($config_dir.'/master.cf', $content); |
|
545 |
unset($content); |
|
546 |
} |
44ae08
|
547 |
} |
b1a6a5
|
548 |
|
MC |
549 |
removeLine('/etc/sysconfig/freshclam', 'FRESHCLAM_DELAY=disabled-warn # REMOVE ME', 1); |
|
550 |
replaceLine('/etc/freshclam.conf', 'Example', '# Example', 1); |
|
551 |
|
0711af
|
552 |
// Add the clamav user to the vscan group |
T |
553 |
//exec('groupmod --add-user clamav vscan'); |
b1a6a5
|
554 |
|
MC |
555 |
|
0711af
|
556 |
} |
b1a6a5
|
557 |
|
0711af
|
558 |
public function configure_spamassassin() |
b1a6a5
|
559 |
{ |
0711af
|
560 |
global $conf; |
b1a6a5
|
561 |
|
0711af
|
562 |
//* Enable spamasasssin on debian and ubuntu |
T |
563 |
/* |
|
564 |
$configfile = '/etc/default/spamassassin'; |
|
565 |
if(is_file($configfile)){ |
|
566 |
copy($configfile, $configfile.'~'); |
|
567 |
} |
|
568 |
$content = rf($configfile); |
|
569 |
$content = str_replace('ENABLED=0', 'ENABLED=1', $content); |
|
570 |
wf($configfile, $content); |
|
571 |
*/ |
|
572 |
} |
b1a6a5
|
573 |
|
0711af
|
574 |
public function configure_getmail() |
b1a6a5
|
575 |
{ |
0711af
|
576 |
global $conf; |
b1a6a5
|
577 |
|
0711af
|
578 |
$config_dir = $conf['getmail']['config_dir']; |
b1a6a5
|
579 |
|
0711af
|
580 |
if(!is_dir($config_dir)) exec("mkdir -p ".escapeshellcmd($config_dir)); |
T |
581 |
|
|
582 |
$command = "useradd -d $config_dir getmail"; |
392450
|
583 |
if(!is_user('getmail')) caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
b1a6a5
|
584 |
|
0711af
|
585 |
$command = "chown -R getmail $config_dir"; |
T |
586 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
b1a6a5
|
587 |
|
0711af
|
588 |
$command = "chmod -R 700 $config_dir"; |
T |
589 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
590 |
} |
b1a6a5
|
591 |
|
MC |
592 |
|
0711af
|
593 |
public function configure_pureftpd() |
b1a6a5
|
594 |
{ |
0711af
|
595 |
global $conf; |
b1a6a5
|
596 |
|
0711af
|
597 |
$config_dir = $conf['pureftpd']['config_dir']; |
T |
598 |
|
|
599 |
//* configure pam for SMTP authentication agains the ispconfig database |
|
600 |
$configfile = 'pureftpd-mysql.conf'; |
|
601 |
if(is_file("$config_dir/$configfile")){ |
b1a6a5
|
602 |
copy("$config_dir/$configfile", "$config_dir/$configfile~"); |
MC |
603 |
} |
0711af
|
604 |
if(is_file("$config_dir/$configfile~")){ |
b1a6a5
|
605 |
exec("chmod 400 $config_dir/$configfile~"); |
MC |
606 |
} |
615a0a
|
607 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/pureftpd_mysql.conf.master', 'tpl/pureftpd_mysql.conf.master'); |
0711af
|
608 |
$content = str_replace('{mysql_server_ispconfig_user}', $conf["mysql"]["ispconfig_user"], $content); |
T |
609 |
$content = str_replace('{mysql_server_ispconfig_password}', $conf["mysql"]["ispconfig_password"], $content); |
|
610 |
$content = str_replace('{mysql_server_database}', $conf["mysql"]["database"], $content); |
|
611 |
$content = str_replace('{mysql_server_ip}', $conf["mysql"]["ip"], $content); |
|
612 |
$content = str_replace('{server_id}', $conf["server_id"], $content); |
|
613 |
wf("$config_dir/$configfile", $content); |
|
614 |
exec("chmod 600 $config_dir/$configfile"); |
|
615 |
exec("chown root:root $config_dir/$configfile"); |
b1a6a5
|
616 |
|
0711af
|
617 |
// copy our customized copy of pureftpd.conf to the pure-ftpd config directory |
615a0a
|
618 |
if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_pureftpd_conf.master')) { |
b1a6a5
|
619 |
exec("cp " . $conf['ispconfig_install_dir'].'/server/conf-custom/install/fedora_pureftpd_conf.master ' . "$config_dir/pure-ftpd.conf"); |
MC |
620 |
}else { |
|
621 |
exec("cp tpl/fedora_pureftpd_conf.master $config_dir/pure-ftpd.conf"); |
|
622 |
} |
|
623 |
|
0711af
|
624 |
} |
b1a6a5
|
625 |
|
0711af
|
626 |
public function configure_mydns() |
b1a6a5
|
627 |
{ |
0711af
|
628 |
global $conf; |
b1a6a5
|
629 |
|
0711af
|
630 |
// configure mydns |
T |
631 |
$configfile = 'mydns.conf'; |
b1a6a5
|
632 |
if(is_file($conf["mydns"]["config_dir"].'/'.$configfile)) copy($conf["mydns"]["config_dir"].'/'.$configfile, $conf["mydns"]["config_dir"].'/'.$configfile.'~'); |
0711af
|
633 |
if(is_file($conf["mydns"]["config_dir"].'/'.$configfile.'~')) exec('chmod 400 '.$conf["mydns"]["config_dir"].'/'.$configfile.'~'); |
615a0a
|
634 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "tpl/".$configfile.".master"); |
b1a6a5
|
635 |
$content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content); |
MC |
636 |
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content); |
|
637 |
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content); |
|
638 |
$content = str_replace('{mysql_server_host}', $conf["mysql"]["host"], $content); |
223c56
|
639 |
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content); |
b1a6a5
|
640 |
$content = str_replace('{server_id}', $conf["server_id"], $content); |
MC |
641 |
wf($conf["mydns"]["config_dir"].'/'.$configfile, $content); |
0711af
|
642 |
exec('chmod 600 '.$conf["mydns"]["config_dir"].'/'.$configfile); |
T |
643 |
exec('chown root:root '.$conf["mydns"]["config_dir"].'/'.$configfile); |
b1a6a5
|
644 |
|
0711af
|
645 |
} |
b1a6a5
|
646 |
|
0f2bb1
|
647 |
public function configure_bind() { |
T |
648 |
global $conf; |
b1a6a5
|
649 |
|
0f2bb1
|
650 |
// add the include line at the end of named.conf. |
b1a6a5
|
651 |
replaceLine('/etc/named.conf', 'include "/etc/named.conf.local";', 'include "/etc/named.conf.local";', 0, 1); |
fd4cfd
|
652 |
|
D |
653 |
//* Check if the zonefile directory has a slash at the end |
|
654 |
$content=$conf['bind']['bind_zonefiles_dir']; |
b1a6a5
|
655 |
if(substr($content, -1, 1) != '/') { |
fd4cfd
|
656 |
$content .= '/'; |
D |
657 |
} |
|
658 |
|
|
659 |
//* Create the slave subdirectory |
|
660 |
$content .= 'slave'; |
|
661 |
$content_mkdir = 'mkdir -p '.$content; |
|
662 |
exec($content_mkdir); |
|
663 |
|
|
664 |
//* Chown the slave subdirectory to $conf['bind']['bind_user'] |
|
665 |
exec('chown '.$conf['bind']['bind_user'].':'.$conf['bind']['bind_group'].' '.$content); |
fc7f1b
|
666 |
exec('chmod 2770 '.$content); |
b1a6a5
|
667 |
|
0f2bb1
|
668 |
} |
b1a6a5
|
669 |
|
0711af
|
670 |
public function configure_apache() |
b1a6a5
|
671 |
{ |
0711af
|
672 |
global $conf; |
b1a6a5
|
673 |
|
1bd269
|
674 |
if($conf['apache']['installed'] == false) return; |
bde98e
|
675 |
if(is_file('/etc/suphp.conf')) { |
4c7fd5
|
676 |
//replaceLine('/etc/suphp.conf','php=php:/usr/bin','x-httpd-suphp=php:/usr/bin/php-cgi',0); |
b1a6a5
|
677 |
replaceLine('/etc/suphp.conf', 'docroot=', 'docroot=/var/www', 0); |
MC |
678 |
replaceLine('/etc/suphp.conf', 'umask=0077', 'umask=0022', 0); |
bde98e
|
679 |
} |
b1a6a5
|
680 |
|
0711af
|
681 |
//* Create the logging directory for the vhost logfiles |
T |
682 |
exec('mkdir -p /var/log/ispconfig/httpd'); |
b1a6a5
|
683 |
|
0711af
|
684 |
// Sites enabled and avaulable dirs |
T |
685 |
exec('mkdir -p '.$conf['apache']['vhost_conf_enabled_dir']); |
|
686 |
exec('mkdir -p '.$conf['apache']['vhost_conf_dir']); |
b1a6a5
|
687 |
|
0711af
|
688 |
$content = rf('/etc/httpd/conf/httpd.conf'); |
b1a6a5
|
689 |
if(!stristr($content, 'Include /etc/httpd/conf/sites-enabled/')) { |
MC |
690 |
af('/etc/httpd/conf/httpd.conf', "\nNameVirtualHost *:80\nNameVirtualHost *:443\nInclude /etc/httpd/conf/sites-enabled/\n\n"); |
0711af
|
691 |
} |
T |
692 |
unset($content); |
b1a6a5
|
693 |
|
9de0c4
|
694 |
//* Copy the ISPConfig configuration include |
b1a6a5
|
695 |
$vhost_conf_dir = $conf['apache']['vhost_conf_dir']; |
MC |
696 |
$vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir']; |
|
697 |
|
ccbf14
|
698 |
$tpl = new tpl('apache_ispconfig.conf.master'); |
TB |
699 |
$tpl->setVar('apache_version',getapacheversion()); |
|
700 |
|
2af58c
|
701 |
$records = $this->db->queryAllRecords("SELECT * FROM ?? WHERE server_id = ? AND virtualhost = 'y'", $conf['mysql']['master_database'] . '.server_ip', $conf['server_id']); |
ccbf14
|
702 |
$ip_addresses = array(); |
TB |
703 |
|
fb3a98
|
704 |
if(is_array($records) && count($records) > 0) { |
86e3bb
|
705 |
foreach($records as $rec) { |
a2156e
|
706 |
if($rec['ip_type'] == 'IPv6') { |
T |
707 |
$ip_address = '['.$rec['ip_address'].']'; |
|
708 |
} else { |
|
709 |
$ip_address = $rec['ip_address']; |
|
710 |
} |
b1a6a5
|
711 |
$ports = explode(',', $rec['virtualhost_port']); |
a2156e
|
712 |
if(is_array($ports)) { |
T |
713 |
foreach($ports as $port) { |
|
714 |
$port = intval($port); |
|
715 |
if($port > 0 && $port < 65536 && $ip_address != '') { |
ccbf14
|
716 |
$ip_addresses[] = array('ip_address' => $ip_address, 'port' => $port); |
a2156e
|
717 |
} |
T |
718 |
} |
|
719 |
} |
86e3bb
|
720 |
} |
T |
721 |
} |
855547
|
722 |
|
3de838
|
723 |
if(count($ip_addresses) > 0) $tpl->setLoop('ip_adresses',$ip_addresses); |
b1a6a5
|
724 |
|
ccbf14
|
725 |
wf($vhost_conf_dir.'/ispconfig.conf', $tpl->grab()); |
TB |
726 |
unset($tpl); |
b1a6a5
|
727 |
|
9de0c4
|
728 |
if(!@is_link($vhost_conf_enabled_dir."/000-ispconfig.conf")) { |
T |
729 |
exec("ln -s ".$vhost_conf_dir."/ispconfig.conf ".$vhost_conf_enabled_dir."/000-ispconfig.conf"); |
|
730 |
} |
b1a6a5
|
731 |
|
99d5dc
|
732 |
//* make sure that webalizer finds its config file when it is directly in /etc |
T |
733 |
if(@is_file('/etc/webalizer.conf') && !@is_dir('/etc/webalizer')) { |
|
734 |
exec('mkdir /etc/webalizer'); |
|
735 |
exec('ln -s /etc/webalizer.conf /etc/webalizer/webalizer.conf'); |
|
736 |
} |
b1a6a5
|
737 |
|
99d5dc
|
738 |
if(is_file('/etc/webalizer/webalizer.conf')) { |
T |
739 |
// Change webalizer mode to incremental |
b1a6a5
|
740 |
replaceLine('/etc/webalizer/webalizer.conf', '#IncrementalName', 'IncrementalName webalizer.current', 0, 0); |
MC |
741 |
replaceLine('/etc/webalizer/webalizer.conf', '#Incremental', 'Incremental yes', 0, 0); |
|
742 |
replaceLine('/etc/webalizer/webalizer.conf', '#HistoryName', 'HistoryName webalizer.hist', 0, 0); |
99d5dc
|
743 |
} |
b1a6a5
|
744 |
|
6b029a
|
745 |
//* add a sshusers group |
T |
746 |
$command = 'groupadd sshusers'; |
|
747 |
if(!is_group('sshusers')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
b1a6a5
|
748 |
|
0711af
|
749 |
} |
b1a6a5
|
750 |
|
d95ed9
|
751 |
public function configure_nginx(){ |
F |
752 |
global $conf; |
b1a6a5
|
753 |
|
d95ed9
|
754 |
if($conf['nginx']['installed'] == false) return; |
F |
755 |
//* Create the logging directory for the vhost logfiles |
|
756 |
if(!@is_dir($conf['ispconfig_log_dir'].'/httpd')) mkdir($conf['ispconfig_log_dir'].'/httpd', 0755, true); |
b1a6a5
|
757 |
|
d95ed9
|
758 |
// Sites enabled and avaulable dirs |
F |
759 |
exec('mkdir -p '.$conf['nginx']['vhost_conf_enabled_dir']); |
|
760 |
exec('mkdir -p '.$conf['nginx']['vhost_conf_dir']); |
|
761 |
|
b1a6a5
|
762 |
wf('/etc/nginx/conf.d/ispconfig_vhosts.conf', "include /etc/nginx/sites-enabled/*.vhost;"); |
d95ed9
|
763 |
|
F |
764 |
//* make sure that webalizer finds its config file when it is directly in /etc |
|
765 |
if(@is_file('/etc/webalizer.conf') && !@is_dir('/etc/webalizer')) { |
|
766 |
mkdir('/etc/webalizer'); |
b1a6a5
|
767 |
symlink('/etc/webalizer.conf', '/etc/webalizer/webalizer.conf'); |
d95ed9
|
768 |
} |
F |
769 |
|
|
770 |
if(is_file('/etc/webalizer/webalizer.conf')) { |
|
771 |
// Change webalizer mode to incremental |
b1a6a5
|
772 |
replaceLine('/etc/webalizer/webalizer.conf', '#IncrementalName', 'IncrementalName webalizer.current', 0, 0); |
MC |
773 |
replaceLine('/etc/webalizer/webalizer.conf', '#Incremental', 'Incremental yes', 0, 0); |
|
774 |
replaceLine('/etc/webalizer/webalizer.conf', '#HistoryName', 'HistoryName webalizer.hist', 0, 0); |
d95ed9
|
775 |
} |
b1a6a5
|
776 |
|
d95ed9
|
777 |
// Check the awsatst script |
F |
778 |
if(!is_dir('/usr/share/awstats/tools')) exec('mkdir -p /usr/share/awstats/tools'); |
b1a6a5
|
779 |
if(!file_exists('/usr/share/awstats/tools/awstats_buildstaticpages.pl') && file_exists('/usr/share/doc/awstats/examples/awstats_buildstaticpages.pl')) symlink('/usr/share/doc/awstats/examples/awstats_buildstaticpages.pl', '/usr/share/awstats/tools/awstats_buildstaticpages.pl'); |
MC |
780 |
if(file_exists('/etc/awstats/awstats.conf.local')) replaceLine('/etc/awstats/awstats.conf.local', 'LogFormat=4', 'LogFormat=1', 0, 1); |
|
781 |
|
d95ed9
|
782 |
//* add a sshusers group |
F |
783 |
$command = 'groupadd sshusers'; |
|
784 |
if(!is_group('sshusers')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
785 |
} |
b1a6a5
|
786 |
|
ca2165
|
787 |
public function configure_bastille_firewall() |
0711af
|
788 |
{ |
T |
789 |
global $conf; |
b1a6a5
|
790 |
|
0711af
|
791 |
$dist_init_scripts = $conf['init_scripts']; |
b1a6a5
|
792 |
|
0711af
|
793 |
if(is_dir("/etc/Bastille.backup")) caselog("rm -rf /etc/Bastille.backup", __FILE__, __LINE__); |
T |
794 |
if(is_dir("/etc/Bastille")) caselog("mv -f /etc/Bastille /etc/Bastille.backup", __FILE__, __LINE__); |
b1a6a5
|
795 |
@mkdir("/etc/Bastille", octdec($directory_mode)); |
MC |
796 |
if(is_dir("/etc/Bastille.backup/firewall.d")) caselog("cp -pfr /etc/Bastille.backup/firewall.d /etc/Bastille/", __FILE__, __LINE__); |
|
797 |
if(is_file($conf['ispconfig_install_dir'].'/server/conf-custom/install/bastille-firewall.cfg.master')) { |
|
798 |
caselog("cp -f " . $conf['ispconfig_install_dir']."/server/conf-custom/install/bastille-firewall.cfg.master /etc/Bastille/bastille-firewall.cfg", __FILE__, __LINE__); |
|
799 |
} else { |
|
800 |
caselog("cp -f tpl/bastille-firewall.cfg.master /etc/Bastille/bastille-firewall.cfg", __FILE__, __LINE__); |
|
801 |
} |
|
802 |
caselog("chmod 644 /etc/Bastille/bastille-firewall.cfg", __FILE__, __LINE__); |
|
803 |
$content = rf("/etc/Bastille/bastille-firewall.cfg"); |
|
804 |
$content = str_replace("{DNS_SERVERS}", "", $content); |
0711af
|
805 |
|
b1a6a5
|
806 |
$tcp_public_services = ''; |
MC |
807 |
$udp_public_services = ''; |
|
808 |
|
2af58c
|
809 |
$row = $this->db->queryOneRecord('SELECT * FROM ?? WHERE server_id = ?', $conf["mysql"]["database"] . '.firewall', $conf['server_id']); |
b1a6a5
|
810 |
|
MC |
811 |
if(trim($row["tcp_port"]) != '' || trim($row["udp_port"]) != ''){ |
|
812 |
$tcp_public_services = trim(str_replace(',', ' ', $row["tcp_port"])); |
|
813 |
$udp_public_services = trim(str_replace(',', ' ', $row["udp_port"])); |
|
814 |
} else { |
|
815 |
$tcp_public_services = '21 22 25 53 80 110 443 3306 8080 10000'; |
|
816 |
$udp_public_services = '53'; |
|
817 |
} |
9ce725
|
818 |
if(!stristr($tcp_public_services, $conf['apache']['vhost_port'])) { |
96cc31
|
819 |
$tcp_public_services .= ' '.intval($conf['apache']['vhost_port']); |
2af58c
|
820 |
if($row["tcp_port"] != '') $this->db->query("UPDATE firewall SET tcp_port = tcp_port + ? WHERE server_id = ?", ',' . intval($conf['apache']['vhost_port']), $conf['server_id']); |
9ce725
|
821 |
} |
0711af
|
822 |
|
b1a6a5
|
823 |
$content = str_replace("{TCP_PUBLIC_SERVICES}", $tcp_public_services, $content); |
MC |
824 |
$content = str_replace("{UDP_PUBLIC_SERVICES}", $udp_public_services, $content); |
0711af
|
825 |
|
b1a6a5
|
826 |
wf("/etc/Bastille/bastille-firewall.cfg", $content); |
0711af
|
827 |
|
b1a6a5
|
828 |
if(is_file($dist_init_scripts."/bastille-firewall")) caselog("mv -f $dist_init_scripts/bastille-firewall $dist_init_scripts/bastille-firewall.backup", __FILE__, __LINE__); |
MC |
829 |
caselog("cp -f apps/bastille-firewall $dist_init_scripts", __FILE__, __LINE__); |
|
830 |
caselog("chmod 700 $dist_init_scripts/bastille-firewall", __FILE__, __LINE__); |
0711af
|
831 |
|
b1a6a5
|
832 |
if(is_file("/sbin/bastille-ipchains")) caselog("mv -f /sbin/bastille-ipchains /sbin/bastille-ipchains.backup", __FILE__, __LINE__); |
MC |
833 |
caselog("cp -f apps/bastille-ipchains /sbin", __FILE__, __LINE__); |
|
834 |
caselog("chmod 700 /sbin/bastille-ipchains", __FILE__, __LINE__); |
|
835 |
|
|
836 |
if(is_file("/sbin/bastille-netfilter")) caselog("mv -f /sbin/bastille-netfilter /sbin/bastille-netfilter.backup", __FILE__, __LINE__); |
|
837 |
caselog("cp -f apps/bastille-netfilter /sbin", __FILE__, __LINE__); |
|
838 |
caselog("chmod 700 /sbin/bastille-netfilter", __FILE__, __LINE__); |
|
839 |
|
0711af
|
840 |
if(!@is_dir('/var/lock/subsys')) caselog("mkdir /var/lock/subsys", __FILE__, __LINE__); |
T |
841 |
|
b1a6a5
|
842 |
exec("which ipchains &> /dev/null", $ipchains_location, $ret_val); |
MC |
843 |
if(!is_file("/sbin/ipchains") && !is_link("/sbin/ipchains") && $ret_val == 0) phpcaselog(@symlink(shell_exec("which ipchains"), "/sbin/ipchains"), 'create symlink', __FILE__, __LINE__); |
|
844 |
unset($ipchains_location); |
|
845 |
exec("which iptables &> /dev/null", $iptables_location, $ret_val); |
|
846 |
if(!is_file("/sbin/iptables") && !is_link("/sbin/iptables") && $ret_val == 0) phpcaselog(@symlink(trim(shell_exec("which iptables")), "/sbin/iptables"), 'create symlink', __FILE__, __LINE__); |
|
847 |
unset($iptables_location); |
0711af
|
848 |
|
T |
849 |
} |
b1a6a5
|
850 |
|
0711af
|
851 |
public function install_ispconfig() |
b1a6a5
|
852 |
{ |
0711af
|
853 |
global $conf; |
b1a6a5
|
854 |
|
0711af
|
855 |
$install_dir = $conf['ispconfig_install_dir']; |
T |
856 |
|
|
857 |
//* Create the ISPConfig installation directory |
|
858 |
if(!@is_dir("$install_dir")) { |
|
859 |
$command = "mkdir $install_dir"; |
|
860 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
861 |
} |
b1a6a5
|
862 |
|
0711af
|
863 |
//* Create a ISPConfig user and group |
T |
864 |
$command = 'groupadd ispconfig'; |
392450
|
865 |
if(!is_group('ispconfig')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
b1a6a5
|
866 |
|
0711af
|
867 |
$command = "useradd -g ispconfig -d $install_dir ispconfig"; |
392450
|
868 |
if(!is_user('ispconfig')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
b1a6a5
|
869 |
|
0711af
|
870 |
//* copy the ISPConfig interface part |
T |
871 |
$command = "cp -rf ../interface $install_dir"; |
|
872 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
b1a6a5
|
873 |
|
0711af
|
874 |
//* copy the ISPConfig server part |
T |
875 |
$command = "cp -rf ../server $install_dir"; |
|
876 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
a13af2
|
877 |
|
fb6c56
|
878 |
//* Make a backup of the security settings |
TB |
879 |
if(is_file('/usr/local/ispconfig/security/security_settings.ini')) copy('/usr/local/ispconfig/security/security_settings.ini','/usr/local/ispconfig/security/security_settings.ini~'); |
|
880 |
|
a13af2
|
881 |
//* copy the ISPConfig security part |
TB |
882 |
$command = 'cp -rf ../security '.$install_dir; |
|
883 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
fb6c56
|
884 |
|
TB |
885 |
//* Apply changed security_settings.ini values to new security_settings.ini file |
|
886 |
if(is_file('/usr/local/ispconfig/security/security_settings.ini~')) { |
|
887 |
$security_settings_old = ini_to_array(file_get_contents('/usr/local/ispconfig/security/security_settings.ini~')); |
|
888 |
$security_settings_new = ini_to_array(file_get_contents('/usr/local/ispconfig/security/security_settings.ini')); |
|
889 |
if(is_array($security_settings_new) && is_array($security_settings_old)) { |
|
890 |
foreach($security_settings_new as $section => $sval) { |
|
891 |
if(is_array($sval)) { |
|
892 |
foreach($sval as $key => $val) { |
|
893 |
if(isset($security_settings_old[$section]) && isset($security_settings_old[$section][$key])) { |
|
894 |
$security_settings_new[$section][$key] = $security_settings_old[$section][$key]; |
|
895 |
} |
|
896 |
} |
|
897 |
} |
|
898 |
} |
|
899 |
file_put_contents('/usr/local/ispconfig/security/security_settings.ini',array_to_ini($security_settings_new)); |
|
900 |
} |
|
901 |
} |
b1a6a5
|
902 |
|
0711af
|
903 |
//* Create a symlink, so ISPConfig is accessible via web |
T |
904 |
// Replaced by a separate vhost definition for port 8080 |
|
905 |
// $command = "ln -s $install_dir/interface/web/ /var/www/ispconfig"; |
|
906 |
// caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
b1a6a5
|
907 |
|
0711af
|
908 |
//* Create the config file for ISPConfig interface |
T |
909 |
$configfile = 'config.inc.php'; |
|
910 |
if(is_file($install_dir.'/interface/lib/'.$configfile)){ |
b1a6a5
|
911 |
copy("$install_dir/interface/lib/$configfile", "$install_dir/interface/lib/$configfile~"); |
MC |
912 |
} |
615a0a
|
913 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "tpl/$configfile.master"); |
0711af
|
914 |
$content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content); |
b1a6a5
|
915 |
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content); |
0711af
|
916 |
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content); |
T |
917 |
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content); |
82e9b9
|
918 |
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content); |
b1a6a5
|
919 |
|
12e3ba
|
920 |
$content = str_replace('{mysql_master_server_ispconfig_user}', $conf['mysql']['master_ispconfig_user'], $content); |
T |
921 |
$content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content); |
|
922 |
$content = str_replace('{mysql_master_server_database}', $conf['mysql']['master_database'], $content); |
|
923 |
$content = str_replace('{mysql_master_server_host}', $conf['mysql']['master_host'], $content); |
82e9b9
|
924 |
$content = str_replace('{mysql_master_server_port}', $conf['mysql']['master_port'], $content); |
b1a6a5
|
925 |
|
7c3b60
|
926 |
$content = str_replace('{server_id}', $conf['server_id'], $content); |
0711af
|
927 |
$content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content); |
56f1f4
|
928 |
$content = str_replace('{language}', $conf['language'], $content); |
8cf78b
|
929 |
$content = str_replace('{timezone}', $conf['timezone'], $content); |
41eaa8
|
930 |
$content = str_replace('{theme}', $conf['theme'], $content); |
992797
|
931 |
$content = str_replace('{language_file_import_enabled}', ($conf['language_file_import_enabled'] == true)?'true':'false', $content); |
b1a6a5
|
932 |
|
0711af
|
933 |
wf("$install_dir/interface/lib/$configfile", $content); |
b1a6a5
|
934 |
|
0711af
|
935 |
//* Create the config file for ISPConfig server |
T |
936 |
$configfile = 'config.inc.php'; |
|
937 |
if(is_file($install_dir.'/server/lib/'.$configfile)){ |
b1a6a5
|
938 |
copy("$install_dir/server/lib/$configfile", "$install_dir/interface/lib/$configfile~"); |
MC |
939 |
} |
615a0a
|
940 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/'.$configfile.'.master', "tpl/$configfile.master"); |
0711af
|
941 |
$content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content); |
T |
942 |
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content); |
|
943 |
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content); |
|
944 |
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content); |
82e9b9
|
945 |
$content = str_replace('{mysql_server_port}', $conf['mysql']['port'], $content); |
b1a6a5
|
946 |
|
12e3ba
|
947 |
$content = str_replace('{mysql_master_server_ispconfig_user}', $conf['mysql']['master_ispconfig_user'], $content); |
T |
948 |
$content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content); |
|
949 |
$content = str_replace('{mysql_master_server_database}', $conf['mysql']['master_database'], $content); |
|
950 |
$content = str_replace('{mysql_master_server_host}', $conf['mysql']['master_host'], $content); |
82e9b9
|
951 |
$content = str_replace('{mysql_master_server_port}', $conf['mysql']['master_port'], $content); |
b1a6a5
|
952 |
|
0711af
|
953 |
$content = str_replace('{server_id}', $conf['server_id'], $content); |
T |
954 |
$content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content); |
5898e6
|
955 |
$content = str_replace('{language}', $conf['language'], $content); |
8cf78b
|
956 |
$content = str_replace('{timezone}', $conf['timezone'], $content); |
41eaa8
|
957 |
$content = str_replace('{theme}', $conf['theme'], $content); |
992797
|
958 |
$content = str_replace('{language_file_import_enabled}', ($conf['language_file_import_enabled'] == true)?'true':'false', $content); |
5c4d55
|
959 |
|
0711af
|
960 |
wf("$install_dir/server/lib/$configfile", $content); |
b1a6a5
|
961 |
|
fb3a98
|
962 |
//* Create the config file for remote-actions (but only, if it does not exist, because |
T |
963 |
// the value is a autoinc-value and so changed by the remoteaction_core_module |
|
964 |
if (!file_exists($install_dir.'/server/lib/remote_action.inc.php')) { |
|
965 |
$content = '<?php' . "\n" . '$maxid_remote_action = 0;' . "\n" . '?>'; |
|
966 |
wf($install_dir.'/server/lib/remote_action.inc.php', $content); |
|
967 |
} |
b1a6a5
|
968 |
|
0711af
|
969 |
//* Enable the server modules and plugins. |
T |
970 |
// TODO: Implement a selector which modules and plugins shall be enabled. |
|
971 |
$dir = $install_dir.'/server/mods-available/'; |
|
972 |
if (is_dir($dir)) { |
|
973 |
if ($dh = opendir($dir)) { |
|
974 |
while (($file = readdir($dh)) !== false) { |
b1a6a5
|
975 |
if($file != '.' && $file != '..' && substr($file, -8, 8) == '.inc.php') { |
MC |
976 |
include_once $install_dir.'/server/mods-available/'.$file; |
|
977 |
$module_name = substr($file, 0, -8); |
392450
|
978 |
$tmp = new $module_name; |
T |
979 |
if($tmp->onInstall()) { |
|
980 |
if(!@is_link($install_dir.'/server/mods-enabled/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-enabled/'.$file); |
|
981 |
if (strpos($file, '_core_module') !== false) { |
|
982 |
if(!@is_link($install_dir.'/server/mods-core/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-core/'.$file); |
|
983 |
} |
0d0cd9
|
984 |
} |
392450
|
985 |
unset($tmp); |
0711af
|
986 |
} |
T |
987 |
} |
|
988 |
closedir($dh); |
|
989 |
} |
|
990 |
} |
b1a6a5
|
991 |
|
0711af
|
992 |
$dir = $install_dir.'/server/plugins-available/'; |
T |
993 |
if (is_dir($dir)) { |
|
994 |
if ($dh = opendir($dir)) { |
|
995 |
while (($file = readdir($dh)) !== false) { |
1bd269
|
996 |
if($conf['apache']['installed'] == true && $file == 'nginx_plugin.inc.php') continue; |
F |
997 |
if($conf['nginx']['installed'] == true && $file == 'apache2_plugin.inc.php') continue; |
b1a6a5
|
998 |
if($file != '.' && $file != '..' && substr($file, -8, 8) == '.inc.php') { |
MC |
999 |
include_once $install_dir.'/server/plugins-available/'.$file; |
|
1000 |
$plugin_name = substr($file, 0, -8); |
392450
|
1001 |
$tmp = new $plugin_name; |
T |
1002 |
if($tmp->onInstall()) { |
|
1003 |
if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file); |
|
1004 |
if (strpos($file, '_core_plugin') !== false) { |
|
1005 |
if(!@is_link($install_dir.'/server/plugins-core/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-core/'.$file); |
|
1006 |
} |
0d0cd9
|
1007 |
} |
392450
|
1008 |
unset($tmp); |
0711af
|
1009 |
} |
T |
1010 |
} |
|
1011 |
closedir($dh); |
|
1012 |
} |
|
1013 |
} |
b1a6a5
|
1014 |
|
392450
|
1015 |
// Update the server config |
T |
1016 |
$mail_server_enabled = ($conf['services']['mail'])?1:0; |
|
1017 |
$web_server_enabled = ($conf['services']['web'])?1:0; |
|
1018 |
$dns_server_enabled = ($conf['services']['dns'])?1:0; |
|
1019 |
$file_server_enabled = ($conf['services']['file'])?1:0; |
|
1020 |
$db_server_enabled = ($conf['services']['db'])?1:0; |
|
1021 |
$vserver_server_enabled = ($conf['services']['vserver'])?1:0; |
2af58c
|
1022 |
$sql = "UPDATE `server` SET mail_server = ?, web_server = ?, dns_server = ?, file_server = ?, db_server = ?, vserver_server = ? WHERE server_id = ?"; |
b1a6a5
|
1023 |
|
2af58c
|
1024 |
$this->db->query($sql, $mail_server_enabled, $web_server_enabled, $dns_server_enabled, $file_server_enabled, $db_server_enabled, $vserver_server_enabled, $conf['server_id']); |
392450
|
1025 |
if($conf['mysql']['master_slave_setup'] == 'y') { |
2af58c
|
1026 |
$this->dbmaster->query($sql, $mail_server_enabled, $web_server_enabled, $dns_server_enabled, $file_server_enabled, $db_server_enabled, $vserver_server_enabled, $conf['server_id']); |
392450
|
1027 |
} |
b1a6a5
|
1028 |
|
fa029b
|
1029 |
// chown install dir to root and chmod 755 |
3e0fc8
|
1030 |
$command = 'chown root:root '.$install_dir; |
TB |
1031 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
1032 |
$command = 'chmod 755 '.$install_dir; |
0711af
|
1033 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
T |
1034 |
|
fa029b
|
1035 |
//* Chmod the files and directories in the install dir |
3e0fc8
|
1036 |
$command = 'chmod -R 750 '.$install_dir.'/*'; |
TB |
1037 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
1038 |
|
|
1039 |
//* chown the interface files to the ispconfig user and group |
|
1040 |
$command = 'chown -R ispconfig:ispconfig '.$install_dir.'/interface'; |
|
1041 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
1042 |
|
|
1043 |
//* chown the server files to the root user and group |
|
1044 |
$command = 'chown -R root:root '.$install_dir.'/server'; |
0711af
|
1045 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
fa029b
|
1046 |
|
TB |
1047 |
//* chown the security files to the root user and group |
|
1048 |
$command = 'chown -R root:root '.$install_dir.'/security'; |
|
1049 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
1050 |
|
|
1051 |
//* chown the security directory and security_settings.ini to root:ispconfig |
|
1052 |
$command = 'chown root:ispconfig '.$install_dir.'/security/security_settings.ini'; |
|
1053 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
1054 |
$command = 'chown root:ispconfig '.$install_dir.'/security'; |
|
1055 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
cb1221
|
1056 |
$command = 'chown root:ispconfig '.$install_dir.'/security/ids.whitelist'; |
TB |
1057 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
1058 |
$command = 'chown root:ispconfig '.$install_dir.'/security/ids.htmlfield'; |
|
1059 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
1060 |
$command = 'chown root:ispconfig '.$install_dir.'/security/apache_directives.blacklist'; |
0711af
|
1061 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
b1a6a5
|
1062 |
|
0711af
|
1063 |
//* Make the global language file directory group writable |
T |
1064 |
exec("chmod -R 770 $install_dir/interface/lib/lang"); |
b1a6a5
|
1065 |
|
0711af
|
1066 |
//* Make the temp directory for language file exports writable |
T |
1067 |
exec("chmod -R 770 $install_dir/interface/web/temp"); |
b1a6a5
|
1068 |
|
0711af
|
1069 |
//* Make all interface language file directories group writable |
T |
1070 |
$handle = @opendir($install_dir.'/interface/web'); |
b1a6a5
|
1071 |
while ($file = @readdir($handle)) { |
MC |
1072 |
if ($file != '.' && $file != '..') { |
|
1073 |
if(@is_dir($install_dir.'/interface/web'.'/'.$file.'/lib/lang')) { |
0711af
|
1074 |
$handle2 = opendir($install_dir.'/interface/web'.'/'.$file.'/lib/lang'); |
b1a6a5
|
1075 |
chmod($install_dir.'/interface/web'.'/'.$file.'/lib/lang', 0770); |
MC |
1076 |
while ($lang_file = @readdir($handle2)) { |
0711af
|
1077 |
if ($lang_file != '.' && $lang_file != '..') { |
b1a6a5
|
1078 |
chmod($install_dir.'/interface/web'.'/'.$file.'/lib/lang/'.$lang_file, 0770); |
0711af
|
1079 |
} |
T |
1080 |
} |
|
1081 |
} |
|
1082 |
} |
|
1083 |
} |
b1a6a5
|
1084 |
|
477d4e
|
1085 |
//* Make the APS directories group writable |
T |
1086 |
exec("chmod -R 770 $install_dir/interface/web/sites/aps_meta_packages"); |
|
1087 |
exec("chmod -R 770 $install_dir/server/aps_packages"); |
b1a6a5
|
1088 |
|
0711af
|
1089 |
//* make sure that the server config file (not the interface one) is only readable by the root user |
bfcdef
|
1090 |
chmod($install_dir.'/server/lib/config.inc.php', 0600); |
T |
1091 |
chown($install_dir.'/server/lib/config.inc.php', 'root'); |
|
1092 |
chgrp($install_dir.'/server/lib/config.inc.php', 'root'); |
b1a6a5
|
1093 |
|
bfcdef
|
1094 |
//* Make sure thet the interface config file is readable by user ispconfig only |
T |
1095 |
chmod($install_dir.'/interface/lib/config.inc.php', 0600); |
|
1096 |
chown($install_dir.'/interface/lib/config.inc.php', 'ispconfig'); |
|
1097 |
chgrp($install_dir.'/interface/lib/config.inc.php', 'ispconfig'); |
b1a6a5
|
1098 |
|
0711af
|
1099 |
if(@is_file("$install_dir/server/lib/mysql_clientdb.conf")) { |
T |
1100 |
exec("chmod 600 $install_dir/server/lib/mysql_clientdb.conf"); |
|
1101 |
exec("chown root:root $install_dir/server/lib/mysql_clientdb.conf"); |
|
1102 |
} |
980485
|
1103 |
|
TB |
1104 |
if(is_dir($install_dir.'/interface/invoices')) { |
|
1105 |
exec('chmod -R 770 '.escapeshellarg($install_dir.'/interface/invoices')); |
|
1106 |
exec('chown -R ispconfig:ispconfig '.escapeshellarg($install_dir.'/interface/invoices')); |
|
1107 |
} |
|
1108 |
|
|
1109 |
exec('chown -R root:root /usr/local/ispconfig/interface/ssl'); |
b1a6a5
|
1110 |
|
0711af
|
1111 |
// TODO: FIXME: add the www-data user to the ispconfig group. This is just for testing |
T |
1112 |
// and must be fixed as this will allow the apache user to read the ispconfig files. |
|
1113 |
// Later this must run as own apache server or via suexec! |
63b369
|
1114 |
if($conf['apache']['installed'] == true){ |
F |
1115 |
$command = 'usermod -a -G ispconfig '.$conf['apache']['user']; |
|
1116 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
272aec
|
1117 |
if(is_group('ispapps')){ |
F |
1118 |
$command = 'usermod -a -G ispapps '.$conf['apache']['user']; |
|
1119 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
1120 |
} |
63b369
|
1121 |
} |
F |
1122 |
if($conf['nginx']['installed'] == true){ |
|
1123 |
$command = 'usermod -a -G ispconfig '.$conf['nginx']['user']; |
|
1124 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
272aec
|
1125 |
if(is_group('ispapps')){ |
F |
1126 |
$command = 'usermod -a -G ispapps '.$conf['nginx']['user']; |
|
1127 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
1128 |
} |
63b369
|
1129 |
} |
b1a6a5
|
1130 |
|
0711af
|
1131 |
//* Make the shell scripts executable |
T |
1132 |
$command = "chmod +x $install_dir/server/scripts/*.sh"; |
|
1133 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
b1a6a5
|
1134 |
|
7e1cfb
|
1135 |
if($conf['apache']['installed'] == true && $this->install_ispconfig_interface == true){ |
1bd269
|
1136 |
//* Copy the ISPConfig vhost for the controlpanel |
F |
1137 |
// TODO: These are missing! should they be "vhost_dist_*_dir" ? |
|
1138 |
$vhost_conf_dir = $conf['apache']['vhost_conf_dir']; |
|
1139 |
$vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir']; |
b1a6a5
|
1140 |
|
MC |
1141 |
|
1bd269
|
1142 |
// Dont just copy over the virtualhost template but add some custom settings |
ccbf14
|
1143 |
$tpl = new tpl('apache_ispconfig.vhost.master'); |
TB |
1144 |
$tpl->setVar('vhost_port',$conf['apache']['vhost_port']); |
b1a6a5
|
1145 |
|
1bd269
|
1146 |
// comment out the listen directive if port is 80 or 443 |
F |
1147 |
if($conf['apache']['vhost_port'] == 80 or $conf['apache']['vhost_port'] == 443) { |
ccbf14
|
1148 |
$tpl->setVar('vhost_port_listen','#'); |
1bd269
|
1149 |
} else { |
ccbf14
|
1150 |
$tpl->setVar('vhost_port_listen',''); |
1bd269
|
1151 |
} |
b1a6a5
|
1152 |
|
ccbf14
|
1153 |
if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) { |
TB |
1154 |
$tpl->setVar('ssl_comment',''); |
1bd269
|
1155 |
} else { |
ccbf14
|
1156 |
$tpl->setVar('ssl_comment','#'); |
1bd269
|
1157 |
} |
10b4c8
|
1158 |
if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key') && is_file($install_dir.'/interface/ssl/ispserver.bundle')) { |
ccbf14
|
1159 |
$tpl->setVar('ssl_bundle_comment',''); |
10b4c8
|
1160 |
} else { |
ccbf14
|
1161 |
$tpl->setVar('ssl_bundle_comment','#'); |
10b4c8
|
1162 |
} |
ccbf14
|
1163 |
|
TB |
1164 |
$tpl->setVar('apache_version',getapacheversion()); |
b1a6a5
|
1165 |
|
ccbf14
|
1166 |
wf($vhost_conf_dir.'/ispconfig.vhost', $tpl->grab()); |
b1a6a5
|
1167 |
|
1bd269
|
1168 |
//copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost"); |
F |
1169 |
//* and create the symlink |
cc6568
|
1170 |
//if($this->is_update == false) { |
b1a6a5
|
1171 |
if(@is_link("$vhost_conf_enabled_dir/ispconfig.vhost")) unlink("$vhost_conf_enabled_dir/ispconfig.vhost"); |
MC |
1172 |
if(!@is_link("$vhost_conf_enabled_dir/000-ispconfig.vhost")) { |
|
1173 |
exec("ln -s $vhost_conf_dir/ispconfig.vhost $vhost_conf_enabled_dir/000-ispconfig.vhost"); |
|
1174 |
} |
|
1175 |
|
|
1176 |
/* |
1bd269
|
1177 |
exec('mkdir -p /var/www/php-fcgi-scripts/ispconfig'); |
F |
1178 |
exec('cp tpl/apache_ispconfig_fcgi_starter.master /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter'); |
|
1179 |
exec('chmod +x /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter'); |
|
1180 |
exec('ln -s /usr/local/ispconfig/interface/web /var/www/ispconfig'); |
|
1181 |
exec('chown -R ispconfig:ispconfig /var/www/php-fcgi-scripts/ispconfig'); |
b1a6a5
|
1182 |
|
1bd269
|
1183 |
replaceLine('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter','PHPRC=','PHPRC=/etc/',0,0); |
526b99
|
1184 |
*/ |
b1a6a5
|
1185 |
//if(!is_file('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter')) { |
MC |
1186 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/apache_ispconfig_fcgi_starter.master', 'tpl/apache_ispconfig_fcgi_starter.master'); |
|
1187 |
$content = str_replace('{fastcgi_bin}', $conf['fastcgi']['fastcgi_bin'], $content); |
|
1188 |
$content = str_replace('{fastcgi_phpini_path}', $conf['fastcgi']['fastcgi_phpini_path'], $content); |
|
1189 |
if(!is_dir('/var/www/php-fcgi-scripts/ispconfig')) exec('mkdir -p /var/www/php-fcgi-scripts/ispconfig'); |
|
1190 |
wf('/var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter', $content); |
|
1191 |
exec('chmod +x /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter'); |
|
1192 |
if(!is_link('/var/www/ispconfig')) exec('ln -s /usr/local/ispconfig/interface/web /var/www/ispconfig'); |
|
1193 |
exec('chown -R ispconfig:ispconfig /var/www/php-fcgi-scripts/ispconfig'); |
|
1194 |
//} |
cc6568
|
1195 |
//} |
f6d745
|
1196 |
} |
b1a6a5
|
1197 |
|
7e1cfb
|
1198 |
if($conf['nginx']['installed'] == true && $this->install_ispconfig_interface == true){ |
1bd269
|
1199 |
//* Copy the ISPConfig vhost for the controlpanel |
F |
1200 |
$vhost_conf_dir = $conf['nginx']['vhost_conf_dir']; |
|
1201 |
$vhost_conf_enabled_dir = $conf['nginx']['vhost_conf_enabled_dir']; |
|
1202 |
|
|
1203 |
// Dont just copy over the virtualhost template but add some custom settings |
615a0a
|
1204 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/nginx_ispconfig.vhost.master', 'tpl/nginx_ispconfig.vhost.master'); |
1bd269
|
1205 |
$content = str_replace('{vhost_port}', $conf['nginx']['vhost_port'], $content); |
b1a6a5
|
1206 |
|
1bd269
|
1207 |
if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) { |
10b4c8
|
1208 |
$content = str_replace('{ssl_on}', ' on', $content); |
1bd269
|
1209 |
$content = str_replace('{ssl_comment}', '', $content); |
F |
1210 |
$content = str_replace('{fastcgi_ssl}', 'on', $content); |
|
1211 |
} else { |
10b4c8
|
1212 |
$content = str_replace('{ssl_on}', ' off', $content); |
1bd269
|
1213 |
$content = str_replace('{ssl_comment}', '#', $content); |
F |
1214 |
$content = str_replace('{fastcgi_ssl}', 'off', $content); |
0711af
|
1215 |
} |
b1a6a5
|
1216 |
|
ca0b77
|
1217 |
$socket_dir = escapeshellcmd($conf['nginx']['php_fpm_socket_dir']); |
b1a6a5
|
1218 |
if(substr($socket_dir, -1) != '/') $socket_dir .= '/'; |
ca0b77
|
1219 |
if(!is_dir($socket_dir)) exec('mkdir -p '.$socket_dir); |
F |
1220 |
$fpm_socket = $socket_dir.'ispconfig.sock'; |
b1a6a5
|
1221 |
|
ca0b77
|
1222 |
//$content = str_replace('{fpm_port}', $conf['nginx']['php_fpm_start_port'], $content); |
F |
1223 |
$content = str_replace('{fpm_socket}', $fpm_socket, $content); |
1bd269
|
1224 |
|
F |
1225 |
wf($vhost_conf_dir.'/ispconfig.vhost', $content); |
b1a6a5
|
1226 |
|
1bd269
|
1227 |
unset($content); |
b1a6a5
|
1228 |
|
1bd269
|
1229 |
// PHP-FPM |
F |
1230 |
// Dont just copy over the php-fpm pool template but add some custom settings |
615a0a
|
1231 |
$content = rfsel($conf['ispconfig_install_dir'].'/server/conf-custom/install/php_fpm_pool.conf.master', 'tpl/php_fpm_pool.conf.master'); |
1bd269
|
1232 |
$content = str_replace('{fpm_pool}', 'ispconfig', $content); |
ca0b77
|
1233 |
//$content = str_replace('{fpm_port}', $conf['nginx']['php_fpm_start_port'], $content); |
F |
1234 |
$content = str_replace('{fpm_socket}', $fpm_socket, $content); |
1bd269
|
1235 |
$content = str_replace('{fpm_user}', 'ispconfig', $content); |
F |
1236 |
$content = str_replace('{fpm_group}', 'ispconfig', $content); |
|
1237 |
wf($conf['nginx']['php_fpm_pool_dir'].'/ispconfig.conf', $content); |
|
1238 |
|
|
1239 |
//copy('tpl/nginx_ispconfig.vhost.master', $vhost_conf_dir.'/ispconfig.vhost'); |
|
1240 |
//* and create the symlink |
7e1cfb
|
1241 |
if($this->is_update == false) { |
1bd269
|
1242 |
if(@is_link($vhost_conf_enabled_dir.'/ispconfig.vhost')) unlink($vhost_conf_enabled_dir.'/ispconfig.vhost'); |
F |
1243 |
if(!@is_link($vhost_conf_enabled_dir.'/000-ispconfig.vhost')) { |
b1a6a5
|
1244 |
symlink($vhost_conf_dir.'/ispconfig.vhost', $vhost_conf_enabled_dir.'/000-ispconfig.vhost'); |
1bd269
|
1245 |
} |
76f197
|
1246 |
} |
b1a6a5
|
1247 |
|
3b273a
|
1248 |
// create symlink from /usr/share/phpmyadmin to /usr/share/phpMyAdmin, if it is installed |
b1a6a5
|
1249 |
if(!@file_exists('/usr/share/phpmyadmin') && @is_dir('/usr/share/phpMyAdmin')) symlink('/usr/share/phpMyAdmin/', '/usr/share/phpmyadmin'); |
0711af
|
1250 |
} |
b1a6a5
|
1251 |
|
0711af
|
1252 |
// Make the Clamav log files readable by ISPConfig |
T |
1253 |
//exec('chmod +r /var/log/clamav/clamav.log'); |
|
1254 |
//exec('chmod +r /var/log/clamav/freshclam.log'); |
b1a6a5
|
1255 |
|
66768a
|
1256 |
//* Install the update script |
b34f99
|
1257 |
if(is_file('/usr/local/bin/ispconfig_update_from_dev.sh')) unlink('/usr/local/bin/ispconfig_update_from_dev.sh'); |
MC |
1258 |
exec('chown root /usr/local/ispconfig/server/scripts/update_from_dev.sh'); |
|
1259 |
exec('chmod 700 /usr/local/ispconfig/server/scripts/update_from_dev.sh'); |
66768a
|
1260 |
exec('chown root /usr/local/ispconfig/server/scripts/update_from_tgz.sh'); |
T |
1261 |
exec('chmod 700 /usr/local/ispconfig/server/scripts/update_from_tgz.sh'); |
|
1262 |
exec('chown root /usr/local/ispconfig/server/scripts/ispconfig_update.sh'); |
|
1263 |
exec('chmod 700 /usr/local/ispconfig/server/scripts/ispconfig_update.sh'); |
b34f99
|
1264 |
if(!is_link('/usr/local/bin/ispconfig_update_from_dev.sh')) exec('ln -s /usr/local/ispconfig/server/scripts/ispconfig_update.sh /usr/local/bin/ispconfig_update_from_dev.sh'); |
608a8c
|
1265 |
if(!is_link('/usr/local/bin/ispconfig_update.sh')) exec('ln -s /usr/local/ispconfig/server/scripts/ispconfig_update.sh /usr/local/bin/ispconfig_update.sh'); |
b1a6a5
|
1266 |
|
76f197
|
1267 |
// set the fast cgi starter script to executable |
T |
1268 |
// exec('chmod 755 '.$install_dir.'/interface/bin/php-fcgi'); |
b1a6a5
|
1269 |
|
0711af
|
1270 |
//* Make the logs readable for the ispconfig user |
T |
1271 |
if(@is_file('/var/log/maillog')) exec('chmod +r /var/log/maillog'); |
|
1272 |
//if(@is_file('/var/log/mail.warn')) exec('chmod +r /var/log/mail.warn'); |
|
1273 |
//if(@is_file('/var/log/mail.err')) exec('chmod +r /var/log/mail.err'); |
|
1274 |
if(@is_file('/var/log/messages')) exec('chmod +r /var/log/messages'); |
b1a6a5
|
1275 |
|
0711af
|
1276 |
//To enable apache to read the directories |
T |
1277 |
// exec('chmod a+rx /usr/local/ispconfig'); |
|
1278 |
// exec('chmod -R 751 /usr/local/ispconfig/interface'); |
|
1279 |
// exec('chmod a+rx /usr/local/ispconfig/interface/web'); |
b1a6a5
|
1280 |
|
d9c8a7
|
1281 |
//* Create the ispconfig log directory |
e38d14
|
1282 |
if(!is_dir($conf['ispconfig_log_dir'])) mkdir($conf['ispconfig_log_dir']); |
J |
1283 |
if(!is_file($conf['ispconfig_log_dir'].'/ispconfig.log')) exec('touch '.$conf['ispconfig_log_dir'].'/ispconfig.log'); |
b1a6a5
|
1284 |
|
0c5b42
|
1285 |
if(is_user('getmail')) { |
T |
1286 |
exec('mv /usr/local/ispconfig/server/scripts/run-getmail.sh /usr/local/bin/run-getmail.sh'); |
|
1287 |
exec('chown getmail /usr/local/bin/run-getmail.sh'); |
|
1288 |
exec('chmod 744 /usr/local/bin/run-getmail.sh'); |
|
1289 |
} |
b1a6a5
|
1290 |
|
9f56bd
|
1291 |
// Edit the file Edit the file /etc/sudoers and comment out the requiregetty line, otherwise the backup function will fail |
b1a6a5
|
1292 |
replaceLine('/etc/sudoers', 'Defaults requiretty', '#Defaults requiretty', 0, 0); |
MC |
1293 |
|
8cf78b
|
1294 |
if(is_dir($install_dir.'/interface/invoices')) { |
e94a9f
|
1295 |
exec('chmod -R 770 '.escapeshellarg($install_dir.'/interface/invoices')); |
T |
1296 |
exec('chown -R ispconfig:ispconfig '.escapeshellarg($install_dir.'/interface/invoices')); |
edf806
|
1297 |
} |
b1a6a5
|
1298 |
|
0799f8
|
1299 |
//* Create the ispconfig auth log file and set uid/gid |
T |
1300 |
if(!is_file($conf['ispconfig_log_dir'].'/auth.log')) { |
|
1301 |
touch($conf['ispconfig_log_dir'].'/auth.log'); |
|
1302 |
} |
|
1303 |
exec('chown ispconfig:ispconfig '. $conf['ispconfig_log_dir'].'/auth.log'); |
|
1304 |
exec('chmod 660 '. $conf['ispconfig_log_dir'].'/auth.log'); |
b1a6a5
|
1305 |
|
d71bae
|
1306 |
//* Remove Domain module as its functions are available in the client module now |
T |
1307 |
if(@is_dir('/usr/local/ispconfig/interface/web/domain')) exec('rm -rf /usr/local/ispconfig/interface/web/domain'); |
021aec
|
1308 |
|
TB |
1309 |
// Add symlink for patch tool |
|
1310 |
if(!is_link('/usr/local/bin/ispconfig_patch')) exec('ln -s /usr/local/ispconfig/server/scripts/ispconfig_patch /usr/local/bin/ispconfig_patch'); |
c83951
|
1311 |
|
TB |
1312 |
// Change mode of a few files from amavisd |
|
1313 |
if(is_file($conf['amavis']['config_dir'].'/conf.d/50-user')) chmod($conf['amavis']['config_dir'].'/conf.d/50-user', 0640); |
|
1314 |
if(is_file($conf['amavis']['config_dir'].'/50-user~')) chmod($conf['amavis']['config_dir'].'/50-user~', 0400); |
|
1315 |
if(is_file($conf['amavis']['config_dir'].'/amavisd.conf')) chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0640); |
|
1316 |
if(is_file($conf['amavis']['config_dir'].'/amavisd.conf~')) chmod($conf['amavis']['config_dir'].'/amavisd.conf~', 0400); |
0711af
|
1317 |
} |
T |
1318 |
} |
|
1319 |
|
fd4cfd
|
1320 |
?> |