tbrehm
2009-05-27 0182cafd95cd8985a500ca298639652dc96fb354
commit | author | age
24854c 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 [::1]/128',
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         
432         //if(is_file('/etc/suphp.conf')) {
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         //}
436         
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         
0182ca 579         $content = str_replace('{server_id}', $conf['server_id'], $content);
24854c 580         $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
T 581         $content = str_replace('{language}', $conf['language'], $content);
582         
583         wf("$install_dir/interface/lib/$configfile", $content);
584         
585         //* Create the config file for ISPConfig server
586         $configfile = 'config.inc.php';
587         if(is_file($install_dir.'/server/lib/'.$configfile)){
588             copy("$install_dir/server/lib/$configfile", "$install_dir/interface/lib/$configfile~");
589         }
590         $content = rf("tpl/$configfile.master");
591         $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
592         $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
593         $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
594         $content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
595         
596         $content = str_replace('{mysql_master_server_ispconfig_user}', $conf['mysql']['master_ispconfig_user'], $content);
597         $content = str_replace('{mysql_master_server_ispconfig_password}', $conf['mysql']['master_ispconfig_password'], $content);
598         $content = str_replace('{mysql_master_server_database}', $conf['mysql']['master_database'], $content);
599         $content = str_replace('{mysql_master_server_host}', $conf['mysql']['master_host'], $content);
600         
601         $content = str_replace('{server_id}', $conf['server_id'], $content);
602         $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
949e7e 603         $content = str_replace('{language}', $conf['language'], $content);
T 604         
24854c 605         wf("$install_dir/server/lib/$configfile", $content);
T 606         
607         
608         //* Enable the server modules and plugins.
609         // TODO: Implement a selector which modules and plugins shall be enabled.
610         $dir = $install_dir.'/server/mods-available/';
611         if (is_dir($dir)) {
612             if ($dh = opendir($dir)) {
613                 while (($file = readdir($dh)) !== false) {
614                     if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') {
615                         include_once($install_dir.'/server/mods-available/'.$file);
616                         $module_name = substr($file,0,-8);
617                         $tmp = new $module_name;
618                         if($tmp->onInstall()) {
619                             if(!@is_link($install_dir.'/server/mods-enabled/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-enabled/'.$file);
620                             if (strpos($file, '_core_module') !== false) {
621                                 if(!@is_link($install_dir.'/server/mods-core/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-core/'.$file);
622                             }
623                         }
624                         unset($tmp);
625                     }
626                 }
627                 closedir($dh);
628             }
629         }
630         
631         $dir = $install_dir.'/server/plugins-available/';
632         if (is_dir($dir)) {
633             if ($dh = opendir($dir)) {
634                 while (($file = readdir($dh)) !== false) {
635                     if($file != '.' && $file != '..' && substr($file,-8,8) == '.inc.php') {
636                         include_once($install_dir.'/server/plugins-available/'.$file);
637                         $plugin_name = substr($file,0,-8);
638                         $tmp = new $plugin_name;
639                         if($tmp->onInstall()) {
640                             if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file);
641                             if (strpos($file, '_core_plugin') !== false) {
642                                 if(!@is_link($install_dir.'/server/plugins-core/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-core/'.$file);
643                             }
644                         }
645                         unset($tmp);
646                     }
647                 }
648                 closedir($dh);
649             }
650         }
651         
652         // Update the server config
653         $mail_server_enabled = ($conf['services']['mail'])?1:0;
654         $web_server_enabled = ($conf['services']['web'])?1:0;
655         $dns_server_enabled = ($conf['services']['dns'])?1:0;
656         $file_server_enabled = ($conf['services']['file'])?1:0;
657         $db_server_enabled = ($conf['services']['db'])?1:0;
658         $vserver_server_enabled = ($conf['services']['vserver'])?1:0;
659         $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']);
660         
661         if($conf['mysql']['master_slave_setup'] == 'y') {
662             $this->dbmaster->query($sql);
663             $this->db->query($sql);
664         } else {
665             $this->db->query($sql);
666         }
667         
668         //* Chmod the files
669         $command = "chmod -R 750 $install_dir";
670         caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
671
672         //* chown the files to the ispconfig user and group
673         $command = "chown -R ispconfig:ispconfig $install_dir";
674         caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
675         
676         //* Make the global language file directory group writable
677         exec("chmod -R 770 $install_dir/interface/lib/lang");
678         
679         //* Make the temp directory for language file exports writable
680         exec("chmod -R 770 $install_dir/interface/web/temp");
681         
682         //* Make all interface language file directories group writable
683         $handle = @opendir($install_dir.'/interface/web');
684         while ($file = @readdir ($handle)) { 
685                if ($file != '.' && $file != '..') {
686                 if(@is_dir($install_dir.'/interface/web'.'/'.$file.'/lib/lang')) {
687                     $handle2 = opendir($install_dir.'/interface/web'.'/'.$file.'/lib/lang');
688                     chmod($install_dir.'/interface/web'.'/'.$file.'/lib/lang',0770);
689                     while ($lang_file = @readdir ($handle2)) {
690                         if ($lang_file != '.' && $lang_file != '..') {
691                             chmod($install_dir.'/interface/web'.'/'.$file.'/lib/lang/'.$lang_file,0770);
692                         }
693                     }
694                 }
695             }
696         }
697         
698         //* make sure that the server config file (not the interface one) is only readable by the root user
699         exec("chmod 600 $install_dir/server/lib/$configfile");
700         exec("chown root:root $install_dir/server/lib/$configfile");
701         if(@is_file("$install_dir/server/lib/mysql_clientdb.conf")) {
702             exec("chmod 600 $install_dir/server/lib/mysql_clientdb.conf");
703             exec("chown root:root $install_dir/server/lib/mysql_clientdb.conf");
704         }
705         
706         // TODO: FIXME: add the www-data user to the ispconfig group. This is just for testing
707         // and must be fixed as this will allow the apache user to read the ispconfig files.
708         // Later this must run as own apache server or via suexec!
709         $command = 'groupmod --add-user wwwrun ispconfig';
710         caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
711         
712         //* Make the shell scripts executable
713         $command = "chmod +x $install_dir/server/scripts/*.sh";
714         caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
715         
716         //* Copy the ISPConfig vhost for the controlpanel
717         // TODO: These are missing! should they be "vhost_dist_*_dir" ?
718         $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
719         $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
720         
721         
722         // Dont just copy over the virtualhost template but add some custom settings
723          
724         $content = rf("tpl/apache_ispconfig.vhost.master");
725         $content = str_replace('{vhost_port}', $conf['apache']['vhost_port'], $content);
726         
727         // comment out the listen directive if port is 80 or 443
728         if($conf['apache']['vhost_port'] == 80 or $conf['apache']['vhost_port'] == 443) {
729             $content = str_replace('{vhost_port_listen}', '#', $content);
730         } else {
731             $content = str_replace('{vhost_port_listen}', '', $content);
732         }
733         
734         $content = str_replace('/var/www/', '/srv/www/', $content);
735         
736         wf("$vhost_conf_dir/ispconfig.vhost", $content);
737         
738         if(!is_file('/srv/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter')) {
739             exec('mkdir -p /srv/www/php-fcgi-scripts/ispconfig');
740             exec('cp tpl/apache_ispconfig_fcgi_starter.master /srv/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
741             exec('chmod +x /srv/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter');
742             exec('ln -s /usr/local/ispconfig/interface/web /srv/www/ispconfig');
743             exec('chown -R ispconfig:ispconfig /srv/www/php-fcgi-scripts/ispconfig');
744             
745         }
746         
747         //copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
748         //* and create the symlink
749         if($this->install_ispconfig_interface == true && $this->is_update == false) {
750             if(@is_link("$vhost_conf_enabled_dir/ispconfig.vhost")) unlink("$vhost_conf_enabled_dir/ispconfig.vhost");
751             if(!@is_link("$vhost_conf_enabled_dir/000-ispconfig.vhost")) {
752                 exec("ln -s $vhost_conf_dir/ispconfig.vhost $vhost_conf_enabled_dir/000-ispconfig.vhost");
753             }
754             
755         }
756         
757         // Fix a setting in vhost master file for suse
758         replaceLine('/usr/local/ispconfig/server/conf/vhost.conf.master',"suPHP_UserGroup","        suPHP_UserGroup <tmpl_var name='system_user'> <tmpl_var name='system_group'>",0);
759         
760         
761         
762         // Make the Clamav log files readable by ISPConfig
763         //exec('chmod +r /var/log/clamav/clamav.log');
764         //exec('chmod +r /var/log/clamav/freshclam.log');
765         
766         //* Install the update script
767         if(is_file('/usr/local/bin/ispconfig_update_from_svn.sh')) unlink('/usr/local/bin/ispconfig_update_from_svn.sh');
768         exec('chown root /usr/local/ispconfig/server/scripts/update_from_svn.sh');
769         exec('chmod 700 /usr/local/ispconfig/server/scripts/update_from_svn.sh');
770         exec('chown root /usr/local/ispconfig/server/scripts/update_from_tgz.sh');
771         exec('chmod 700 /usr/local/ispconfig/server/scripts/update_from_tgz.sh');
772         exec('chown root /usr/local/ispconfig/server/scripts/ispconfig_update.sh');
773         exec('chmod 700 /usr/local/ispconfig/server/scripts/ispconfig_update.sh');
774         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');
775         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');
776         
777         //set the fast cgi starter script to executable
778         //exec('chmod 755 '.$install_dir.'/interface/bin/php-fcgi');
779         
780         //* Make the logs readable for the ispconfig user
781         if(@is_file('/var/log/mail.log')) exec('chmod +r /var/log/mail.log');
782         if(@is_file('/var/log/mail.warn')) exec('chmod +r /var/log/mail.warn');
783         if(@is_file('/var/log/mail.err')) exec('chmod +r /var/log/mail.err');
784         if(@is_file('/var/log/messages')) exec('chmod +r /var/log/messages');
785         
786         //To enable apache to read the directories
787         exec('chmod a+rx /usr/local/ispconfig');
788         exec('chmod -R 751 /usr/local/ispconfig/interface');
789         exec('chmod a+rx /usr/local/ispconfig/interface/web');
790         
791         //* Create the ispconfig log directory
792         if(!is_dir('/var/log/ispconfig')) mkdir('/var/log/ispconfig');
793         if(!is_file('/var/log/ispconfig/ispconfig.log')) exec('touch /var/log/ispconfig/ispconfig.log');
794         
795         exec('mv /usr/local/ispconfig/server/scripts/run-getmail.sh /usr/local/bin/run-getmail.sh');
796         exec('chown getmail /usr/local/bin/run-getmail.sh');
797         exec('chmod 744 /usr/local/bin/run-getmail.sh');
798         
799         
800     }
801     
802     public function configure_dbserver()
803     {
804         global $conf;
805         
806         //* If this server shall act as database server for client DB's, we configure this here
807         $install_dir = $conf['ispconfig_install_dir'];
808         
809         // Create a file with the database login details which 
810         // are used to create the client databases.
811         
812         if(!is_dir("$install_dir/server/lib")) {
813             $command = "mkdir $install_dir/server/lib";
814             caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
815         }
816         
817         $content = rf("tpl/mysql_clientdb.conf.master");
818         $content = str_replace('{username}',$conf['mysql']['admin_user'],$content);
819         $content = str_replace('{password}',$conf['mysql']['admin_password'], $content);
820         wf("$install_dir/server/lib/mysql_clientdb.conf",$content);
821         exec('chmod 600 '."$install_dir/server/lib/mysql_clientdb.conf");
822         exec('chown root:root '."$install_dir/server/lib/mysql_clientdb.conf");
823         
824     }
825     
826     public function install_crontab()
827     {        
828         global $conf;
829         
830         //* Root Crontab
831         exec('crontab -u root -l > crontab.txt');
832         $existing_root_cron_jobs = file('crontab.txt');
833         
834         // remove existing ispconfig cronjobs, in case the syntax has changed
835         foreach($existing_root_cron_jobs as $key => $val) {
836             if(stristr($val,'/usr/local/ispconfig')) unset($existing_root_cron_jobs[$key]);
837         }
838         
839         $root_cron_jobs = array(
840             '* * * * * /usr/local/ispconfig/server/server.sh &> /dev/null',
841             '30 00 * * * /usr/local/ispconfig/server/cron_daily.sh &> /dev/null'
842         );
843         foreach($root_cron_jobs as $cron_job) {
844             if(!in_array($cron_job."\n", $existing_root_cron_jobs)) {
845                 $existing_root_cron_jobs[] = $cron_job."\n";
846             }
847         }
848         file_put_contents('crontab.txt', $existing_root_cron_jobs);
849         exec('crontab -u root crontab.txt &> /dev/null');
850         unlink('crontab.txt');
851         
852         //* Getmail crontab
853         if(is_user('getmail')) {
854             $cf = $conf['getmail'];
855             exec('crontab -u getmail -l > crontab.txt');
856             $existing_cron_jobs = file('crontab.txt');
857         
858             $cron_jobs = array(
859                 '*/5 * * * * /usr/local/bin/run-getmail.sh > /dev/null 2>> /var/log/ispconfig/cron.log'
860             );
861         
862             // remove existing ispconfig cronjobs, in case the syntax has changed
863             foreach($existing_cron_jobs as $key => $val) {
864                 if(stristr($val,'getmail')) unset($existing_cron_jobs[$key]);
865             }
866         
867             foreach($cron_jobs as $cron_job) {
868                 if(!in_array($cron_job."\n", $existing_cron_jobs)) {
869                     $existing_cron_jobs[] = $cron_job."\n";
870                 }
871             }
872             file_put_contents('crontab.txt', $existing_cron_jobs);
873             exec('crontab -u getmail crontab.txt &> /dev/null');
874             unlink('crontab.txt');
875         }
876         
877         exec('touch /var/log/ispconfig/cron.log');
878         exec('chmod 666 /var/log/ispconfig/cron.log');
879     }
880
881 }
882
7d89f5 883 ?>