commit | author | age
|
9200ad
|
1 |
<?php |
T |
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_base { |
|
32 |
|
|
33 |
var $wb = array(); |
|
34 |
var $language = 'en'; |
|
35 |
var $db; |
cc3fb3
|
36 |
public $conf; |
ca5291
|
37 |
public $install_ispconfig_interface = true; |
09e141
|
38 |
|
P |
39 |
|
32814e
|
40 |
public function __construct() |
5133cc
|
41 |
{ |
b0a1cc
|
42 |
global $conf; //TODO: maybe $conf should be passed to constructor |
P |
43 |
$this->conf = $conf; |
5133cc
|
44 |
} |
9200ad
|
45 |
|
4f7028
|
46 |
//: TODO Implement the translation function and language files for the installer. |
32814e
|
47 |
public function lng($text) |
P |
48 |
{ |
ce9544
|
49 |
return $text; |
9200ad
|
50 |
} |
T |
51 |
|
32814e
|
52 |
public function error($msg) |
P |
53 |
{ |
9200ad
|
54 |
die("ERROR: ".$msg."\n"); |
T |
55 |
} |
|
56 |
|
32814e
|
57 |
public function simple_query($query, $answers, $default) |
P |
58 |
{ |
ce9544
|
59 |
$finished = false; |
T |
60 |
do { |
32814e
|
61 |
$answers_str = implode(',', $answers); |
239ce8
|
62 |
swrite($this->lng($query).' ('.$answers_str.') ['.$default.']: '); |
ce9544
|
63 |
$input = sread(); |
T |
64 |
|
32814e
|
65 |
//* Stop the installation |
ce9544
|
66 |
if($input == 'quit') { |
32814e
|
67 |
swriteln($this->lng("Installation terminated by user.\n")); |
239ce8
|
68 |
die(); |
ce9544
|
69 |
} |
T |
70 |
|
32814e
|
71 |
//* Select the default |
ce9544
|
72 |
if($input == '') { |
T |
73 |
$answer = $default; |
|
74 |
$finished = true; |
|
75 |
} |
|
76 |
|
32814e
|
77 |
//* Set answer id valid |
P |
78 |
if(in_array($input, $answers)) { |
ce9544
|
79 |
$answer = $input; |
T |
80 |
$finished = true; |
|
81 |
} |
|
82 |
|
|
83 |
} while ($finished == false); |
239ce8
|
84 |
swriteln(); |
ce9544
|
85 |
return $answer; |
T |
86 |
} |
|
87 |
|
32814e
|
88 |
public function free_query($query,$default) |
P |
89 |
{ |
239ce8
|
90 |
swrite($this->lng($query).' ['.$default.']: '); |
ce9544
|
91 |
$input = sread(); |
T |
92 |
|
32814e
|
93 |
//* Stop the installation |
ce9544
|
94 |
if($input == 'quit') { |
32814e
|
95 |
swriteln($this->lng("Installation terminated by user.\n")); |
P |
96 |
die(); |
ce9544
|
97 |
} |
T |
98 |
|
32814e
|
99 |
$answer = ($input == '') ? $default : $input; |
239ce8
|
100 |
swriteln(); |
ce9544
|
101 |
return $answer; |
T |
102 |
} |
|
103 |
|
1b063e
|
104 |
/* |
32814e
|
105 |
// TODO: this function is not used atmo I think - pedro |
P |
106 |
function request_language(){ |
9200ad
|
107 |
|
T |
108 |
swriteln(lng('Enter your language')); |
|
109 |
swriteln(lng('de, en')); |
|
110 |
|
|
111 |
} |
1b063e
|
112 |
*/ |
9200ad
|
113 |
|
facccb
|
114 |
/** Create the database for ISPConfig */ |
P |
115 |
public function configure_database() |
|
116 |
{ |
9200ad
|
117 |
global $conf; |
facccb
|
118 |
$cf = $conf['mysql']; // make $conf['mysql'] more accessible |
P |
119 |
//** Create the database |
|
120 |
if(!$this->db->query('CREATE DATABASE IF NOT EXISTS '.$cf['database'])) { |
|
121 |
$this->error('Unable to create MySQL database: '.$cf['database'].'.'); |
9200ad
|
122 |
} |
T |
123 |
|
facccb
|
124 |
//* Set the database name in the DB library |
P |
125 |
$this->db->dbName = $cf['database']; |
9200ad
|
126 |
|
facccb
|
127 |
//* Load the database dump into the database, if database contains no tables |
9200ad
|
128 |
$db_tables = $this->db->getTables(); |
T |
129 |
if(count($db_tables) > 0) { |
66b4f9
|
130 |
$this->error('Stopped: Database already contains some tables.'); |
9200ad
|
131 |
} else { |
facccb
|
132 |
if($cf['admin_password'] == '') { |
P |
133 |
caselog("mysql -h '".$cf['host']."' -u '".$cf['admin_user']."' '".$cf['database']."' < 'sql/ispconfig3.sql' &> /dev/null", |
66b4f9
|
134 |
__FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql'); |
9200ad
|
135 |
} else { |
facccb
|
136 |
caselog("mysql -h '".$cf['host']."' -u '".$cf['admin_user']."' -p'".$cf['admin_password']."' '".$cf['database']."' < 'sql/ispconfig3.sql' &> /dev/null", |
66b4f9
|
137 |
__FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql'); |
9200ad
|
138 |
} |
T |
139 |
$db_tables = $this->db->getTables(); |
|
140 |
if(count($db_tables) == 0) { |
|
141 |
$this->error('Unable to load SQL-Dump into database table.'); |
|
142 |
} |
|
143 |
} |
|
144 |
} |
|
145 |
|
4f7028
|
146 |
//** Create the server record in the database |
94411b
|
147 |
public function add_database_server_record() { |
7bd4b4
|
148 |
|
T |
149 |
global $conf; |
|
150 |
$cf = $conf['mysql']; // make $conf['mysql'] more accessible |
|
151 |
|
ac4a37
|
152 |
if($cf['host'] == 'localhost') { |
T |
153 |
$from_host = 'localhost'; |
|
154 |
} else { |
6380a8
|
155 |
$from_host = $this->conf['hostname']; |
ac4a37
|
156 |
} |
T |
157 |
|
7bd4b4
|
158 |
//* Create the ISPConfig database user |
T |
159 |
$query = 'GRANT SELECT, INSERT, UPDATE, DELETE ON '.$cf['database'].".* " |
ac4a37
|
160 |
."TO '".$cf['ispconfig_user']."'@'".$from_host."' " |
7bd4b4
|
161 |
."IDENTIFIED BY '".$cf['ispconfig_password']."';"; |
T |
162 |
if(!$this->db->query($query)) { |
|
163 |
$this->error('Unable to create database user: '.$cf['ispconfig_user']); |
|
164 |
} |
|
165 |
|
|
166 |
//* Reload database privelages |
|
167 |
$this->db->query('FLUSH PRIVILEGES;'); |
|
168 |
|
a768b9
|
169 |
//* Set the database name in the DB library |
T |
170 |
$this->db->dbName = $cf['database']; |
94411b
|
171 |
|
d4c9b3
|
172 |
$server_ini_content = rf("tpl/server.ini.master"); |
T |
173 |
$server_ini_content = addslashes($server_ini_content); |
94411b
|
174 |
|
3341c7
|
175 |
$sql = "INSERT INTO `server` (`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`) VALUES (1, 1, 'riud', 'riud', 'r', 'Server', 1, 1, 1, 1, 1, 1, '$server_ini_content', 0, 1);"; |
94411b
|
176 |
$this->db->query($sql); |
a768b9
|
177 |
$conf['server_id'] = $this->db->insertID(); |
T |
178 |
$this->conf['server_id'] = $conf['server_id']; |
94411b
|
179 |
} |
T |
180 |
|
b41692
|
181 |
|
09e141
|
182 |
//** writes postfix configuration files |
b41692
|
183 |
private function process_postfix_config($configfile) |
P |
184 |
{ |
cc3fb3
|
185 |
$config_dir = $this->conf['postfix']['config_dir'].'/'; |
b41692
|
186 |
$full_file_name = $config_dir.$configfile; |
P |
187 |
//* Backup exiting file |
|
188 |
if(is_file($full_file_name)){ |
|
189 |
copy($full_file_name, $config_dir.$configfile.'~'); |
|
190 |
} |
|
191 |
$content = rf('tpl/'.$configfile.'.master'); |
|
192 |
$content = str_replace('{mysql_server_ispconfig_user}', $this->conf['mysql']['ispconfig_user'], $content); |
|
193 |
$content = str_replace('{mysql_server_ispconfig_password}', $this->conf['mysql']['ispconfig_password'], $content); |
|
194 |
$content = str_replace('{mysql_server_database}', $this->conf['mysql']['database'], $content); |
|
195 |
$content = str_replace('{mysql_server_ip}', $this->conf['mysql']['ip'], $content); |
|
196 |
$content = str_replace('{server_id}', $this->conf['server_id'], $content); |
|
197 |
wf($full_file_name, $content); |
|
198 |
} |
|
199 |
|
61d290
|
200 |
public function configure_jailkit() |
D |
201 |
{ |
|
202 |
$cf = $this->conf['jailkit']; |
|
203 |
$config_dir = $cf['config_dir']; |
|
204 |
$jk_init = $cf['jk_init']; |
|
205 |
$jk_chrootsh = $cf['jk_chrootsh']; |
|
206 |
|
3e8065
|
207 |
if (is_dir($config_dir)) |
61d290
|
208 |
{ |
fad1df
|
209 |
if(is_file($config_dir.'/'.$jk_init)) copy($config_dir.'/'.$jk_init, $config_dir.'/'.$jk_init.'~'); |
T |
210 |
if(is_file($config_dir.'/'.$jk_chrootsh.".master")) copy($config_dir.'/'.$jk_chrootsh.".master", $config_dir.'/'.$jk_chrootsh.'~'); |
61d290
|
211 |
|
D |
212 |
copy('tpl/'.$jk_init.".master", $config_dir.'/'.$jk_init); |
|
213 |
copy('tpl/'.$jk_chrootsh.".master", $config_dir.'/'.$jk_chrootsh); |
|
214 |
} |
|
215 |
|
|
216 |
} |
|
217 |
|
b41692
|
218 |
public function configure_postfix($options = '') |
P |
219 |
{ |
cc3fb3
|
220 |
$cf = $this->conf['postfix']; |
77ab0a
|
221 |
$config_dir = $cf['config_dir']; |
P |
222 |
|
b41692
|
223 |
if(!is_dir($config_dir)){ |
P |
224 |
$this->error("The postfix configuration directory '$config_dir' does not exist."); |
|
225 |
} |
|
226 |
|
|
227 |
//* mysql-virtual_domains.cf |
|
228 |
$this->process_postfix_config('mysql-virtual_domains.cf'); |
|
229 |
|
|
230 |
//* mysql-virtual_forwardings.cf |
|
231 |
$this->process_postfix_config('mysql-virtual_forwardings.cf'); |
|
232 |
|
|
233 |
//* mysql-virtual_mailboxes.cf |
|
234 |
$this->process_postfix_config('mysql-virtual_mailboxes.cf'); |
|
235 |
|
|
236 |
//* mysql-virtual_email2email.cf |
|
237 |
$this->process_postfix_config('mysql-virtual_email2email.cf'); |
|
238 |
|
|
239 |
//* mysql-virtual_transports.cf |
|
240 |
$this->process_postfix_config('mysql-virtual_transports.cf'); |
|
241 |
|
|
242 |
//* mysql-virtual_recipient.cf |
|
243 |
$this->process_postfix_config('mysql-virtual_recipient.cf'); |
|
244 |
|
|
245 |
//* mysql-virtual_sender.cf |
|
246 |
$this->process_postfix_config('mysql-virtual_sender.cf'); |
|
247 |
|
|
248 |
//* mysql-virtual_client.cf |
|
249 |
$this->process_postfix_config('mysql-virtual_client.cf'); |
5bf366
|
250 |
|
T |
251 |
//* mysql-virtual_relaydomains.cf |
|
252 |
$this->process_postfix_config('mysql-virtual_relaydomains.cf'); |
b41692
|
253 |
|
P |
254 |
//* Changing mode and group of the new created config files. |
77ab0a
|
255 |
caselog('chmod o= '.$config_dir.'/mysql-virtual_*.cf* &> /dev/null', |
P |
256 |
__FILE__, __LINE__, 'chmod on mysql-virtual_*.cf*', 'chmod on mysql-virtual_*.cf* failed'); |
|
257 |
caselog('chgrp '.$cf['group'].' '.$config_dir.'/mysql-virtual_*.cf* &> /dev/null', |
|
258 |
__FILE__, __LINE__, 'chgrp on mysql-virtual_*.cf*', 'chgrp on mysql-virtual_*.cf* failed'); |
9200ad
|
259 |
|
77ab0a
|
260 |
//* Creating virtual mail user and group |
P |
261 |
$command = 'groupadd -g '.$cf['vmail_groupid'].' '.$cf['vmail_groupname']; |
|
262 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
263 |
|
|
264 |
$command = 'useradd -g '.$cf['vmail_groupname'].' -u '.$cf['vmail_userid'].' '.$cf['vmail_username'].' -d '.$cf['vmail_mailbox_base'].' -m'; |
|
265 |
caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
9200ad
|
266 |
|
T |
267 |
$postconf_commands = array ( |
77ab0a
|
268 |
'myhostname = '.$this->conf['hostname'], |
P |
269 |
'mydestination = '.$this->conf['hostname'].', localhost, localhost.localdomain', |
9200ad
|
270 |
'mynetworks = 127.0.0.0/8', |
T |
271 |
'virtual_alias_domains =', |
438d9f
|
272 |
'virtual_alias_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_forwardings.cf, mysql:'.$config_dir.'/mysql-virtual_email2email.cf', |
P |
273 |
'virtual_mailbox_domains = proxy:mysql:'.$config_dir.'/mysql-virtual_domains.cf', |
77ab0a
|
274 |
'virtual_mailbox_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_mailboxes.cf', |
P |
275 |
'virtual_mailbox_base = '.$cf['vmail_mailbox_base'], |
|
276 |
'virtual_uid_maps = static:'.$cf['vmail_userid'], |
|
277 |
'virtual_gid_maps = static:'.$cf['vmail_groupid'], |
9200ad
|
278 |
'smtpd_sasl_auth_enable = yes', |
T |
279 |
'broken_sasl_auth_clients = yes', |
438d9f
|
280 |
'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:'.$config_dir.'/mysql-virtual_recipient.cf, reject_unauth_destination', |
9200ad
|
281 |
'smtpd_use_tls = yes', |
438d9f
|
282 |
'smtpd_tls_cert_file = '.$config_dir.'/smtpd.cert', |
P |
283 |
'smtpd_tls_key_file = '.$config_dir.'/smtpd.key', |
|
284 |
'transport_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_transports.cf', |
5bf366
|
285 |
'relay_domains = mysql:'.$config_dir.'/mysql-virtual_relaydomains.cf', |
9200ad
|
286 |
'virtual_create_maildirsize = yes', |
T |
287 |
'virtual_mailbox_extended = yes', |
438d9f
|
288 |
'virtual_mailbox_limit_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_mailbox_limit_maps.cf', |
9200ad
|
289 |
'virtual_mailbox_limit_override = yes', |
T |
290 |
'virtual_maildir_limit_message = "The user you are trying to reach is over quota."', |
|
291 |
'virtual_overquota_bounce = yes', |
|
292 |
'proxy_read_maps = $local_recipient_maps $mydestination $virtual_alias_maps $virtual_alias_domains $virtual_mailbox_maps $virtual_mailbox_domains $relay_recipient_maps $relay_domains $canonical_maps $sender_canonical_maps $recipient_canonical_maps $relocated_maps $transport_maps $mynetworks $virtual_mailbox_limit_maps', |
438d9f
|
293 |
'smtpd_sender_restrictions = check_sender_access mysql:'.$config_dir.'/mysql-virtual_sender.cf', |
P |
294 |
'smtpd_client_restrictions = check_client_access mysql:'.$config_dir.'/mysql-virtual_client.cf', |
9200ad
|
295 |
'maildrop_destination_concurrency_limit = 1', |
T |
296 |
'maildrop_destination_recipient_limit = 1', |
54fb59
|
297 |
'virtual_transport = maildrop', |
438d9f
|
298 |
'header_checks = regexp:'.$config_dir.'/header_checks', |
P |
299 |
'mime_header_checks = regexp:'.$config_dir.'/mime_header_checks', |
|
300 |
'nested_header_checks = regexp:'.$config_dir.'/nested_header_checks', |
|
301 |
'body_checks = regexp:'.$config_dir.'/body_checks' |
9200ad
|
302 |
); |
T |
303 |
|
438d9f
|
304 |
//* Create the header and body check files |
P |
305 |
touch($config_dir.'/header_checks'); |
|
306 |
touch($config_dir.'/mime_header_checks'); |
|
307 |
touch($config_dir.'/nested_header_checks'); |
|
308 |
touch($config_dir.'/body_checks'); |
54fb59
|
309 |
|
T |
310 |
|
438d9f
|
311 |
//* Make a backup copy of the main.cf file |
P |
312 |
copy($config_dir.'/main.cf', $config_dir.'/main.cf~'); |
9200ad
|
313 |
|
438d9f
|
314 |
//* Executing the postconf commands |
9200ad
|
315 |
foreach($postconf_commands as $cmd) { |
T |
316 |
$command = "postconf -e '$cmd'"; |
438d9f
|
317 |
caselog($command." &> /dev/null", __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command); |
9200ad
|
318 |
} |
T |
319 |
|
|
320 |
// TODO: Change the master.cf file |
|
321 |
/* |
|
322 |
Add: |
77ab0a
|
323 |
maildrop unix - n n - - pipe |
P |
324 |
flags=R user=vmail argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender} |
9200ad
|
325 |
*/ |
fb7155
|
326 |
if(!stristr($options,'dont-create-certs')) { |
438d9f
|
327 |
//* Create the SSL certificate |
P |
328 |
$command = 'cd '.$config_dir.'; ' |
|
329 |
.'openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout ' |
|
330 |
.'smtpd.key -keyform PEM -days 365 -x509'; |
c58e3f
|
331 |
exec($command); |
9200ad
|
332 |
|
438d9f
|
333 |
$command = 'chmod o= '.$config_dir.'/smtpd.key'; |
P |
334 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command); |
c58e3f
|
335 |
} |
9200ad
|
336 |
|
77ab0a
|
337 |
//** We have to change the permissions of the courier authdaemon directory to make it accessible for maildrop. |
438d9f
|
338 |
$command = 'chmod 755 /var/run/courier/authdaemon/'; |
P |
339 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command); |
9200ad
|
340 |
|
438d9f
|
341 |
//* Changing maildrop lines in posfix master.cf |
P |
342 |
if(is_file($config_dir.'/master.cf')){ |
|
343 |
copy($config_dir.'/master.cf', $config_dir.'/master.cf~'); |
|
344 |
} |
|
345 |
if(is_file($config_dir.'/master.cf~')){ |
|
346 |
exec('chmod 400 '.$config_dir.'/master.cf~'); |
|
347 |
} |
|
348 |
$configfile = $config_dir.'/master.cf'; |
20e642
|
349 |
$content = rf($configfile); |
77ab0a
|
350 |
$content = str_replace(' flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}', |
P |
351 |
' flags=R user='.$cf['vmail_username'].' argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}', |
|
352 |
$content); |
|
353 |
wf($configfile, $content); |
20e642
|
354 |
|
438d9f
|
355 |
//* Writing the Maildrop mailfilter file |
9200ad
|
356 |
$configfile = 'mailfilter'; |
77ab0a
|
357 |
if(is_file($cf['vmail_mailbox_base'].'/.'.$configfile)){ |
P |
358 |
copy($cf['vmail_mailbox_base'].'/.'.$configfile, $cf['vmail_mailbox_base'].'/.'.$configfile.'~'); |
|
359 |
} |
|
360 |
$content = rf("tpl/$configfile.master"); |
|
361 |
$content = str_replace('{dist_postfix_vmail_mailbox_base}', $cf['vmail_mailbox_base'], $content); |
|
362 |
wf($cf['vmail_mailbox_base'].'/.'.$configfile, $content); |
9200ad
|
363 |
|
77ab0a
|
364 |
//* Create the directory for the custom mailfilters |
P |
365 |
$command = 'mkdir '.$cf['vmail_mailbox_base'].'/mailfilters'; |
|
366 |
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
9200ad
|
367 |
|
77ab0a
|
368 |
//* Chmod and chown the .mailfilter file |
P |
369 |
$command = 'chown -R '.$cf['vmail_username'].':'.$cf['vmail_groupname'].' '.$cf['vmail_mailbox_base'].'/.mailfilter'; |
|
370 |
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
9200ad
|
371 |
|
77ab0a
|
372 |
$command = 'chmod -R 600 '.$cf['vmail_mailbox_base'].'/.mailfilter'; |
P |
373 |
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
9200ad
|
374 |
|
T |
375 |
} |
|
376 |
|
|
377 |
function configure_saslauthd() { |
|
378 |
global $conf; |
|
379 |
|
20e642
|
380 |
|
9200ad
|
381 |
$configfile = 'sasl_smtpd.conf'; |
cc3fb3
|
382 |
if(is_file($conf["postfix"]["config_dir"].'/sasl/smtpd.conf')) copy($conf["postfix"]["config_dir"].'/sasl/smtpd.conf',$conf["postfix"]["config_dir"].'/sasl/smtpd.conf~'); |
O |
383 |
if(is_file($conf["postfix"]["config_dir"].'/sasl/smtpd.conf~')) exec('chmod 400 '.$conf["postfix"]["config_dir"].'/sasl/smtpd.conf~'); |
9200ad
|
384 |
$content = rf("tpl/".$configfile.".master"); |
09e141
|
385 |
$content = str_replace('{mysql_server_ispconfig_user}',$this->conf['mysql']['ispconfig_user'],$content); |
P |
386 |
$content = str_replace('{mysql_server_ispconfig_password}',$this->conf['mysql']['ispconfig_password'], $content); |
|
387 |
$content = str_replace('{mysql_server_database}',$this->conf['mysql']['database'],$content); |
|
388 |
$content = str_replace('{mysql_server_ip}',$this->conf['mysql']['ip'],$content); |
cc3fb3
|
389 |
wf($conf["postfix"]["config_dir"].'/sasl/smtpd.conf',$content); |
9200ad
|
390 |
|
T |
391 |
// TODO: Chmod and chown on the config file |
20e642
|
392 |
|
T |
393 |
|
|
394 |
|
|
395 |
// Create the spool directory |
20218c
|
396 |
exec('mkdir -p /var/spool/postfix/var/run/saslauthd'); |
20e642
|
397 |
|
T |
398 |
// Edit the file /etc/default/saslauthd |
cc3fb3
|
399 |
$configfile = $conf["saslauthd"]["config"]; |
20e642
|
400 |
if(is_file($configfile)) copy($configfile,$configfile.'~'); |
e32699
|
401 |
if(is_file($configfile.'~')) exec('chmod 400 '.$configfile.'~'); |
20e642
|
402 |
$content = rf($configfile); |
T |
403 |
$content = str_replace('START=no','START=yes',$content); |
|
404 |
$content = str_replace('OPTIONS="-c"','OPTIONS="-m /var/spool/postfix/var/run/saslauthd -r"',$content); |
|
405 |
wf($configfile,$content); |
|
406 |
|
20218c
|
407 |
// Edit the file /etc/init.d/saslauthd |
cc3fb3
|
408 |
$configfile = $conf["init_scripts"].'/'.$conf["saslauthd"]["init_script"]; |
20e642
|
409 |
$content = rf($configfile); |
T |
410 |
$content = str_replace('PIDFILE=$RUN_DIR/saslauthd.pid','PIDFILE="/var/spool/postfix/var/run/${NAME}/saslauthd.pid"',$content); |
|
411 |
wf($configfile,$content); |
9200ad
|
412 |
|
T |
413 |
|
|
414 |
} |
|
415 |
|
09e141
|
416 |
public function configure_pam() |
P |
417 |
{ |
cc3fb3
|
418 |
$pam = $this->conf['pam']; |
09e141
|
419 |
//* configure pam for SMTP authentication agains the ispconfig database |
9200ad
|
420 |
$configfile = 'pamd_smtp'; |
09e141
|
421 |
if(is_file("$pam/smtp")) copy("$pam/smtp", "$pam/smtp~"); |
P |
422 |
if(is_file("$pam/smtp~")) exec("chmod 400 $pam/smtp~"); |
|
423 |
|
|
424 |
$content = rf("tpl/$configfile.master"); |
|
425 |
$content = str_replace('{mysql_server_ispconfig_user}', $this->conf['mysql']['ispconfig_user'], $content); |
|
426 |
$content = str_replace('{mysql_server_ispconfig_password}', $this->conf['mysql']['ispconfig_password'], $content); |
|
427 |
$content = str_replace('{mysql_server_database}', $this->conf['mysql']['database'], $content); |
|
428 |
$content = str_replace('{mysql_server_ip}', $this->conf['mysql']['ip'], $content); |
|
429 |
wf("$pam/smtp", $content); |
|
430 |
exec("chmod 660 $pam/smtp"); |
|
431 |
exec("chown daemon:daemon $pam/smtp"); |
9200ad
|
432 |
|
T |
433 |
} |
|
434 |
|
09e141
|
435 |
public function configure_courier() |
P |
436 |
{ |
cc3fb3
|
437 |
$config_dir = $this->conf['courier']['config_dir']; |
09e141
|
438 |
//* authmysqlrc |
9200ad
|
439 |
$configfile = 'authmysqlrc'; |
09e141
|
440 |
if(is_file("$config_dir/$configfile")){ |
P |
441 |
copy("$config_dir/$configfile", "$config_dir/$configfile~"); |
|
442 |
} |
|
443 |
exec("chmod 400 $config_dir/$configfile~"); |
|
444 |
$content = rf("tpl/$configfile.master"); |
|
445 |
$content = str_replace('{mysql_server_ispconfig_user}',$this->conf['mysql']['ispconfig_user'],$content); |
|
446 |
$content = str_replace('{mysql_server_ispconfig_password}',$this->conf['mysql']['ispconfig_password'], $content); |
|
447 |
$content = str_replace('{mysql_server_database}',$this->conf['mysql']['database'],$content); |
|
448 |
$content = str_replace('{mysql_server_host}',$this->conf['mysql']['host'],$content); |
|
449 |
wf("$config_dir/$configfile", $content); |
9200ad
|
450 |
|
09e141
|
451 |
exec("chmod 660 $config_dir/$configfile"); |
P |
452 |
exec("chown daemon:daemon $config_dir/$configfile"); |
20e642
|
453 |
|
09e141
|
454 |
//* authdaemonrc |
cc3fb3
|
455 |
$configfile = $this->conf['courier']['config_dir'].'/authdaemonrc'; |
09e141
|
456 |
if(is_file($configfile)){ |
P |
457 |
copy($configfile, $configfile.'~'); |
|
458 |
} |
|
459 |
if(is_file($configfile.'~')){ |
|
460 |
exec('chmod 400 '.$configfile.'~'); |
|
461 |
} |
20e642
|
462 |
$content = rf($configfile); |
09e141
|
463 |
$content = str_replace('authmodulelist="authpam"', 'authmodulelist="authmysql"', $content); |
P |
464 |
wf($configfile, $content); |
9200ad
|
465 |
} |
T |
466 |
|
|
467 |
function configure_amavis() { |
|
468 |
global $conf; |
|
469 |
|
|
470 |
// amavisd user config file |
|
471 |
$configfile = 'amavisd_user_config'; |
cc3fb3
|
472 |
if(is_file($conf["amavis"]["config_dir"].'/conf.d/50-user')) copy($conf["amavis"]["config_dir"].'/conf.d/50-user',$conf["courier"]["config_dir"].'/50-user~'); |
O |
473 |
if(is_file($conf["amavis"]["config_dir"].'/conf.d/50-user~')) exec('chmod 400 '.$conf["amavis"]["config_dir"].'/conf.d/50-user~'); |
9200ad
|
474 |
$content = rf("tpl/".$configfile.".master"); |
09e141
|
475 |
$content = str_replace('{mysql_server_ispconfig_user}',$this->conf['mysql']['ispconfig_user'],$content); |
P |
476 |
$content = str_replace('{mysql_server_ispconfig_password}',$this->conf['mysql']['ispconfig_password'], $content); |
|
477 |
$content = str_replace('{mysql_server_database}',$this->conf['mysql']['database'],$content); |
20218c
|
478 |
$content = str_replace('{mysql_server_port}',$conf["mysql"]["port"],$content); |
09e141
|
479 |
$content = str_replace('{mysql_server_ip}',$this->conf['mysql']['ip'],$content); |
cc3fb3
|
480 |
wf($conf["amavis"]["config_dir"].'/conf.d/50-user',$content); |
9200ad
|
481 |
|
T |
482 |
// TODO: chmod and chown on the config file |
|
483 |
|
|
484 |
|
|
485 |
// Adding the amavisd commands to the postfix configuration |
|
486 |
$postconf_commands = array ( |
|
487 |
'content_filter = amavis:[127.0.0.1]:10024', |
|
488 |
'receive_override_options = no_address_mappings' |
|
489 |
); |
|
490 |
|
|
491 |
// Make a backup copy of the main.cf file |
cc3fb3
|
492 |
copy($conf["postfix"]["config_dir"].'/main.cf',$conf["postfix"]["config_dir"].'/main.cf~2'); |
9200ad
|
493 |
|
T |
494 |
// Executing the postconf commands |
|
495 |
foreach($postconf_commands as $cmd) { |
|
496 |
$command = "postconf -e '$cmd'"; |
76b6b6
|
497 |
caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
9200ad
|
498 |
} |
T |
499 |
|
|
500 |
// Append the configuration for amavisd to the master.cf file |
cc3fb3
|
501 |
if(is_file($conf["postfix"]["config_dir"].'/master.cf')) copy($conf["postfix"]["config_dir"].'/master.cf',$conf["postfix"]["config_dir"].'/master.cf~'); |
9200ad
|
502 |
$content = rf("tpl/master_cf_amavis.master"); |
T |
503 |
// Only add the content if we had not addded it before |
|
504 |
if(!stristr("127.0.0.1:10025 inet n - - - - smtpd",$content)) { |
cc3fb3
|
505 |
af($conf["postfix"]["config_dir"].'/master.cf',$content); |
9200ad
|
506 |
} |
T |
507 |
|
|
508 |
// Add the clamav user to the amavis group |
|
509 |
exec('adduser clamav amavis'); |
|
510 |
|
|
511 |
|
|
512 |
} |
|
513 |
|
77ab0a
|
514 |
public function configure_spamassassin() |
P |
515 |
{ |
09e141
|
516 |
//* Enable spamasasssin on debian and ubuntu |
9200ad
|
517 |
$configfile = '/etc/default/spamassassin'; |
77ab0a
|
518 |
if(is_file($configfile)){ |
09e141
|
519 |
copy($configfile, $configfile.'~'); |
77ab0a
|
520 |
} |
9200ad
|
521 |
$content = rf($configfile); |
77ab0a
|
522 |
$content = str_replace('ENABLED=0', 'ENABLED=1', $content); |
P |
523 |
wf($configfile, $content); |
9200ad
|
524 |
} |
T |
525 |
|
09e141
|
526 |
public function configure_getmail() |
P |
527 |
{ |
cc3fb3
|
528 |
$config_dir = $this->conf['getmail']['config_dir']; |
03ade5
|
529 |
|
T |
530 |
if(!is_dir($config_dir)) exec("mkdir -p ".escapeshellcmd($config_dir)); |
09e141
|
531 |
|
P |
532 |
$command = "useradd -d $config_dir getmail"; |
|
533 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
ba747c
|
534 |
|
09e141
|
535 |
$command = "chown -R getmail $config_dir"; |
P |
536 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
3edf9d
|
537 |
|
09e141
|
538 |
$command = "chmod -R 700 $config_dir"; |
P |
539 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
ba747c
|
540 |
} |
T |
541 |
|
9200ad
|
542 |
|
09e141
|
543 |
public function configure_pureftpd() |
P |
544 |
{ |
7bd4b4
|
545 |
global $conf; |
T |
546 |
|
cc3fb3
|
547 |
$config_dir = $this->conf['pureftpd']['config_dir']; |
09e141
|
548 |
|
P |
549 |
//* configure pam for SMTP authentication agains the ispconfig database |
20218c
|
550 |
$configfile = 'db/mysql.conf'; |
09e141
|
551 |
if(is_file("$config_dir/$configfile")){ |
P |
552 |
copy("$config_dir/$configfile", "$config_dir/$configfile~"); |
|
553 |
} |
|
554 |
if(is_file("$config_dir/$configfile~")){ |
|
555 |
exec("chmod 400 $config_dir/$configfile~"); |
|
556 |
} |
|
557 |
$content = rf('tpl/pureftpd_mysql.conf.master'); |
7bd4b4
|
558 |
$content = str_replace('{mysql_server_ispconfig_user}', $conf["mysql"]["ispconfig_user"], $content); |
T |
559 |
$content = str_replace('{mysql_server_ispconfig_password}', $conf["mysql"]["ispconfig_password"], $content); |
|
560 |
$content = str_replace('{mysql_server_database}', $conf["mysql"]["database"], $content); |
|
561 |
$content = str_replace('{mysql_server_ip}', $conf["mysql"]["ip"], $content); |
|
562 |
$content = str_replace('{server_id}', $conf["server_id"], $content); |
09e141
|
563 |
wf("$config_dir/$configfile", $content); |
P |
564 |
exec("chmod 600 $config_dir/$configfile"); |
|
565 |
exec("chown root:root $config_dir/$configfile"); |
|
566 |
// **enable chrooting |
af8f1b
|
567 |
//exec('mkdir -p '.$config_dir.'/conf/ChrootEveryone'); |
09e141
|
568 |
exec('echo "yes" > '.$config_dir.'/conf/ChrootEveryone'); |
b4c750
|
569 |
} |
T |
570 |
|
09e141
|
571 |
public function configure_mydns() |
P |
572 |
{ |
99d85e
|
573 |
global $conf; |
T |
574 |
|
|
575 |
// configure pam for SMTP authentication agains the ispconfig database |
|
576 |
$configfile = 'mydns.conf'; |
cc3fb3
|
577 |
if(is_file($conf["mydns"]["config_dir"].'/'.$configfile)) copy($conf["mydns"]["config_dir"].'/'.$configfile,$conf["mydns"]["config_dir"].'/'.$configfile.'~'); |
O |
578 |
if(is_file($conf["mydns"]["config_dir"].'/'.$configfile.'~')) exec('chmod 400 '.$conf["mydns"]["config_dir"].'/'.$configfile.'~'); |
99d85e
|
579 |
$content = rf("tpl/".$configfile.".master"); |
7bd4b4
|
580 |
$content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content); |
T |
581 |
$content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content); |
|
582 |
$content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content); |
20218c
|
583 |
$content = str_replace('{mysql_server_host}',$conf["mysql"]["host"],$content); |
99d85e
|
584 |
$content = str_replace('{server_id}',$conf["server_id"],$content); |
cc3fb3
|
585 |
wf($conf["mydns"]["config_dir"].'/'.$configfile,$content); |
O |
586 |
exec('chmod 600 '.$conf["mydns"]["config_dir"].'/'.$configfile); |
|
587 |
exec('chown root:root '.$conf["mydns"]["config_dir"].'/'.$configfile); |
99d85e
|
588 |
|
T |
589 |
} |
|
590 |
|
76b6b6
|
591 |
public function configure_apache() |
P |
592 |
{ |
|
593 |
//* Create the logging directory for the vhost logfiles |
|
594 |
exec('mkdir -p /var/log/ispconfig/httpd'); |
313e33
|
595 |
|
T |
596 |
} |
|
597 |
|
b4c750
|
598 |
|
76b6b6
|
599 |
public function install_ispconfig() |
P |
600 |
{ |
7bd4b4
|
601 |
global $conf; |
T |
602 |
|
76b6b6
|
603 |
$install_dir = $this->conf['ispconfig_install_dir']; |
9200ad
|
604 |
|
76b6b6
|
605 |
//* Create the ISPConfig installation directory |
P |
606 |
$command = "mkdir $install_dir"; |
|
607 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
9200ad
|
608 |
|
76b6b6
|
609 |
//* Create a ISPConfig user and group |
P |
610 |
$command = 'groupadd ispconfig'; |
|
611 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
612 |
|
|
613 |
$command = "useradd -g ispconfig -d $install_dir ispconfig"; |
|
614 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
615 |
|
|
616 |
//* copy the ISPConfig interface part |
|
617 |
$command = "cp -rf ../interface $install_dir"; |
|
618 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
619 |
|
|
620 |
//* copy the ISPConfig server part |
|
621 |
$command = "cp -rf ../server $install_dir"; |
|
622 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
623 |
|
|
624 |
//* Create a symlink, so ISPConfig is accessible via web |
b722a1
|
625 |
// Replaced by a separate vhost definition for port 8080 |
T |
626 |
// $command = "ln -s $install_dir/interface/web/ /var/www/ispconfig"; |
|
627 |
// caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
76b6b6
|
628 |
|
P |
629 |
//* Create the config file for ISPConfig interface |
|
630 |
$configfile = 'config.inc.php'; |
|
631 |
if(is_file($install_dir.'/interface/lib/'.$configfile)){ |
|
632 |
copy("$install_dir/interface/lib/$configfile", "$install_dir/interface/lib/$configfile~"); |
|
633 |
} |
|
634 |
$content = rf("tpl/$configfile.master"); |
7bd4b4
|
635 |
$content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content); |
T |
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); |
76b6b6
|
639 |
wf("$install_dir/interface/lib/$configfile", $content); |
P |
640 |
|
|
641 |
//* Create the config file for ISPConfig server |
|
642 |
$configfile = 'config.inc.php'; |
|
643 |
if(is_file($install_dir.'/server/lib/'.$configfile)){ |
|
644 |
copy("$install_dir/server/lib/$configfile", "$install_dir/interface/lib/$configfile~"); |
|
645 |
} |
|
646 |
$content = rf("tpl/$configfile.master"); |
7bd4b4
|
647 |
$content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content); |
T |
648 |
$content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content); |
|
649 |
$content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content); |
|
650 |
$content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content); |
|
651 |
$content = str_replace('{server_id}', $conf['server_id'], $content); |
76b6b6
|
652 |
wf("$install_dir/server/lib/$configfile", $content); |
P |
653 |
|
710f35
|
654 |
|
1b063e
|
655 |
//* Enable the server modules and plugins. |
T |
656 |
// TODO: Implement a selector which modules and plugins shall be enabled. |
|
657 |
$dir = $install_dir.'/server/mods-available/'; |
|
658 |
if (is_dir($dir)) { |
|
659 |
if ($dh = opendir($dir)) { |
|
660 |
while (($file = readdir($dh)) !== false) { |
|
661 |
if($file != '.' && $file != '..') { |
6a95c8
|
662 |
if(!@is_link($install_dir.'/server/mods-enabled/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-enabled/'.$file); |
1b063e
|
663 |
} |
T |
664 |
} |
|
665 |
closedir($dh); |
|
666 |
} |
|
667 |
} |
|
668 |
|
|
669 |
$dir = $install_dir.'/server/plugins-available/'; |
|
670 |
if (is_dir($dir)) { |
|
671 |
if ($dh = opendir($dir)) { |
|
672 |
while (($file = readdir($dh)) !== false) { |
|
673 |
if($file != '.' && $file != '..') { |
6a95c8
|
674 |
if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file); |
1b063e
|
675 |
} |
T |
676 |
} |
|
677 |
closedir($dh); |
|
678 |
} |
|
679 |
} |
76b6b6
|
680 |
|
P |
681 |
//* Chmod the files |
|
682 |
$command = "chmod -R 750 $install_dir"; |
|
683 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
684 |
|
|
685 |
//* chown the files to the ispconfig user and group |
|
686 |
$command = "chown -R ispconfig:ispconfig $install_dir"; |
|
687 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
|
688 |
|
710f35
|
689 |
//* Make the global language file directory group writable |
f3e2f0
|
690 |
exec("chmod -R 770 $install_dir/interface/lib/lang"); |
710f35
|
691 |
|
1e2414
|
692 |
//* Make the temp directory for language file exports writable |
T |
693 |
exec("chmod -R 770 $install_dir/interface/web/temp"); |
|
694 |
|
710f35
|
695 |
//* Make all interface language file directories group writable |
T |
696 |
$handle = @opendir($install_dir.'/interface/web'); |
|
697 |
while ($file = @readdir ($handle)) { |
|
698 |
if ($file != '.' && $file != '..') { |
|
699 |
if(@is_dir($install_dir.'/interface/web'.'/'.$file.'/lib/lang')) { |
|
700 |
$handle2 = opendir($install_dir.'/interface/web'.'/'.$file.'/lib/lang'); |
f3e2f0
|
701 |
chmod($install_dir.'/interface/web'.'/'.$file.'/lib/lang',0770); |
710f35
|
702 |
while ($lang_file = @readdir ($handle2)) { |
T |
703 |
if ($lang_file != '.' && $lang_file != '..') { |
f3e2f0
|
704 |
chmod($install_dir.'/interface/web'.'/'.$file.'/lib/lang/'.$lang_file,0770); |
710f35
|
705 |
} |
T |
706 |
} |
|
707 |
} |
|
708 |
} |
|
709 |
} |
|
710 |
|
76b6b6
|
711 |
//* make sure that the server config file (not the interface one) is only readable by the root user |
P |
712 |
exec("chmod 600 $install_dir/server/lib/$configfile"); |
|
713 |
exec("chown root:root $install_dir/server/lib/$configfile"); |
2e1086
|
714 |
|
9200ad
|
715 |
// TODO: FIXME: add the www-data user to the ispconfig group. This is just for testing |
T |
716 |
// and must be fixed as this will allow the apache user to read the ispconfig files. |
|
717 |
// Later this must run as own apache server or via suexec! |
76b6b6
|
718 |
$command = 'adduser www-data ispconfig'; |
P |
719 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
9200ad
|
720 |
|
76b6b6
|
721 |
//* Make the shell scripts executable |
P |
722 |
$command = "chmod +x $install_dir/server/scripts/*.sh"; |
|
723 |
caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command"); |
9200ad
|
724 |
|
76b6b6
|
725 |
//* Copy the ISPConfig vhost for the controlpanel |
1b063e
|
726 |
// TODO: These are missing! should they be "vhost_dist_*_dir" ? |
cc3fb3
|
727 |
$vhost_conf_dir = $this->conf['apache']['vhost_conf_dir']; |
O |
728 |
$vhost_conf_enabled_dir = $this->conf['apache']['vhost_conf_enabled_dir']; |
9b9ba4
|
729 |
|
D |
730 |
|
|
731 |
// Dont just copy over the virtualhost template but add some custom settings |
|
732 |
|
|
733 |
$content = rf("tpl/apache_ispconfig.vhost.master"); |
9ac95d
|
734 |
$content = str_replace('{vhost_port}', $this->conf['apache']['vhost_port'], $content); |
9b9ba4
|
735 |
wf("$vhost_conf_dir/ispconfig.vhost", $content); |
D |
736 |
|
|
737 |
//copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost"); |
76b6b6
|
738 |
//* and create the symlink |
ac4a37
|
739 |
if($this->install_ispconfig_interface == true) { |
T |
740 |
if(!is_link("$vhost_conf_enabled_dir/ispconfig.vhost")) { |
|
741 |
exec("ln -s $vhost_conf_dir/ispconfig.vhost $vhost_conf_enabled_dir/ispconfig.vhost"); |
|
742 |
} |
a35764
|
743 |
} |
bc41bb
|
744 |
|
T |
745 |
// Make the Clamav log files readable by ISPConfig |
|
746 |
exec('chmod +r /var/log/clamav/clamav.log'); |
|
747 |
exec('chmod +r /var/log/clamav/freshclam.log'); |
83994b
|
748 |
|
T |
749 |
//* Install the SVN update script |
|
750 |
exec('cp ../helper_scripts/update_from_svn.sh /usr/local/bin/ispconfig_update_from_svn.sh'); |
|
751 |
exec('chown root /usr/local/bin/ispconfig_update_from_svn.sh'); |
|
752 |
exec('chmod 700 /usr/local/bin/ispconfig_update_from_svn.sh'); |
|
753 |
|
a014c2
|
754 |
//set the fast cgi starter script to executable |
D |
755 |
exec('chmod 755 '.$install_dir.'/interface/bin/php-fcgi'); |
9200ad
|
756 |
} |
T |
757 |
|
76b6b6
|
758 |
public function install_crontab() |
5d54be
|
759 |
{ |
P |
760 |
//* Root Crontab |
|
761 |
exec('crontab -u root -l > crontab.txt'); |
daff5c
|
762 |
$existing_root_cron_jobs = file('crontab.txt'); |
T |
763 |
|
30aa08
|
764 |
$root_cron_jobs = array( |
T |
765 |
'* * * * * /usr/local/ispconfig/server/server.sh &> /dev/null', |
|
766 |
'30 00 * * * /usr/local/ispconfig/server/cron_daily.sh &> /dev/null' |
|
767 |
); |
daff5c
|
768 |
foreach($root_cron_jobs as $cron_job) { |
5d54be
|
769 |
if(!in_array($cron_job."\n", $existing_root_cron_jobs)) { |
daff5c
|
770 |
$existing_root_cron_jobs[] = $cron_job."\n"; |
T |
771 |
} |
|
772 |
} |
5d54be
|
773 |
file_put_contents('crontab.txt', $existing_root_cron_jobs); |
P |
774 |
exec('crontab -u root crontab.txt &> /dev/null'); |
daff5c
|
775 |
unlink('crontab.txt'); |
T |
776 |
|
5d54be
|
777 |
//* Getmail crontab |
cc3fb3
|
778 |
$cf = $this->conf['getmail']; |
5d54be
|
779 |
exec('crontab -u getmail -l > crontab.txt'); |
daff5c
|
780 |
$existing_cron_jobs = file('crontab.txt'); |
T |
781 |
|
5d54be
|
782 |
$cron_jobs = array('*/5 * * * * '.$cf['program'].' -g '.$cf['config_dir'].' -r '.$cf['config_dir'].'/*.conf &> /dev/null'); |
daff5c
|
783 |
foreach($cron_jobs as $cron_job) { |
5d54be
|
784 |
if(!in_array($cron_job."\n", $existing_cron_jobs)) { |
daff5c
|
785 |
$existing_cron_jobs[] = $cron_job."\n"; |
T |
786 |
} |
|
787 |
} |
5d54be
|
788 |
file_put_contents('crontab.txt', $existing_cron_jobs); |
P |
789 |
exec('crontab -u getmail crontab.txt &> /dev/null'); |
daff5c
|
790 |
unlink('crontab.txt'); |
T |
791 |
} |
9200ad
|
792 |
|
T |
793 |
} |
|
794 |
|
5d54be
|
795 |
?> |