fantu
2008-11-30 07cdaafc715bf55126959f93bd79b51b3cadddce
install/lib/installer_base.lib.php
@@ -119,7 +119,7 @@
      
      $cf = $conf['mysql']; // make $conf['mysql'] more accessible
      //** Create the database
      if(!$this->db->query('CREATE DATABASE IF NOT EXISTS '.$cf['database'])) {
      if(!$this->db->query('CREATE DATABASE IF NOT EXISTS '.$cf['database'].' DEFAULT CHARACTER SET '.$cf['charset'])) {
         $this->error('Unable to create MySQL database: '.$cf['database'].'.');
      }
      
@@ -132,10 +132,10 @@
         $this->error('Stopped: Database already contains some tables.');
      } else {
         if($cf['admin_password'] == '') {
            caselog("mysql -h '".$cf['host']."' -u '".$cf['admin_user']."' '".$cf['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/ispconfig3.sql' &> /dev/null",
            caselog("mysql --default-character-set=".$cf['charset']." -h '".$cf['host']."' -u '".$cf['admin_user']."' '".$cf['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/ispconfig3.sql' &> /dev/null",
                        __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql');
         } else {
            caselog("mysql -h '".$cf['host']."' -u '".$cf['admin_user']."' -p'".$cf['admin_password']."' '".$cf['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/ispconfig3.sql' &> /dev/null",
            caselog("mysql --default-character-set=".$cf['charset']." -h '".$cf['host']."' -u '".$cf['admin_user']."' -p'".$cf['admin_password']."' '".$cf['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/ispconfig3.sql' &> /dev/null",
                        __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql');
         }
         $db_tables = $this->db->getTables();
@@ -832,12 +832,20 @@
         
        $content = rf("tpl/apache_ispconfig.vhost.master");
      $content = str_replace('{vhost_port}', $conf['apache']['vhost_port'], $content);
      // comment out the listen directive if port is 80 or 443
      if($conf['apache']['vhost_port'] == 80 or $conf['apache']['vhost_port'] == 443) {
         $content = str_replace('{vhost_port_listen}', '#', $content);
      } else {
         $content = str_replace('{vhost_port_listen}', '', $content);
      }
      wf("$vhost_conf_dir/ispconfig.vhost", $content);
      
      //copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
      //* and create the symlink
      if($this->install_ispconfig_interface == true) {
         if(!@is_link("$vhost_conf_enabled_dir/ispconfig.vhost")) unlink("$vhost_conf_enabled_dir/ispconfig.vhost");
         if(@is_link("$vhost_conf_enabled_dir/ispconfig.vhost")) unlink("$vhost_conf_enabled_dir/ispconfig.vhost");
         if(!@is_link("$vhost_conf_enabled_dir/000-ispconfig.vhost")) {
            exec("ln -s $vhost_conf_dir/ispconfig.vhost $vhost_conf_enabled_dir/000-ispconfig.vhost");
         }
@@ -860,6 +868,10 @@
      if(@is_file('/var/log/mail.warn')) exec('chmod +r /var/log/mail.warn');
      if(@is_file('/var/log/mail.err')) exec('chmod +r /var/log/mail.err');
      if(@is_file('/var/log/messages')) exec('chmod +r /var/log/messages');
      //* Create the ispconfig log directory
      if(!is_dir('/var/log/ispconfig')) mkdir('/var/log/ispconfig');
      if(!is_file('/var/log/ispconfig/ispconfig.log')) exec('touch /var/log/ispconfig/ispconfig.log');
      
      
   }
@@ -915,25 +927,27 @@
      unlink('crontab.txt');
      
      //* Getmail crontab
        $cf = $conf['getmail'];
      exec('crontab -u getmail -l > crontab.txt');
      $existing_cron_jobs = file('crontab.txt');
      if(is_user('getmail')) {
           $cf = $conf['getmail'];
         exec('crontab -u getmail -l > crontab.txt');
         $existing_cron_jobs = file('crontab.txt');
      
      $cron_jobs = array('*/5 * * * * '.$cf['program'].' -g '.$cf['config_dir'].' -r '.$cf['config_dir'].'/*.conf > /dev/null');
         $cron_jobs = array('*/5 * * * * '.$cf['program'].' -g '.$cf['config_dir'].' -r '.$cf['config_dir'].'/*.conf > /dev/null');
      
      // remove existing ispconfig cronjobs, in case the syntax has changed
      foreach($cron_jobs as $key => $val) {
         if(stristr($val,$cf['program'])) unset($cron_jobs[$key]);
      }
      foreach($cron_jobs as $cron_job) {
         if(!in_array($cron_job."\n", $existing_cron_jobs)) {
            $existing_cron_jobs[] = $cron_job."\n";
         // remove existing ispconfig cronjobs, in case the syntax has changed
         foreach($cron_jobs as $key => $val) {
            if(stristr($val,$cf['program'])) unset($cron_jobs[$key]);
         }
         foreach($cron_jobs as $cron_job) {
            if(!in_array($cron_job."\n", $existing_cron_jobs)) {
               $existing_cron_jobs[] = $cron_job."\n";
            }
         }
         file_put_contents('crontab.txt', $existing_cron_jobs);
         exec('crontab -u getmail crontab.txt &> /dev/null');
         unlink('crontab.txt');
      }
      file_put_contents('crontab.txt', $existing_cron_jobs);
      exec('crontab -u getmail crontab.txt &> /dev/null');
      unlink('crontab.txt');
   }
   
}