Sergio Cambra
2014-07-08 009b2dcf6ac4d6dabdb0ccec16319fa2901fbc48
install/dist/lib/gentoo.lib.php
@@ -157,6 +157,19 @@
         caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
      }
      //* postfix-dkim
      $full_file_name=$config_dir.'/tag_as_originating.re';
      if(is_file($full_file_name)) {
         copy($full_file_name, $config_dir.$configfile.'~');
      }
      $this->write_config_file($full_file_name, '/^/ FILTER amavis:[127.0.0.1]:10026');
      $full_file_name=$config_dir.'/tag_as_foreign.re';
      if(is_file($full_file_name)) {
         copy($full_file_name, $config_dir.$configfile.'~');
      }
      $this->write_config_file($full_file_name, '/^/ FILTER amavis:[127.0.0.1]:10024');
      //* Chmod and chown the .mailfilter file
      $command = 'chown -R '.$cf['vmail_username'].':'.$cf['vmail_groupname'].' '.$cf['vmail_mailbox_base'].'/.mailfilter';
      caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
@@ -232,7 +245,7 @@
      //* Reconfigure postfix to use dovecot authentication
      $postconf_commands = array (
         'dovecot_destination_recipient_limit = 1',
         'virtual_transport = dovecot',
         'virtual_transport = lmtp:unix:private/dovecot-lmtp',
         'smtpd_sasl_type = dovecot',
         'smtpd_sasl_path = private/auth'
      );
@@ -319,13 +332,24 @@
         caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
      }
      //* Append the configuration for amavisd to the master.cf file
        // Append the configuration for amavisd to the master.cf file
      $content = rf($conf['postfix']['config_dir'].'/master.cf');
      if(!stristr($content, '127.0.0.1:10025')) //* Only add the content if we had not addded it before
         {
      // Only add the content if we had not addded it before
      if(!preg_match('/^amavis\s+unix\s+/m', $content)) {
         unset($content);
         $content = $this->get_template_file('master_cf_amavis', true);
         af($conf['postfix']['config_dir'].'/master.cf', $content);
         $content = rf($conf['postfix']['config_dir'].'/master.cf');
      }
      if(!preg_match('/^127.0.0.1:10025\s+/m', $content)) {
          unset($content);
            $content = $this->get_template_file('master_cf_amavis10025', true);
         af($conf['postfix']['config_dir'].'/master.cf', $content);
         $content = rf($conf['postfix']['config_dir'].'/master.cf');
      }
      if(!preg_match('/^127.0.0.1:10027\s+/m', $content)) {
         unset($content);
         $content = $this->get_template_file('master_cf_amavis10027', true);
         af($conf['postfix']['config_dir'].'/master.cf', $content);
      }
      unset($content);
@@ -495,6 +519,7 @@
      //* Copy the ISPConfig configuration include
      /*
      $content = $this->get_template_file('apache_ispconfig.conf', true);
      $records = $this->db->queryAllRecords("SELECT * FROM server_ip WHERE server_id = ".$conf["server_id"]." AND virtualhost = 'y'");
@@ -507,6 +532,37 @@
      }
      $this->write_config_file($conf['apache']['vhost_conf_dir'].'/000-ispconfig.conf', $content);
      */
      $tpl = new tpl('apache_ispconfig.conf.master');
      $tpl->setVar('apache_version',getapacheversion());
      $records = $this->db->queryAllRecords('SELECT * FROM '.$conf['mysql']['master_database'].'.server_ip WHERE server_id = '.$conf['server_id']." AND virtualhost = 'y'");
      $ip_addresses = array();
      if(is_array($records) && count($records) > 0) {
         foreach($records as $rec) {
            if($rec['ip_type'] == 'IPv6') {
               $ip_address = '['.$rec['ip_address'].']';
            } else {
               $ip_address = $rec['ip_address'];
            }
            $ports = explode(',', $rec['virtualhost_port']);
            if(is_array($ports)) {
               foreach($ports as $port) {
                  $port = intval($port);
                  if($port > 0 && $port < 65536 && $ip_address != '') {
                     $ip_addresses[] = array('ip_address' => $ip_address, 'port' => $port);
                  }
               }
            }
         }
      }
      if(count($ip_addresses) > 0) $tpl->setLoop('ip_adresses',$ip_addresses);
      wf($conf['apache']['vhost_conf_dir'].'/000-ispconfig.conf', $tpl->grab());
      unset($tpl);
      //* Gentoo by default does not include .vhost files. Add include line to config file.
      $content = rf($conf['apache']['config_file']);
@@ -990,19 +1046,19 @@
      }
      //* Install the update script
      if (is_file('/usr/local/bin/ispconfig_update_from_svn.sh')) {
         unlink('/usr/local/bin/ispconfig_update_from_svn.sh');
      if (is_file('/usr/local/bin/ispconfig_update_from_dev.sh')) {
         unlink('/usr/local/bin/ispconfig_update_from_dev.sh');
      }
      chown($install_dir.'/server/scripts/update_from_svn.sh', 'root');
      chmod($install_dir.'/server/scripts/update_from_svn.sh', 0700);
      chown($install_dir.'/server/scripts/update_from_dev.sh', 'root');
      chmod($install_dir.'/server/scripts/update_from_dev.sh', 0700);
      chown($install_dir.'/server/scripts/update_from_tgz.sh', 'root');
      chmod($install_dir.'/server/scripts/update_from_tgz.sh', 0700);
      chown($install_dir.'/server/scripts/ispconfig_update.sh', 'root');
      chmod($install_dir.'/server/scripts/ispconfig_update.sh', 0700);
      if (!is_link('/usr/local/bin/ispconfig_update_from_svn.sh')) {
         symlink($install_dir.'/server/scripts/ispconfig_update.sh', '/usr/local/bin/ispconfig_update_from_svn.sh');
      if (!is_link('/usr/local/bin/ispconfig_update_from_dev.sh')) {
         symlink($install_dir.'/server/scripts/ispconfig_update.sh', '/usr/local/bin/ispconfig_update_from_dev.sh');
      }
      if (!is_link('/usr/local/bin/ispconfig_update.sh')) {
@@ -1047,6 +1103,9 @@
      //* Remove Domain module as its functions are available in the client module now
      if(@is_dir('/usr/local/ispconfig/interface/web/domain')) exec('rm -rf /usr/local/ispconfig/interface/web/domain');
      // Add symlink for patch tool
      if(!is_link('/usr/local/bin/ispconfig_patch')) exec('ln -s /usr/local/ispconfig/server/scripts/ispconfig_patch /usr/local/bin/ispconfig_patch');
   }