tbrehm
2009-03-25 5456caa51870bfdecfce4637bab5f4991c7e66d9
commit | author | age
8e5788 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_dist extends installer_base {
32     
33     function configure_postfix($options = '')
34     {
35         global $conf;
36         $cf = $conf['postfix'];
37         $config_dir = $cf['config_dir'];
38         
39         if(!is_dir($config_dir)){
40             $this->error("The postfix configuration directory '$config_dir' does not exist.");
41         }
42         
43         //* mysql-virtual_domains.cf
44         $this->process_postfix_config('mysql-virtual_domains.cf');
45
46         //* mysql-virtual_forwardings.cf
47         $this->process_postfix_config('mysql-virtual_forwardings.cf');
48
49         //* mysql-virtual_mailboxes.cf
50         $this->process_postfix_config('mysql-virtual_mailboxes.cf');
51
52         //* mysql-virtual_email2email.cf
53         $this->process_postfix_config('mysql-virtual_email2email.cf');
54
55         //* mysql-virtual_transports.cf
56         $this->process_postfix_config('mysql-virtual_transports.cf');
57
58         //* mysql-virtual_recipient.cf
59         $this->process_postfix_config('mysql-virtual_recipient.cf');
60
61         //* mysql-virtual_sender.cf
62         $this->process_postfix_config('mysql-virtual_sender.cf');
63
64         //* mysql-virtual_client.cf
65         $this->process_postfix_config('mysql-virtual_client.cf');
66         
67         //* mysql-virtual_relaydomains.cf
68         $this->process_postfix_config('mysql-virtual_relaydomains.cf');
69
70         //* Changing mode and group of the new created config files.
71         caselog('chmod o= '.$config_dir.'/mysql-virtual_*.cf* &> /dev/null',
72                  __FILE__, __LINE__, 'chmod on mysql-virtual_*.cf*', 'chmod on mysql-virtual_*.cf* failed');
73         caselog('chgrp '.$cf['group'].' '.$config_dir.'/mysql-virtual_*.cf* &> /dev/null', 
74                 __FILE__, __LINE__, 'chgrp on mysql-virtual_*.cf*', 'chgrp on mysql-virtual_*.cf* failed');
75         
76         //* Creating virtual mail user and group
77         $command = 'groupadd -g '.$cf['vmail_groupid'].' '.$cf['vmail_groupname'];
78         if(!is_group($cf['vmail_groupname'])) caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
79
80         $command = 'useradd -g '.$cf['vmail_groupname'].' -u '.$cf['vmail_userid'].' '.$cf['vmail_username'].' -d '.$cf['vmail_mailbox_base'].' -m';
81         if(!is_user($cf['vmail_username'])) caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");        
82
83         $postconf_commands = array (
84             'myhostname = '.$conf['hostname'],
85             'mydestination = '.$conf['hostname'].', localhost, localhost.localdomain',
86             'mynetworks = 127.0.0.0/8',
87             'virtual_alias_domains =',
88             'virtual_alias_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_forwardings.cf, mysql:'.$config_dir.'/mysql-virtual_email2email.cf',
89             'virtual_mailbox_domains = proxy:mysql:'.$config_dir.'/mysql-virtual_domains.cf',
90             'virtual_mailbox_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_mailboxes.cf',
91             'virtual_mailbox_base = '.$cf['vmail_mailbox_base'],
92             'virtual_uid_maps = static:'.$cf['vmail_userid'],
93             'virtual_gid_maps = static:'.$cf['vmail_groupid'],
94             'smtpd_sasl_auth_enable = yes',
95             'broken_sasl_auth_clients = yes',
96             'smtpd_sasl_authenticated_header = yes',
97             'smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, check_recipient_access mysql:'.$config_dir.'/mysql-virtual_recipient.cf, reject_unauth_destination',
98             'smtpd_use_tls = yes',
99             'smtpd_tls_security_level = may',
100             'smtpd_tls_cert_file = '.$config_dir.'/smtpd.cert',
101             'smtpd_tls_key_file = '.$config_dir.'/smtpd.key',
102             'transport_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_transports.cf',
103             'relay_domains = mysql:'.$config_dir.'/mysql-virtual_relaydomains.cf',
104             'virtual_create_maildirsize = yes',
105             'virtual_maildir_extended = yes',
106             'virtual_mailbox_limit_maps = proxy:mysql:'.$config_dir.'/mysql-virtual_mailbox_limit_maps.cf',
107             'virtual_mailbox_limit_override = yes',
108             'virtual_maildir_limit_message = "The user you are trying to reach is over quota."',
109             'virtual_overquota_bounce = yes',
110             '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',
111             'smtpd_sender_restrictions = check_sender_access mysql:'.$config_dir.'/mysql-virtual_sender.cf',
112             'smtpd_client_restrictions = check_client_access mysql:'.$config_dir.'/mysql-virtual_client.cf',
113             'maildrop_destination_concurrency_limit = 1',
114             'maildrop_destination_recipient_limit   = 1',
115             'virtual_transport = maildrop',
116             'header_checks = regexp:'.$config_dir.'/header_checks',
117             'mime_header_checks = regexp:'.$config_dir.'/mime_header_checks',
118             'nested_header_checks = regexp:'.$config_dir.'/nested_header_checks',
119             'body_checks = regexp:'.$config_dir.'/body_checks',
120             'inet_interfaces = all'
121         );
122         
123         //* Create the header and body check files
124         touch($config_dir.'/header_checks');
125         touch($config_dir.'/mime_header_checks');
126         touch($config_dir.'/nested_header_checks');
127         touch($config_dir.'/body_checks');
128         
129         
130         //* Make a backup copy of the main.cf file
131         copy($config_dir.'/main.cf', $config_dir.'/main.cf~');
132         
133         //* Executing the postconf commands
134         foreach($postconf_commands as $cmd) {
135             $command = "postconf -e '$cmd'";
136             caselog($command." &> /dev/null", __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command);
137         }
138         
139         if(!stristr($options,'dont-create-certs')) {
140             //* Create the SSL certificate
141             $command = 'cd '.$config_dir.'; '
142                       .'openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM -days 365 -x509';
143             exec($command);
144         
145             $command = 'chmod o= '.$config_dir.'/smtpd.key';
146             caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command);
147         }
148         
149         //** We have to change the permissions of the courier authdaemon directory to make it accessible for maildrop.
150         $command = 'chmod 755  /var/run/authdaemon.courier-imap';
151         caselog($command.' &> /dev/null', __FILE__, __LINE__, 'EXECUTED: '.$command, 'Failed to execute the command '.$command);
152         
153         //* Changing maildrop lines in posfix master.cf
154         if(is_file($config_dir.'/master.cf')){
155             copy($config_dir.'/master.cf', $config_dir.'/master.cf~');
156         }
157         if(is_file($config_dir.'/master.cf~')){
158             exec('chmod 400 '.$config_dir.'/master.cf~');
159         }
160         $configfile = $config_dir.'/master.cf';
161         $content = rf($configfile);
162         
163         $content = str_replace('  flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}', 
164                    '  flags=R user='.$cf['vmail_username'].' argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}',
165                      $content);
166         
167         $content = str_replace('  flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient}', 
168                    '  flags=R user='.$cf['vmail_username'].' argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}',
169                      $content);
170         
171         wf($configfile, $content);
172         
173         //* Writing the Maildrop mailfilter file
174         $configfile = 'mailfilter';
175         if(is_file($cf['vmail_mailbox_base'].'/.'.$configfile)){
176             copy($cf['vmail_mailbox_base'].'/.'.$configfile, $cf['vmail_mailbox_base'].'/.'.$configfile.'~');
177         }
178         $content = rf("tpl/$configfile.master");
179         $content = str_replace('{dist_postfix_vmail_mailbox_base}', $cf['vmail_mailbox_base'], $content);
180         wf($cf['vmail_mailbox_base'].'/.'.$configfile, $content);
181         
182         //* Create the directory for the custom mailfilters
183         $command = 'mkdir '.$cf['vmail_mailbox_base'].'/mailfilters';
184         caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
185         
186         //* Chmod and chown the .mailfilter file
187         $command = 'chown -R '.$cf['vmail_username'].':'.$cf['vmail_groupname'].' '.$cf['vmail_mailbox_base'].'/.mailfilter';
188         caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
189         
190         $command = 'chmod -R 600 '.$cf['vmail_mailbox_base'].'/.mailfilter';
191         caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
192         
193     }
194     
195     public function configure_saslauthd() {
196         global $conf;
197         
198         /*
199         $configfile = 'sasl_smtpd.conf';
200         if(is_file('/etc/sasl2/smtpd.conf')) copy('/etc/sasl2/smtpd.conf','/etc/sasl2/smtpd.conf~');
201         if(is_file('/etc/sasl2/smtpd.conf~')) exec('chmod 400 '.'/etc/sasl2/smtpd.conf~');
202         $content = rf("tpl/".$configfile.".master");
203         $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
204         $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
205         $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
206         $content = str_replace('{mysql_server_ip}',$conf['mysql']['ip'],$content);
207         wf('/etc/sasl2/smtpd.conf',$content);
208         */
209         
210         // TODO: Chmod and chown on the config file
211         
212         
213         /*
214         // Create the spool directory
215         exec('mkdir -p /var/spool/postfix/var/run/saslauthd');
216         
217         // Edit the file /etc/default/saslauthd
218         $configfile = $conf["saslauthd"]["config"];
219         if(is_file($configfile)) copy($configfile,$configfile.'~');
220         if(is_file($configfile.'~')) exec('chmod 400 '.$configfile.'~');
221         $content = rf($configfile);
222         $content = str_replace('START=no','START=yes',$content);
223         $content = str_replace('OPTIONS="-c"','OPTIONS="-m /var/spool/postfix/var/run/saslauthd -r"',$content);
224         wf($configfile,$content);
225         */
226         
227         // Edit the file /etc/init.d/saslauthd
228         $configfile = $conf["init_scripts"].'/'.$conf["saslauthd"]["init_script"];
229         $content = rf($configfile);
230         $content = str_replace('/sbin/startproc $AUTHD_BIN -a $SASLAUTHD_AUTHMECH -n $SASLAUTHD_THREADS > /dev/null 2>&1','/sbin/startproc $AUTHD_BIN -r -a $SASLAUTHD_AUTHMECH -n $SASLAUTHD_THREADS > /dev/null 2>&1',$content);
231         $content = str_replace('/sbin/startproc $AUTHD_BIN $SASLAUTHD_PARAMS -a $SASLAUTHD_AUTHMECH -n $SASLAUTHD_THREADS > /dev/null 2>&1','/sbin/startproc $AUTHD_BIN $SASLAUTHD_PARAMS -r -a $SASLAUTHD_AUTHMECH -n $SASLAUTHD_THREADS > /dev/null 2>&1',$content);
232         
233         
234         wf($configfile,$content);
235         
236         
237         
238     }
239     
240     public function configure_pam()
241     {
242         global $conf;
243         $pam = $conf['pam'];
244         //* configure pam for SMTP authentication agains the ispconfig database
245         $configfile = 'pamd_smtp';
246         if(is_file("$pam/smtp"))    copy("$pam/smtp", "$pam/smtp~");
247         if(is_file("$pam/smtp~"))   exec("chmod 400 $pam/smtp~");
248
249         $content = rf("tpl/$configfile.master");
250         $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
251         $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
252         $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
253         $content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content);
254         wf("$pam/smtp", $content);
255         //exec("chmod 660 $pam/smtp");
256         //exec("chown root:root $pam/smtp");
257     
258     }
259     
260     public function configure_courier()
261     {
262         global $conf;
263         $config_dir = $conf['courier']['config_dir'];
264         //* authmysqlrc
265         $configfile = 'authmysqlrc';
266         if(is_file("$config_dir/$configfile")){
267             copy("$config_dir/$configfile", "$config_dir/$configfile~");
268         }
269         exec("chmod 400 $config_dir/$configfile~");
270         $content = rf("tpl/$configfile.master");
271         $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
272         $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
273         $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
274         $content = str_replace('{mysql_server_host}',$conf['mysql']['host'],$content);
275         wf("$config_dir/$configfile", $content);
276         
277         exec("chmod 660 $config_dir/$configfile");
278         exec("chown root:root $config_dir/$configfile");
279         
280         //* authdaemonrc
281         $configfile = $conf['courier']['config_dir'].'/authdaemonrc';
282         if(is_file($configfile)){
283             copy($configfile, $configfile.'~');
284         }
285         if(is_file($configfile.'~')){
286             exec('chmod 400 '.$configfile.'~');
287         }
288         $content = rf($configfile);
289         $content = str_replace('authmodulelist=', 'authmodulelist="authmysql"', $content);
290         wf($configfile, $content);
291     }
292     
293     public function configure_amavis() {
294         global $conf;
295         
296         // amavisd user config file
297         $configfile = 'opensuse_amavisd_conf';
298         if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf')) copy($conf["amavis"]["config_dir"].'/amavisd.conf',$conf["courier"]["config_dir"].'/amavisd.conf~');
299         if(is_file($conf["amavis"]["config_dir"].'/amavisd.conf~')) exec('chmod 400 '.$conf["amavis"]["config_dir"].'/amavisd.conf~');
300         $content = rf("tpl/".$configfile.".master");
301         $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
302         $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
303         $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
304         $content = str_replace('{mysql_server_port}',$conf["mysql"]["port"],$content);
305         $content = str_replace('{mysql_server_ip}',$conf['mysql']['ip'],$content);
306         wf($conf["amavis"]["config_dir"].'/amavisd.conf',$content);
307         
308         
309         // Adding the amavisd commands to the postfix configuration
310         $postconf_commands = array (
311             'content_filter = amavis:[127.0.0.1]:10024',
312             'receive_override_options = no_address_mappings'
313         );
314         
315         // Make a backup copy of the main.cf file
316         copy($conf["postfix"]["config_dir"].'/main.cf',$conf["postfix"]["config_dir"].'/main.cf~2');
317         
318         // Executing the postconf commands
319         foreach($postconf_commands as $cmd) {
320             $command = "postconf -e '$cmd'";
321             caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
322         }
323         
324         // Append the configuration for amavisd to the master.cf file
325         if(is_file($conf["postfix"]["config_dir"].'/master.cf')) copy($conf["postfix"]["config_dir"].'/master.cf',$conf["postfix"]["config_dir"].'/master.cf~');
326         $content = rf($conf["postfix"]["config_dir"].'/master.cf');
327         // Only add the content if we had not addded it before
328         if(!stristr($content,"127.0.0.1:10025")) {
329             unset($content);
330             $content = rf("tpl/master_cf_amavis.master");
331             af($conf["postfix"]["config_dir"].'/master.cf',$content);
332         }
333         unset($content);
334         
335         // Add the clamav user to the vscan group
336         exec('groupmod --add-user clamav vscan');
337         
338         
339     }
340     
341     public function configure_spamassassin()
342     {
343         global $conf;
344         
345         //* Enable spamasasssin on debian and ubuntu
346         /*
347         $configfile = '/etc/default/spamassassin';
348         if(is_file($configfile)){
349             copy($configfile, $configfile.'~');
350         }
351         $content = rf($configfile);
352         $content = str_replace('ENABLED=0', 'ENABLED=1', $content);
353         wf($configfile, $content);
354         */
355     }
356     
357     public function configure_getmail()
358     {
359         global $conf;
360         
361         $config_dir = $conf['getmail']['config_dir'];
362         
363         if(!is_dir($config_dir)) exec("mkdir -p ".escapeshellcmd($config_dir));
364
365         $command = "useradd -d $config_dir getmail";
366         if(!is_user('getmail')) caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
367         
368         $command = "chown -R getmail $config_dir";
369         caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
370         
371         $command = "chmod -R 700 $config_dir";
372         caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
373     }
374     
375     
376     public function configure_pureftpd()
377     {
378         global $conf;
379         
380         $config_dir = $conf['pureftpd']['config_dir'];
381
382         //* configure pam for SMTP authentication agains the ispconfig database
383         $configfile = 'db/mysql.conf';
384         if(is_file("$config_dir/$configfile")){
385             copy("$config_dir/$configfile", "$config_dir/$configfile~");
386         }
387         if(is_file("$config_dir/$configfile~")){
388             exec("chmod 400 $config_dir/$configfile~");
389         }
390         $content = rf('tpl/pureftpd_mysql.conf.master');
391         $content = str_replace('{mysql_server_ispconfig_user}', $conf["mysql"]["ispconfig_user"], $content);
392         $content = str_replace('{mysql_server_ispconfig_password}', $conf["mysql"]["ispconfig_password"], $content);
393         $content = str_replace('{mysql_server_database}', $conf["mysql"]["database"], $content);
394         $content = str_replace('{mysql_server_ip}', $conf["mysql"]["ip"], $content);
395         $content = str_replace('{server_id}', $conf["server_id"], $content);
396         wf("$config_dir/$configfile", $content);
397         exec("chmod 600 $config_dir/$configfile");
398         exec("chown root:root $config_dir/$configfile");
399         
400         // copy our customized copy of pureftpd.conf to the pure-ftpd config directory
401         exec("cp tpl/opensuse_pureftpd_conf.master $config_dir/pure-ftpd.conf");
402         
403     }
404     
405     public function configure_mydns()
406     {
407         global $conf;
408         
409         // configure pam for SMTP authentication agains the ispconfig database
410         $configfile = 'mydns.conf';
411         if(is_file($conf["mydns"]["config_dir"].'/'.$configfile)) copy($conf["mydns"]["config_dir"].'/'.$configfile,$conf["mydns"]["config_dir"].'/'.$configfile.'~');
412         if(is_file($conf["mydns"]["config_dir"].'/'.$configfile.'~')) exec('chmod 400 '.$conf["mydns"]["config_dir"].'/'.$configfile.'~');
413         $content = rf("tpl/".$configfile.".master");
414         $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
415         $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
416         $content = str_replace('{mysql_server_database}',$conf['mysql']['database'],$content);
417         $content = str_replace('{mysql_server_host}',$conf["mysql"]["host"],$content);
418         $content = str_replace('{server_id}',$conf["server_id"],$content);
419         wf($conf["mydns"]["config_dir"].'/'.$configfile,$content);
420         exec('chmod 600 '.$conf["mydns"]["config_dir"].'/'.$configfile);
421         exec('chown root:root '.$conf["mydns"]["config_dir"].'/'.$configfile);
422     
423     }
424     
425     public function configure_apache()
426     {    
427         global $conf;
428         
429         //* Create the logging directory for the vhost logfiles
430         exec('mkdir -p /var/log/ispconfig/httpd');
431         
cd4045 432         //if(is_file('/etc/suphp.conf')) {
T 433         replaceLine('/etc/suphp.conf','php=php','x-httpd-suphp=php:/srv/www/cgi-bin/php5',0,0);
434         replaceLine('/etc/suphp.conf','docroot=','docroot=/srv/www',0,0);
435         //}
8e5788 436         
T 437         // Sites enabled and avaulable dirs
438         exec('mkdir -p '.$conf['apache']['vhost_conf_enabled_dir']);
439         exec('mkdir -p '.$conf['apache']['vhost_conf_dir']);
440         
441         $content = rf('/etc/apache2/httpd.conf');
442         if(!stristr($content,'Include /etc/apache2/sites-enabled/')) {
443             af('/etc/apache2/httpd.conf',"\n<Directory /srv/www>\n    Options FollowSymlinks\n</Directory>\n\nInclude /etc/apache2/sites-enabled/\n\n");
444         }
445         unset($content);
446         
447         //* Copy the ISPConfig configuration include
448         $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
449         $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
450         
451         //copy('tpl/apache_ispconfig.conf.master',$vhost_conf_dir.'/ispconfig.conf');
452         $content = rf("tpl/apache_ispconfig.conf.master");
453         $records = $this->db->queryAllRecords("SELECT * FROM server_ip WHERE server_id = ".$conf["server_id"]." AND virtualhost = 'y'");
454         if(count($records) > 0) {
455             foreach($records as $rec) {
456                 $content .= "NameVirtualHost ".$rec["ip_address"].":80\n";
457                 $content .= "NameVirtualHost ".$rec["ip_address"].":443\n";
458             }
459         }
460         $content .= "\n";
461         wf($vhost_conf_dir.'/ispconfig.conf',$content);
462         
463         if(!@is_link($vhost_conf_enabled_dir."/000-ispconfig.conf")) {
464             exec("ln -s ".$vhost_conf_dir."/ispconfig.conf ".$vhost_conf_enabled_dir."/000-ispconfig.conf");
465         }
466         
467     }
468     
469     public function configure_firewall()
470     {
471         global $conf;
472         
473         $dist_init_scripts = $conf['init_scripts'];
474           
475         if(is_dir("/etc/Bastille.backup")) caselog("rm -rf /etc/Bastille.backup", __FILE__, __LINE__);
476         if(is_dir("/etc/Bastille")) caselog("mv -f /etc/Bastille /etc/Bastille.backup", __FILE__, __LINE__);
477           @mkdir("/etc/Bastille", octdec($directory_mode));
478           if(is_dir("/etc/Bastille.backup/firewall.d")) caselog("cp -pfr /etc/Bastille.backup/firewall.d /etc/Bastille/", __FILE__, __LINE__);
479           caselog("cp -f tpl/bastille-firewall.cfg.master /etc/Bastille/bastille-firewall.cfg", __FILE__, __LINE__);
480           caselog("chmod 644 /etc/Bastille/bastille-firewall.cfg", __FILE__, __LINE__);
481           $content = rf("/etc/Bastille/bastille-firewall.cfg");
482           $content = str_replace("{DNS_SERVERS}", "", $content);
483
484           $tcp_public_services = '';
485           $udp_public_services = '';
486         
487         $row = $this->db->queryOneRecord("SELECT * FROM firewall WHERE server_id = ".intval($conf['server_id']));
488         
489           if(trim($row["tcp_port"]) != '' || trim($row["udp_port"]) != ''){
490             $tcp_public_services = trim(str_replace(',',' ',$row["tcp_port"]));
491             $udp_public_services = trim(str_replace(',',' ',$row["udp_port"]));
492           } else {
493             $tcp_public_services = '21 22 25 53 80 110 443 3306 8080 10000';
494             $udp_public_services = '53';
495           }
496         
497         if(!stristr($tcp_public_services, $conf['apache']['vhost_port'])) {
498             $tcp_public_services .= ' '.intval($conf['apache']['vhost_port']);
499             if($row["tcp_port"] != '') $this->db->query("UPDATE firewall SET tcp_port = tcp_port + ',".intval($conf['apache']['vhost_port'])."' WHERE server_id = ".intval($conf['server_id']));
500         }
501
502           $content = str_replace("{TCP_PUBLIC_SERVICES}", $tcp_public_services, $content);
503           $content = str_replace("{UDP_PUBLIC_SERVICES}", $udp_public_services, $content);
504         
505           wf("/etc/Bastille/bastille-firewall.cfg", $content);
506
507           if(is_file($dist_init_scripts."/bastille-firewall")) caselog("mv -f $dist_init_scripts/bastille-firewall $dist_init_scripts/bastille-firewall.backup", __FILE__, __LINE__);
508           caselog("cp -f apps/bastille-firewall $dist_init_scripts", __FILE__, __LINE__);
509           caselog("chmod 700 $dist_init_scripts/bastille-firewall", __FILE__, __LINE__);
510
511           if(is_file("/sbin/bastille-ipchains")) caselog("mv -f /sbin/bastille-ipchains /sbin/bastille-ipchains.backup", __FILE__, __LINE__);
512           caselog("cp -f apps/bastille-ipchains /sbin", __FILE__, __LINE__);
513           caselog("chmod 700 /sbin/bastille-ipchains", __FILE__, __LINE__);
514
515           if(is_file("/sbin/bastille-netfilter")) caselog("mv -f /sbin/bastille-netfilter /sbin/bastille-netfilter.backup", __FILE__, __LINE__);
516           caselog("cp -f apps/bastille-netfilter /sbin", __FILE__, __LINE__);
517           caselog("chmod 700 /sbin/bastille-netfilter", __FILE__, __LINE__);
518         
519         if(!@is_dir('/var/lock/subsys')) caselog("mkdir /var/lock/subsys", __FILE__, __LINE__);
520
521           exec("which ipchains &> /dev/null", $ipchains_location, $ret_val);
522           if(!is_file("/sbin/ipchains") && !is_link("/sbin/ipchains") && $ret_val == 0) phpcaselog(@symlink(shell_exec("which ipchains"), "/sbin/ipchains"), 'create symlink', __FILE__, __LINE__);
523           unset($ipchains_location);
524           exec("which iptables &> /dev/null", $iptables_location, $ret_val);
525           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__);
526           unset($iptables_location);
527
528     }
529     
530     
531     public function install_ispconfig()
532     {
533         global $conf;
534         
535         $install_dir = $conf['ispconfig_install_dir'];
536
537         //* Create the ISPConfig installation directory
538         if(!@is_dir("$install_dir")) {
539             $command = "mkdir $install_dir";
540             caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
541         }
542         
543         //* Create a ISPConfig user and group
544         $command = 'groupadd ispconfig';
545         if(!is_group('ispconfig')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
546         
547         $command = "useradd -g ispconfig -d $install_dir ispconfig";
548         if(!is_user('ispconfig')) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
549         
550         //* copy the ISPConfig interface part
551         $command = "cp -rf ../interface $install_dir";
552         caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
553         
554         //* copy the ISPConfig server part
555         $command = "cp -rf ../server $install_dir";
556         caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
557         
558         //* Create a symlink, so ISPConfig is accessible via web
559         // Replaced by a separate vhost definition for port 8080
560         // $command = "ln -s $install_dir/interface/web/ /var/www/ispconfig";
561         // caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
562         
563         //* Create the config file for ISPConfig interface
564         $configfile = 'config.inc.php';
565         if(is_file($install_dir.'/interface/lib/'.$configfile)){
566             copy("$install_dir/interface/lib/$configfile", "$install_dir/interface/lib/$configfile~");
567         }
568         $content = rf("tpl/$configfile.master");
569         $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
570         $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
571         $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
572         $content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
573         
574         $content = str_replace('{mysql_master_server_ispconfig_user}', $conf['mysql']['master_ispconfig_user'], $content);
575         $content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content);
576         $content = str_replace('{mysql_master_server_database}', $conf['mysql']['master_database'], $content);
577         $content = str_replace('{mysql_master_server_host}', $conf['mysql']['master_host'], $content);
578         
579         $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
580         wf("$install_dir/interface/lib/$configfile", $content);
581         
582         //* Create the config file for ISPConfig server
583         $configfile = 'config.inc.php';
584         if(is_file($install_dir.'/server/lib/'.$configfile)){
585             copy("$install_dir/server/lib/$configfile", "$install_dir/interface/lib/$configfile~");
586         }
587         $content = rf("tpl/$configfile.master");
588         $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
589         $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
590         $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
591         $content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
592         
593         $content = str_replace('{mysql_master_server_ispconfig_user}', $conf['mysql']['master_ispconfig_user'], $content);
594         $content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content);
595         $content = str_replace('{mysql_master_server_database}', $conf['mysql']['master_database'], $content);
596         $content = str_replace('{mysql_master_server_host}', $conf['mysql']['master_host'], $content);
597         
598         $content = str_replace('{server_id}', $conf['server_id'], $content);
599         $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
600         wf("$install_dir/server/lib/$configfile", $content);
601         
602         
603         //* Enable the server modules and plugins.
604         // TODO: Implement a selector which modules and plugins shall be enabled.
605         $dir = $install_dir.'/server/mods-available/';
606         if (is_dir($dir)) {
607             if ($dh = opendir($dir)) {
608                 while (($file = readdir($dh)) !== false) {
609                     if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') {
610                         include_once($install_dir.'/server/mods-available/'.$file);
611                         $module_name = substr($file,0,-8);
612                         $tmp = new $module_name;
613                         if($tmp->onInstall()) {
614                             if(!@is_link($install_dir.'/server/mods-enabled/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-enabled/'.$file);
615                             if (strpos($file, '_core_module') !== false) {
616                                 if(!@is_link($install_dir.'/server/mods-core/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-core/'.$file);
617                             }
618                         }
619                         unset($tmp);
620                     }
621                 }
622                 closedir($dh);
623             }
624         }
625         
626         $dir = $install_dir.'/server/plugins-available/';
627         if (is_dir($dir)) {
628             if ($dh = opendir($dir)) {
629                 while (($file = readdir($dh)) !== false) {
630                     if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') {
631                         include_once($install_dir.'/server/plugins-available/'.$file);
632                         $plugin_name = substr($file,0,-8);
633                         $tmp = new $plugin_name;
634                         if($tmp->onInstall()) {
635                             if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file);
636                             if (strpos($file, '_core_plugin') !== false) {
637                                 if(!@is_link($install_dir.'/server/plugins-core/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-core/'.$file);
638                             }
639                         }
640                         unset($tmp);
641                     }
642                 }
643                 closedir($dh);
644             }
645         }
646         
647         // Update the server config
648         $mail_server_enabled = ($conf['services']['mail'])?1:0;
649         $web_server_enabled = ($conf['services']['web'])?1:0;
650         $dns_server_enabled = ($conf['services']['dns'])?1:0;
651         $file_server_enabled = ($conf['services']['file'])?1:0;
652         $db_server_enabled = ($conf['services']['db'])?1:0;
653         $vserver_server_enabled = ($conf['services']['vserver'])?1:0;
654         $sql = "UPDATE `server` SET mail_server = '$mail_server_enabled', web_server = '$web_server_enabled', dns_server = '$dns_server_enabled', file_server = '$file_server_enabled', db_server = '$db_server_enabled', vserver_server = '$vserver_server_enabled' WHERE server_id = ".intval($conf['server_id']);
655         
656         if($conf['mysql']['master_slave_setup'] == 'y') {
657             $this->dbmaster->query($sql);
658             $this->db->query($sql);
659         } else {
660             $this->db->query($sql);
661         }
662         
663         //* Chmod the files
664         $command = "chmod -R 750 $install_dir";
665         caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
666
667         //* chown the files to the ispconfig user and group
668         $command = "chown -R ispconfig:ispconfig $install_dir";
669         caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
670         
671         //* Make the global language file directory group writable
672         exec("chmod -R 770 $install_dir/interface/lib/lang");
673         
674         //* Make the temp directory for language file exports writable
675         exec("chmod -R 770 $install_dir/interface/web/temp");
676         
677         //* Make all interface language file directories group writable
678         $handle = @opendir($install_dir.'/interface/web');
679         while ($file = @readdir ($handle)) { 
680                if ($file != '.' && $file != '..') {
681                 if(@is_dir($install_dir.'/interface/web'.'/'.$file.'/lib/lang')) {
682                     $handle2 = opendir($install_dir.'/interface/web'.'/'.$file.'/lib/lang');
683                     chmod($install_dir.'/interface/web'.'/'.$file.'/lib/lang',0770);
684                     while ($lang_file = @readdir ($handle2)) {
685                         if ($lang_file != '.' && $lang_file != '..') {
686                             chmod($install_dir.'/interface/web'.'/'.$file.'/lib/lang/'.$lang_file,0770);
687                         }
688                     }
689                 }
690             }
691         }
692         
693         //* make sure that the server config file (not the interface one) is only readable by the root user
694         exec("chmod 600 $install_dir/server/lib/$configfile");
695         exec("chown root:root $install_dir/server/lib/$configfile");
696         if(@is_file("$install_dir/server/lib/mysql_clientdb.conf")) {
697             exec("chmod 600 $install_dir/server/lib/mysql_clientdb.conf");
698             exec("chown root:root $install_dir/server/lib/mysql_clientdb.conf");
699         }
700         
701         // TODO: FIXME: add the www-data user to the ispconfig group. This is just for testing
702         // and must be fixed as this will allow the apache user to read the ispconfig files.
703         // Later this must run as own apache server or via suexec!
704         $command = 'groupmod --add-user wwwrun ispconfig';
705         caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
706         
707         //* Make the shell scripts executable
708         $command = "chmod +x $install_dir/server/scripts/*.sh";
709         caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
710         
711         //* Copy the ISPConfig vhost for the controlpanel
712         // TODO: These are missing! should they be "vhost_dist_*_dir" ?
713         $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
714         $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
715         
716         
717         // Dont just copy over the virtualhost template but add some custom settings
718          
719         $content = rf("tpl/apache_ispconfig.vhost.master");
720         $content = str_replace('{vhost_port}', $conf['apache']['vhost_port'], $content);
721         
722         // comment out the listen directive if port is 80 or 443
723         if($conf['apache']['vhost_port'] == 80 or $conf['apache']['vhost_port'] == 443) {
724             $content = str_replace('{vhost_port_listen}', '#', $content);
725         } else {
726             $content = str_replace('{vhost_port_listen}', '', $content);
727         }
728         
729         $content = str_replace('/var/www/', '/srv/www/', $content);
730         
731         wf("$vhost_conf_dir/ispconfig.vhost", $content);
732         
733         if(!is_file('/srv/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter')) {
734             exec('mkdir -p /srv/www/php-fcgi-scripts/ispconfig');
735             exec('cp tpl/apache_ispconfig_fcgi_starter.master /srv/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
736             exec('chmod +x /srv/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
737             exec('ln -s /usr/local/ispconfig/interface/web /srv/www/ispconfig');
738             exec('chown -R ispconfig:ispconfig /srv/www/php-fcgi-scripts/ispconfig');
739             
740         }
741         
742         //copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
743         //* and create the symlink
744         if($this->install_ispconfig_interface == true && $this->is_update == false) {
745             if(@is_link("$vhost_conf_enabled_dir/ispconfig.vhost")) unlink("$vhost_conf_enabled_dir/ispconfig.vhost");
746             if(!@is_link("$vhost_conf_enabled_dir/000-ispconfig.vhost")) {
747                 exec("ln -s $vhost_conf_dir/ispconfig.vhost $vhost_conf_enabled_dir/000-ispconfig.vhost");
748             }
749             
750         }
751         
752         // Fix a setting in vhost master file for suse
753         replaceLine('/usr/local/ispconfig/server/conf/vhost.conf.master',"suPHP_UserGroup","        suPHP_UserGroup <tmpl_var name='system_user'> <tmpl_var name='system_group'>",0);
754         
755         
756         
757         // Make the Clamav log files readable by ISPConfig
758         //exec('chmod +r /var/log/clamav/clamav.log');
759         //exec('chmod +r /var/log/clamav/freshclam.log');
760         
761         //* Install the update script
762         if(is_file('/usr/local/bin/ispconfig_update_from_svn.sh')) unlink('/usr/local/bin/ispconfig_update_from_svn.sh');
763         exec('chown root /usr/local/ispconfig/server/scripts/update_from_svn.sh');
764         exec('chmod 700 /usr/local/ispconfig/server/scripts/update_from_svn.sh');
765         exec('chown root /usr/local/ispconfig/server/scripts/update_from_tgz.sh');
766         exec('chmod 700 /usr/local/ispconfig/server/scripts/update_from_tgz.sh');
767         exec('chown root /usr/local/ispconfig/server/scripts/ispconfig_update.sh');
768         exec('chmod 700 /usr/local/ispconfig/server/scripts/ispconfig_update.sh');
769         if(!is_link('/usr/local/bin/ispconfig_update_from_svn.sh')) exec('ln -s /usr/local/ispconfig/server/scripts/ispconfig_update.sh /usr/local/bin/ispconfig_update_from_svn.sh');
770         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');
771         
772         //set the fast cgi starter script to executable
773         //exec('chmod 755 '.$install_dir.'/interface/bin/php-fcgi');
774         
775         //* Make the logs readable for the ispconfig user
776         if(@is_file('/var/log/mail.log')) exec('chmod +r /var/log/mail.log');
777         if(@is_file('/var/log/mail.warn')) exec('chmod +r /var/log/mail.warn');
778         if(@is_file('/var/log/mail.err')) exec('chmod +r /var/log/mail.err');
779         if(@is_file('/var/log/messages')) exec('chmod +r /var/log/messages');
780         
781         //To enable apache to read the directories
782         exec('chmod a+rx /usr/local/ispconfig');
783         exec('chmod -R 751 /usr/local/ispconfig/interface');
784         exec('chmod a+rx /usr/local/ispconfig/interface/web');
785         
786         //* Create the ispconfig log directory
787         if(!is_dir('/var/log/ispconfig')) mkdir('/var/log/ispconfig');
788         if(!is_file('/var/log/ispconfig/ispconfig.log')) exec('touch /var/log/ispconfig/ispconfig.log');
789         
5456ca 790         exec('mv /usr/local/ispconfig/server/scripts/run-getmail.sh /usr/local/bin/run-getmail.sh');
T 791         exec('chown getmail /usr/local/bin/run-getmail.sh');
792         exec('chmod 744 /usr/local/bin/run-getmail.sh');
8e5788 793         
T 794         
795     }
796     
797     public function configure_dbserver()
798     {
799         global $conf;
800         
801         //* If this server shall act as database server for client DB's, we configure this here
802         $install_dir = $conf['ispconfig_install_dir'];
803         
804         // Create a file with the database login details which 
805         // are used to create the client databases.
806         
807         if(!is_dir("$install_dir/server/lib")) {
808             $command = "mkdir $install_dir/server/lib";
809             caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
810         }
811         
812         $content = rf("tpl/mysql_clientdb.conf.master");
813         $content = str_replace('{username}',$conf['mysql']['admin_user'],$content);
814         $content = str_replace('{password}',$conf['mysql']['admin_password'], $content);
815         wf("$install_dir/server/lib/mysql_clientdb.conf",$content);
816         exec('chmod 600 '."$install_dir/server/lib/mysql_clientdb.conf");
817         exec('chown root:root '."$install_dir/server/lib/mysql_clientdb.conf");
818         
819     }
820     
821     public function install_crontab()
822     {        
823         global $conf;
824         
825         //* Root Crontab
826         exec('crontab -u root -l > crontab.txt');
827         $existing_root_cron_jobs = file('crontab.txt');
828         
829         // remove existing ispconfig cronjobs, in case the syntax has changed
830         foreach($existing_root_cron_jobs as $key => $val) {
831             if(stristr($val,'/usr/local/ispconfig')) unset($existing_root_cron_jobs[$key]);
832         }
833         
834         $root_cron_jobs = array(
835             '* * * * * /usr/local/ispconfig/server/server.sh &> /dev/null',
836             '30 00 * * * /usr/local/ispconfig/server/cron_daily.sh &> /dev/null'
837         );
838         foreach($root_cron_jobs as $cron_job) {
839             if(!in_array($cron_job."\n", $existing_root_cron_jobs)) {
840                 $existing_root_cron_jobs[] = $cron_job."\n";
841             }
842         }
843         file_put_contents('crontab.txt', $existing_root_cron_jobs);
844         exec('crontab -u root crontab.txt &> /dev/null');
845         unlink('crontab.txt');
846         
847         //* Getmail crontab
848         if(is_user('getmail')) {
849             $cf = $conf['getmail'];
850             exec('crontab -u getmail -l > crontab.txt');
851             $existing_cron_jobs = file('crontab.txt');
852         
853             $cron_jobs = array(
5456ca 854                 '*/5 * * * * /usr/local/bin/run-getmail.sh > /dev/null 2>> /var/log/ispconfig/cron.log'
8e5788 855             );
T 856         
857             // remove existing ispconfig cronjobs, in case the syntax has changed
858             foreach($existing_cron_jobs as $key => $val) {
859                 if(stristr($val,'getmail')) unset($existing_cron_jobs[$key]);
860             }
861         
862             foreach($cron_jobs as $cron_job) {
863                 if(!in_array($cron_job."\n", $existing_cron_jobs)) {
864                     $existing_cron_jobs[] = $cron_job."\n";
865                 }
866             }
867             file_put_contents('crontab.txt', $existing_cron_jobs);
868             exec('crontab -u getmail crontab.txt &> /dev/null');
869             unlink('crontab.txt');
870         }
871         
872         exec('touch /var/log/ispconfig/cron.log');
873         exec('chmod 666 /var/log/ispconfig/cron.log');
874     }
875
876 }
877
7d89f5 878 ?>