Florian Schaal
2014-10-17 22e5abc44844ffb4aa6a6eaf301d6fde633908e9
install/lib/installer_base.lib.php
@@ -498,6 +498,13 @@
               $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
            $query = "GRANT SELECT, INSERT, DELETE ON ".$value['db'].".`mail_backup` TO '".$value['user']."'@'".$host."' ";
            if ($verbose){
               echo $query ."\n";
            }
            if(!$this->dbmaster->query($query)) {
               $this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
            }
         }
         /*
@@ -633,6 +640,7 @@
      //* Create aliasaes
      exec('/usr/lib/mailman/bin/genaliases 2>/dev/null');
      if(is_file('/var/lib/mailman/data/virtual-mailman')) exec('postmap /var/lib/mailman/data/virtual-mailman');
   }
@@ -674,6 +682,9 @@
      //* mysql-virtual_relayrecipientmaps.cf
      $this->process_postfix_config('mysql-virtual_relayrecipientmaps.cf');
      //* mysql-virtual_outgoing_bcc.cf
      $this->process_postfix_config('mysql-virtual_outgoing_bcc.cf');
      //* postfix-dkim
      $full_file_name=$config_dir.'/tag_as_originating.re';
@@ -698,7 +709,7 @@
      if(!is_user($cf['vmail_username'])) caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
      //* These postconf commands will be executed on installation and update
      $server_ini_rec = $this->db->queryOneRecord("SELECT config FROM server WHERE server_id = ".$conf['server_id']);
      $server_ini_rec = $this->db->queryOneRecord("SELECT config FROM `" . $this->db->quote($conf["mysql"]["database"]) . "`.`server` WHERE server_id = ".$conf['server_id']);
      $server_ini_array = ini_to_array(stripslashes($server_ini_rec['config']));
      unset($server_ini_rec);
@@ -922,6 +933,19 @@
   public function configure_dovecot() {
      global $conf;
      $virtual_transport = 'dovecot';
      // check if virtual_transport must be changed
      if ($this->is_update) {
         $tmp = $inst->db->queryOneRecord("SELECT * FROM ".$conf["mysql"]["database"].".server WHERE server_id = ".$conf['server_id']);
         $ini_array = ini_to_array(stripslashes($tmp['config']));
         // ini_array needs not to be checked, because already done in update.php -> updateDbAndIni()
         if(isset($ini_array['mail']['mailbox_virtual_uidgid_maps']) && $ini_array['mail']['mailbox_virtual_uidgid_maps'] == 'y') {
            $virtual_transport = 'lmtp:unix:private/dovecot-lmtp';
         }
      }
      $config_dir = $conf['dovecot']['config_dir'];
@@ -946,7 +970,7 @@
      // Adding the amavisd commands to the postfix configuration
      $postconf_commands = array (
         'dovecot_destination_recipient_limit = 1',
         'virtual_transport = dovecot',
         'virtual_transport = '.$virtual_transport,
         'smtpd_sasl_type = dovecot',
         'smtpd_sasl_path = private/auth'
      );
@@ -1007,7 +1031,7 @@
      chgrp($config_dir.'/'.$configfile, 'root');
      
      // Dovecot shall ignore mounts in website directory
      exec("doveadm mount add '/var/www/*' ignore");
      if(is_installed('doveadm')) exec("doveadm mount add '/var/www/*' ignore > /dev/null 2> /dev/null");
   }
@@ -1277,10 +1301,20 @@
      if(is_file('/etc/apache2/apache.conf')) {
         if(hasLine('/etc/apache2/apache.conf', 'Include sites-enabled/', 1) == false) {
            if(hasLine('/etc/apache2/apache.conf', 'IncludeOptional sites-enabled/*.conf', 1) == false) {
            if(hasLine('/etc/apache2/apache.conf', 'IncludeOptional sites-enabled/*.conf', 1) == false && hasLine('/etc/apache2/apache.conf', 'IncludeOptional sites-enabled/', 1) == false) {
               replaceLine('/etc/apache2/apache.conf', 'Include sites-enabled/', 'Include sites-enabled/', 1, 1);
            } elseif(hasLine('/etc/apache2/apache.conf', 'IncludeOptional sites-enabled/*.vhost', 1) == false) {
               replaceLine('/etc/apache2/apache.conf', 'IncludeOptional sites-enabled/*.vhost', 'IncludeOptional sites-enabled/*.vhost', 1, 1);
               replaceLine('/etc/apache2/apache.conf', 'IncludeOptional sites-enabled/*.vhost', 'IncludeOptional sites-enabled/', 1, 1);
            }
         }
      }
      if(is_file('/etc/apache2/apache2.conf')) {
         if(hasLine('/etc/apache2/apache2.conf', 'Include sites-enabled/', 1) == false && hasLine('/etc/apache2/apache2.conf', 'IncludeOptional sites-enabled/', 1) == false) {
            if(hasLine('/etc/apache2/apache2.conf', 'Include sites-enabled/*.conf', 1) == true) {
               replaceLine('/etc/apache2/apache2.conf', 'Include sites-enabled/*.conf', 'Include sites-enabled/', 1, 1);
            } elseif(hasLine('/etc/apache2/apache2.conf', 'IncludeOptional sites-enabled/*.conf', 1) == true) {
               replaceLine('/etc/apache2/apache2.conf', 'IncludeOptional sites-enabled/*.conf', 'IncludeOptional sites-enabled/', 1, 1);
            }
         }
      }
@@ -1619,7 +1653,8 @@
         if(!is_user($apps_vhost_user)) caselog($command.' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
         $command = 'adduser '.$conf['nginx']['user'].' '.$apps_vhost_group;
         //$command = 'adduser '.$conf['nginx']['user'].' '.$apps_vhost_group;
         $command = 'usermod -a -G '.$apps_vhost_group.' '.$conf['nginx']['user'];
         caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
         if(!@is_dir($install_dir)){
@@ -2125,7 +2160,15 @@
      //* 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');
      //* Disable rkhunter run and update in debian cronjob as ispconfig is running and updating rkhunter
      if(is_file('/etc/default/rkhunter')) {
         replaceLine('/etc/default/rkhunter', 'CRON_DAILY_RUN="yes"', 'CRON_DAILY_RUN="no"', 1, 0);
         replaceLine('/etc/default/rkhunter', 'CRON_DB_UPDATE="yes"', 'CRON_DB_UPDATE="no"', 1, 0);
      }
      // 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');
   }
@@ -2169,8 +2212,8 @@
      }
      $root_cron_jobs = array(
         "* * * * * ".$install_dir."/server/server.sh 2>&1 > /dev/null | while read line; do echo `/bin/date` \"\$line\" >> ".$conf['ispconfig_log_dir']."/cron.log; done",
         "* * * * * ".$install_dir."/server/cron.sh 2>&1 > /dev/null | while read line; do echo `/bin/date` \"\$line\" >> ".$conf['ispconfig_log_dir']."/cron.log; done"
         "* * * * * ".$install_dir."/server/server.sh 2>&1 | while read line; do echo `/bin/date` \"\$line\" >> ".$conf['ispconfig_log_dir']."/cron.log; done",
         "* * * * * ".$install_dir."/server/cron.sh 2>&1 | while read line; do echo `/bin/date` \"\$line\" >> ".$conf['ispconfig_log_dir']."/cron.log; done"
      );
      if ($conf['nginx']['installed'] == true) {